Skip to content

Commit f1c9950

Browse files
authored
[clang-tidy] Fix file extension inconsistency (#156528)
This fixes an issue with #150791. In CheckRunner, we treat files with unrecognized extensions as ".cpp", by forcefully assigning `extension = ".cpp"` if it's not already one of `".c", ".hpp", ".m", or ".mm"`. Make the new code which chooses the default `-std` argument be consistent with that, so that using other file extensions doesn't trigger an error message like `error: invalid argument '-std=c99' not allowed with 'C++'`
1 parent 5899bca commit f1c9950

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

clang-tools-extra/test/clang-tidy/check_clang_tidy.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,7 @@ def parse_arguments() -> Tuple[argparse.Namespace, List[str]]:
391391
args, extra_args = parser.parse_known_args()
392392
if args.std is None:
393393
_, extension = os.path.splitext(args.assume_filename or args.input_file_name)
394-
args.std = [
395-
"c++11-or-later" if extension in [".cpp", ".hpp", ".mm"] else "c99-or-later"
396-
]
394+
args.std = ["c99-or-later" if extension in [".c", ".m"] else "c++11-or-later"]
397395

398396
return (args, extra_args)
399397

0 commit comments

Comments
 (0)