Skip to content

Commit 625841c

Browse files
authored
[clang-format] Use double hyphen for multiple-letter flags (#100978)
- Closes: #100974
1 parent e490686 commit 625841c

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

clang/tools/clang-format/clang-format-diff.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def main():
134134
if line_count != 0:
135135
end_line += line_count - 1
136136
lines_by_file.setdefault(filename, []).extend(
137-
["-lines", str(start_line) + ":" + str(end_line)]
137+
["--lines", str(start_line) + ":" + str(end_line)]
138138
)
139139

140140
# Reformat files containing changes in place.
@@ -146,12 +146,12 @@ def main():
146146
if args.i:
147147
command.append("-i")
148148
if args.sort_includes:
149-
command.append("-sort-includes")
149+
command.append("--sort-includes")
150150
command.extend(lines)
151151
if args.style:
152-
command.extend(["-style", args.style])
152+
command.extend(["--style", args.style])
153153
if args.fallback_style:
154-
command.extend(["-fallback-style", args.fallback_style])
154+
command.extend(["--fallback-style", args.fallback_style])
155155

156156
try:
157157
p = subprocess.Popen(

clang/tools/clang-format/clang-format-sublime.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ def run(self, edit):
3535
regions = []
3636
command = [binary]
3737
if style:
38-
command.extend(["-style", style])
38+
command.extend(["--style", style])
3939
for region in self.view.sel():
4040
regions.append(region)
4141
region_offset = min(region.a, region.b)
4242
region_length = abs(region.b - region.a)
4343
command.extend(
4444
[
45-
"-offset",
45+
"--offset",
4646
str(region_offset),
47-
"-length",
47+
"--length",
4848
str(region_length),
49-
"-assume-filename",
49+
"--assume-filename",
5050
str(self.view.file_name()),
5151
]
5252
)

clang/tools/clang-format/clang-format.el

+7-7
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,19 @@ uses the function `buffer-file-name'."
166166
(let ((status (apply #'call-process-region
167167
nil nil clang-format-executable
168168
nil `(,temp-buffer ,temp-file) nil
169-
`("-output-replacements-xml"
169+
`("--output-replacements-xml"
170170
;; Guard against a nil assume-file-name.
171171
;; If the clang-format option -assume-filename
172172
;; is given a blank string it will crash as per
173173
;; the following bug report
174174
;; https://bugs.llvm.org/show_bug.cgi?id=34667
175175
,@(and assume-file-name
176-
(list "-assume-filename" assume-file-name))
177-
,@(and style (list "-style" style))
178-
"-fallback-style" ,clang-format-fallback-style
179-
"-offset" ,(number-to-string file-start)
180-
"-length" ,(number-to-string (- file-end file-start))
181-
"-cursor" ,(number-to-string cursor))))
176+
(list "--assume-filename" assume-file-name))
177+
,@(and style (list "--style" style))
178+
"--fallback-style" ,clang-format-fallback-style
179+
"--offset" ,(number-to-string file-start)
180+
"--length" ,(number-to-string (- file-end file-start))
181+
"--cursor" ,(number-to-string cursor))))
182182
(stderr (with-temp-buffer
183183
(unless (zerop (cadr (insert-file-contents temp-file)))
184184
(insert ": "))

clang/tools/clang-format/clang-format.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def main():
7878

7979
# Determine range to format.
8080
if vim.eval('exists("l:lines")') == "1":
81-
lines = ["-lines", vim.eval("l:lines")]
81+
lines = ["--lines", vim.eval("l:lines")]
8282
elif vim.eval('exists("l:formatdiff")') == "1" and os.path.exists(
8383
vim.current.buffer.name
8484
):
@@ -88,12 +88,12 @@ def main():
8888
lines = []
8989
for op in reversed(sequence.get_opcodes()):
9090
if op[0] not in ["equal", "delete"]:
91-
lines += ["-lines", "%s:%s" % (op[3] + 1, op[4])]
91+
lines += ["--lines", "%s:%s" % (op[3] + 1, op[4])]
9292
if lines == []:
9393
return
9494
else:
9595
lines = [
96-
"-lines",
96+
"--lines",
9797
"%s:%s" % (vim.current.range.start + 1, vim.current.range.end + 1),
9898
]
9999

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

118118
# Call formatter.
119-
command = [binary, "-cursor", str(cursor_byte)]
120-
if lines != ["-lines", "all"]:
119+
command = [binary, "--cursor", str(cursor_byte)]
120+
if lines != ["--lines", "all"]:
121121
command += lines
122122
if style:
123-
command.extend(["-style", style])
123+
command.extend(["--style", style])
124124
if fallback_style:
125-
command.extend(["-fallback-style", fallback_style])
125+
command.extend(["--fallback-style", fallback_style])
126126
if vim.current.buffer.name:
127-
command.extend(["-assume-filename", vim.current.buffer.name])
127+
command.extend(["--assume-filename", vim.current.buffer.name])
128128
p = subprocess.Popen(
129129
command,
130130
stdout=subprocess.PIPE,

clang/tools/clang-format/git-clang-format

+3-3
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,12 @@ def clang_format_to_blob(filename, line_ranges, revision=None,
510510
Returns the object ID (SHA-1) of the created blob."""
511511
clang_format_cmd = [binary]
512512
if style:
513-
clang_format_cmd.extend(['-style='+style])
513+
clang_format_cmd.extend(['--style='+style])
514514
clang_format_cmd.extend([
515-
'-lines=%s:%s' % (start_line, start_line+line_count-1)
515+
'--lines=%s:%s' % (start_line, start_line+line_count-1)
516516
for start_line, line_count in line_ranges])
517517
if revision is not None:
518-
clang_format_cmd.extend(['-assume-filename='+filename])
518+
clang_format_cmd.extend(['--assume-filename='+filename])
519519
git_show_cmd = ['git', 'cat-file', 'blob', '%s:%s' % (revision, filename)]
520520
git_show = subprocess.Popen(git_show_cmd, env=env, stdin=subprocess.PIPE,
521521
stdout=subprocess.PIPE)

0 commit comments

Comments
 (0)