Skip to content

[clang-format] Use double hyphen for multiple-letter flags #100978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions clang/tools/clang-format/clang-format-diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def main():
if line_count != 0:
end_line += line_count - 1
lines_by_file.setdefault(filename, []).extend(
["-lines", str(start_line) + ":" + str(end_line)]
["--lines", str(start_line) + ":" + str(end_line)]
)

# Reformat files containing changes in place.
Expand All @@ -146,12 +146,12 @@ def main():
if args.i:
command.append("-i")
if args.sort_includes:
command.append("-sort-includes")
command.append("--sort-includes")
command.extend(lines)
if args.style:
command.extend(["-style", args.style])
command.extend(["--style", args.style])
if args.fallback_style:
command.extend(["-fallback-style", args.fallback_style])
command.extend(["--fallback-style", args.fallback_style])

try:
p = subprocess.Popen(
Expand Down
8 changes: 4 additions & 4 deletions clang/tools/clang-format/clang-format-sublime.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ def run(self, edit):
regions = []
command = [binary]
if style:
command.extend(["-style", style])
command.extend(["--style", style])
for region in self.view.sel():
regions.append(region)
region_offset = min(region.a, region.b)
region_length = abs(region.b - region.a)
command.extend(
[
"-offset",
"--offset",
str(region_offset),
"-length",
"--length",
str(region_length),
"-assume-filename",
"--assume-filename",
str(self.view.file_name()),
]
)
Expand Down
14 changes: 7 additions & 7 deletions clang/tools/clang-format/clang-format.el
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,19 @@ uses the function `buffer-file-name'."
(let ((status (apply #'call-process-region
nil nil clang-format-executable
nil `(,temp-buffer ,temp-file) nil
`("-output-replacements-xml"
`("--output-replacements-xml"
;; Guard against a nil assume-file-name.
;; If the clang-format option -assume-filename
;; is given a blank string it will crash as per
;; the following bug report
;; https://bugs.llvm.org/show_bug.cgi?id=34667
,@(and assume-file-name
(list "-assume-filename" assume-file-name))
,@(and style (list "-style" style))
"-fallback-style" ,clang-format-fallback-style
"-offset" ,(number-to-string file-start)
"-length" ,(number-to-string (- file-end file-start))
"-cursor" ,(number-to-string cursor))))
(list "--assume-filename" assume-file-name))
,@(and style (list "--style" style))
"--fallback-style" ,clang-format-fallback-style
"--offset" ,(number-to-string file-start)
"--length" ,(number-to-string (- file-end file-start))
"--cursor" ,(number-to-string cursor))))
(stderr (with-temp-buffer
(unless (zerop (cadr (insert-file-contents temp-file)))
(insert ": "))
Expand Down
16 changes: 8 additions & 8 deletions clang/tools/clang-format/clang-format.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def main():

# Determine range to format.
if vim.eval('exists("l:lines")') == "1":
lines = ["-lines", vim.eval("l:lines")]
lines = ["--lines", vim.eval("l:lines")]
elif vim.eval('exists("l:formatdiff")') == "1" and os.path.exists(
vim.current.buffer.name
):
Expand All @@ -88,12 +88,12 @@ def main():
lines = []
for op in reversed(sequence.get_opcodes()):
if op[0] not in ["equal", "delete"]:
lines += ["-lines", "%s:%s" % (op[3] + 1, op[4])]
lines += ["--lines", "%s:%s" % (op[3] + 1, op[4])]
if lines == []:
return
else:
lines = [
"-lines",
"--lines",
"%s:%s" % (vim.current.range.start + 1, vim.current.range.end + 1),
]

Expand All @@ -116,15 +116,15 @@ def main():
startupinfo.wShowWindow = subprocess.SW_HIDE

# Call formatter.
command = [binary, "-cursor", str(cursor_byte)]
if lines != ["-lines", "all"]:
command = [binary, "--cursor", str(cursor_byte)]
if lines != ["--lines", "all"]:
command += lines
if style:
command.extend(["-style", style])
command.extend(["--style", style])
if fallback_style:
command.extend(["-fallback-style", fallback_style])
command.extend(["--fallback-style", fallback_style])
if vim.current.buffer.name:
command.extend(["-assume-filename", vim.current.buffer.name])
command.extend(["--assume-filename", vim.current.buffer.name])
p = subprocess.Popen(
command,
stdout=subprocess.PIPE,
Expand Down
6 changes: 3 additions & 3 deletions clang/tools/clang-format/git-clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -499,12 +499,12 @@ def clang_format_to_blob(filename, line_ranges, revision=None,
Returns the object ID (SHA-1) of the created blob."""
clang_format_cmd = [binary]
if style:
clang_format_cmd.extend(['-style='+style])
clang_format_cmd.extend(['--style='+style])
clang_format_cmd.extend([
'-lines=%s:%s' % (start_line, start_line+line_count-1)
'--lines=%s:%s' % (start_line, start_line+line_count-1)
for start_line, line_count in line_ranges])
if revision is not None:
clang_format_cmd.extend(['-assume-filename='+filename])
clang_format_cmd.extend(['--assume-filename='+filename])
git_show_cmd = ['git', 'cat-file', 'blob', '%s:%s' % (revision, filename)]
git_show = subprocess.Popen(git_show_cmd, env=env, stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
Expand Down
Loading