diff --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp --- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp @@ -486,6 +486,9 @@ NamingCheckFailure &Failure = NamingCheckFailures[ID]; SourceRange Range(MacroNameTok.getLocation(), MacroNameTok.getEndLoc()); + if (!isValidAsciiIdentifier(Info.Fixup)) + Failure.FixStatus = ShouldFixStatus::FixInvalidIdentifier; + Failure.Info = std::move(Info); addUsage(ID, Range); } diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp @@ -171,6 +171,11 @@ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration uses identifier '_', which is reserved in the global namespace; cannot be fixed automatically [bugprone-reserved-identifier] // CHECK-FIXES: {{^}}int _;{{$}} +// https://github.com/llvm/llvm-project/issues/52895 +#define _5_kmph_rpm 459 +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: declaration uses identifier '_5_kmph_rpm', which is reserved in the global namespace; cannot be fixed automatically [bugprone-reserved-identifier] +// CHECK-FIXES: {{^}}#define _5_kmph_rpm 459{{$}} + // these should pass #define MACRO(m) int m = 0