aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Ridge <zeratul976@hotmail.com>2025-03-04 03:46:54 -0500
committerGitHub <noreply@github.com>2025-03-04 03:46:54 -0500
commit8266cd9f84b5a7d334ade7ff41393458b3789047 (patch)
tree20368cebaab0679c26bd28b3a7189d7d6e327082
parent80bdfcd411cd8197b0a8b6139b89a87d3a4528fa (diff)
downloadllvm-8266cd9f84b5a7d334ade7ff41393458b3789047.zip
llvm-8266cd9f84b5a7d334ade7ff41393458b3789047.tar.gz
llvm-8266cd9f84b5a7d334ade7ff41393458b3789047.tar.bz2
[clangd] Disable cppcoreguidelines-macro-to-enum clang-tidy checker (#129478)
Clangd does not support its checker because the checker relies on having seen preprocessor conditionals that occur in the preamble, and clangd does not currently replay those. This checker was already disabled under its main name, modernize-macro-to-enum (https://github.com/clangd/clangd/issues/1464). This commit disables it under the alternative name cppcoreguidelines-macro-to-enum as well. Fixes https://github.com/llvm/llvm-project/issues/127965
-rw-r--r--clang-tools-extra/clangd/TidyProvider.cpp1
-rw-r--r--clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp15
2 files changed, 16 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/TidyProvider.cpp b/clang-tools-extra/clangd/TidyProvider.cpp
index 2ac1232..1d79a7a 100644
--- a/clang-tools-extra/clangd/TidyProvider.cpp
+++ b/clang-tools-extra/clangd/TidyProvider.cpp
@@ -210,6 +210,7 @@ TidyProvider disableUnusableChecks(llvm::ArrayRef<std::string> ExtraBadChecks) {
// Check relies on seeing ifndef/define/endif directives,
// clangd doesn't replay those when using a preamble.
"-llvm-header-guard", "-modernize-macro-to-enum",
+ "-cppcoreguidelines-macro-to-enum",
// ----- Crashing Checks -----
diff --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 7a47d6e..f9ff6f2 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -823,6 +823,21 @@ TEST(DiagnosticTest, ClangTidyNoLiteralDataInMacroToken) {
EXPECT_THAT(TU.build().getDiagnostics(), UnorderedElementsAre()); // no-crash
}
+TEST(DiagnosticTest, ClangTidyMacroToEnumCheck) {
+ Annotations Main(R"cpp(
+ #if 1
+ auto foo();
+ #endif
+ )cpp");
+ TestTU TU = TestTU::withCode(Main.code());
+ std::vector<TidyProvider> Providers;
+ Providers.push_back(
+ addTidyChecks("cppcoreguidelines-macro-to-enum,modernize-macro-to-enum"));
+ Providers.push_back(disableUnusableChecks());
+ TU.ClangTidyProvider = combine(std::move(Providers));
+ EXPECT_THAT(TU.build().getDiagnostics(), UnorderedElementsAre()); // no-crash
+}
+
TEST(DiagnosticTest, ElseAfterReturnRange) {
Annotations Main(R"cpp(
int foo(int cond) {