-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Revert "[clang-tidy] support query based custom check" #159380
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
Revert "[clang-tidy] support query based custom check" #159380
Conversation
This reverts commit d05b7f1.
@llvm/pr-subscribers-clang-tools-extra Author: Ingo Müller (ingomueller-net) ChangesReverts llvm/llvm-project#131804. This breaks a build bot; see discussion in the original PR. I could reproduce this problem locally. The problem is that the original PR makes use of Patch is 49.80 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/159380.diff 35 Files Affected:
diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt
index 87050db4e0e75..6b6f2b1ca2276 100644
--- a/clang-tools-extra/CMakeLists.txt
+++ b/clang-tools-extra/CMakeLists.txt
@@ -5,8 +5,6 @@ include(GNUInstallDirs)
option(CLANG_TIDY_ENABLE_STATIC_ANALYZER
"Include static analyzer checks in clang-tidy" ON)
-option(CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
- "Enable query-based custom checks in clang-tidy" ON)
if(CLANG_INCLUDE_TESTS)
umbrella_lit_testsuite_begin(check-clang-tools)
diff --git a/clang-tools-extra/clang-tidy/CMakeLists.txt b/clang-tools-extra/clang-tidy/CMakeLists.txt
index 153356245cfd1..93117cf1d6373 100644
--- a/clang-tools-extra/clang-tidy/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/CMakeLists.txt
@@ -58,7 +58,6 @@ add_subdirectory(bugprone)
add_subdirectory(cert)
add_subdirectory(concurrency)
add_subdirectory(cppcoreguidelines)
-add_subdirectory(custom)
add_subdirectory(darwin)
add_subdirectory(fuchsia)
add_subdirectory(google)
@@ -102,10 +101,6 @@ set(ALL_CLANG_TIDY_CHECKS
clangTidyReadabilityModule
clangTidyZirconModule
)
-
-if(CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS)
- list(APPEND ALL_CLANG_TIDY_CHECKS clangTidyCustomModule)
-endif()
if(CLANG_TIDY_ENABLE_STATIC_ANALYZER)
list(APPEND ALL_CLANG_TIDY_CHECKS clangTidyMPIModule)
endif()
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index db3b9eac53b8f..4c36bbccf44d9 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -53,11 +53,6 @@ LLVM_INSTANTIATE_REGISTRY(clang::tidy::ClangTidyModuleRegistry)
namespace clang::tidy {
-namespace custom {
-extern void registerCustomChecks(const ClangTidyOptions &O,
- ClangTidyCheckFactories &Factories);
-} // namespace custom
-
namespace {
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
#define ANALYZER_CHECK_NAME_PREFIX "clang-analyzer-"
@@ -347,10 +342,6 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS)
: Context(Context), OverlayFS(std::move(OverlayFS)),
CheckFactories(new ClangTidyCheckFactories) {
-#if CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
- if (Context.canExperimentalCustomChecks())
- custom::registerCustomChecks(Context.getOptions(), *CheckFactories);
-#endif
for (ClangTidyModuleRegistry::entry E : ClangTidyModuleRegistry::entries()) {
std::unique_ptr<ClangTidyModule> Module = E.instantiate();
Module->addCheckFactories(*CheckFactories);
@@ -420,10 +411,7 @@ ClangTidyASTConsumerFactory::createASTConsumer(
.getCurrentWorkingDirectory();
if (WorkingDir)
Context.setCurrentBuildDirectory(WorkingDir.get());
-#if CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
- if (Context.canExperimentalCustomChecks())
- custom::registerCustomChecks(Context.getOptions(), *CheckFactories);
-#endif
+
std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
CheckFactories->createChecksForLanguage(&Context);
@@ -509,13 +497,13 @@ ClangTidyOptions::OptionMap ClangTidyASTConsumerFactory::getCheckOptions() {
return Options;
}
-std::vector<std::string> getCheckNames(const ClangTidyOptions &Options,
- bool AllowEnablingAnalyzerAlphaCheckers,
- bool ExperimentalCustomChecks) {
+std::vector<std::string>
+getCheckNames(const ClangTidyOptions &Options,
+ bool AllowEnablingAnalyzerAlphaCheckers) {
clang::tidy::ClangTidyContext Context(
std::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(),
Options),
- AllowEnablingAnalyzerAlphaCheckers, false, ExperimentalCustomChecks);
+ AllowEnablingAnalyzerAlphaCheckers);
ClangTidyASTConsumerFactory Factory(Context);
return Factory.getCheckNames();
}
@@ -536,12 +524,11 @@ void filterCheckOptions(ClangTidyOptions &Options,
ClangTidyOptions::OptionMap
getCheckOptions(const ClangTidyOptions &Options,
- bool AllowEnablingAnalyzerAlphaCheckers,
- bool ExperimentalCustomChecks) {
+ bool AllowEnablingAnalyzerAlphaCheckers) {
clang::tidy::ClangTidyContext Context(
std::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(),
Options),
- AllowEnablingAnalyzerAlphaCheckers, false, ExperimentalCustomChecks);
+ AllowEnablingAnalyzerAlphaCheckers);
ClangTidyDiagnosticConsumer DiagConsumer(Context);
auto DiagOpts = std::make_unique<DiagnosticOptions>();
DiagnosticsEngine DE(llvm::makeIntrusiveRefCnt<DiagnosticIDs>(), *DiagOpts,
@@ -678,19 +665,15 @@ void exportReplacements(const llvm::StringRef MainFilePath,
YAML << TUD;
}
-ChecksAndOptions getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers,
- bool ExperimentalCustomChecks) {
+ChecksAndOptions
+getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers) {
ChecksAndOptions Result;
ClangTidyOptions Opts;
Opts.Checks = "*";
clang::tidy::ClangTidyContext Context(
std::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(), Opts),
- AllowEnablingAnalyzerAlphaCheckers, false, ExperimentalCustomChecks);
+ AllowEnablingAnalyzerAlphaCheckers);
ClangTidyCheckFactories Factories;
-#if CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
- if (ExperimentalCustomChecks)
- custom::registerCustomChecks(Context.getOptions(), Factories);
-#endif
for (const ClangTidyModuleRegistry::entry &Module :
ClangTidyModuleRegistry::entries()) {
Module.instantiate()->addCheckFactories(Factories);
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.h b/clang-tools-extra/clang-tidy/ClangTidy.h
index f4e6b7ef34ab0..3d1d3ca0b1791 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.h
+++ b/clang-tools-extra/clang-tidy/ClangTidy.h
@@ -56,16 +56,15 @@ class ClangTidyASTConsumerFactory {
/// Fills the list of check names that are enabled when the provided
/// filters are applied.
std::vector<std::string> getCheckNames(const ClangTidyOptions &Options,
- bool AllowEnablingAnalyzerAlphaCheckers,
- bool ExperimentalCustomChecks);
+ bool AllowEnablingAnalyzerAlphaCheckers);
struct ChecksAndOptions {
llvm::StringSet<> Checks;
llvm::StringSet<> Options;
};
-ChecksAndOptions getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers,
- bool ExperimentalCustomChecks);
+ChecksAndOptions
+getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers = true);
/// Returns the effective check-specific options.
///
@@ -75,8 +74,7 @@ ChecksAndOptions getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers,
/// Options.
ClangTidyOptions::OptionMap
getCheckOptions(const ClangTidyOptions &Options,
- bool AllowEnablingAnalyzerAlphaCheckers,
- bool ExperimentalCustomChecks);
+ bool AllowEnablingAnalyzerAlphaCheckers);
/// Filters CheckOptions in \p Options to only include options specified in
/// the \p EnabledChecks which is a sorted vector.
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 823c7b5626e97..d07f15a10555f 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -160,12 +160,11 @@ ClangTidyError::ClangTidyError(StringRef CheckName,
ClangTidyContext::ClangTidyContext(
std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider,
- bool AllowEnablingAnalyzerAlphaCheckers, bool EnableModuleHeadersParsing,
- bool ExperimentalCustomChecks)
+ bool AllowEnablingAnalyzerAlphaCheckers, bool EnableModuleHeadersParsing)
: OptionsProvider(std::move(OptionsProvider)),
+
AllowEnablingAnalyzerAlphaCheckers(AllowEnablingAnalyzerAlphaCheckers),
- EnableModuleHeadersParsing(EnableModuleHeadersParsing),
- ExperimentalCustomChecks(ExperimentalCustomChecks) {
+ EnableModuleHeadersParsing(EnableModuleHeadersParsing) {
// Before the first translation unit we can get errors related to command-line
// parsing, use dummy string for the file name in this case.
setCurrentFile("dummy");
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index 21ffd9de35c19..a854756d647c2 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -19,7 +19,6 @@
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Regex.h"
#include <optional>
-#include <utility>
namespace clang {
@@ -69,13 +68,10 @@ struct ClangTidyStats {
/// \endcode
class ClangTidyContext {
public:
- ClangTidyContext(std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider)
- : ClangTidyContext(std::move(OptionsProvider), false, false, false) {}
/// Initializes \c ClangTidyContext instance.
ClangTidyContext(std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider,
- bool AllowEnablingAnalyzerAlphaCheckers,
- bool EnableModuleHeadersParsing,
- bool ExperimentalCustomChecks);
+ bool AllowEnablingAnalyzerAlphaCheckers = false,
+ bool EnableModuleHeadersParsing = false);
/// Sets the DiagnosticsEngine that diag() will emit diagnostics to.
// FIXME: this is required initialization, and should be a constructor param.
// Fix the context -> diag engine -> consumer -> context initialization cycle.
@@ -214,10 +210,6 @@ class ClangTidyContext {
return EnableModuleHeadersParsing;
}
- // whether experimental custom checks can be enabled.
- // enabled with `--experimental-custom-checks`
- bool canExperimentalCustomChecks() const { return ExperimentalCustomChecks; }
-
void setSelfContainedDiags(bool Value) { SelfContainedDiags = Value; }
bool areDiagsSelfContained() const { return SelfContainedDiags; }
@@ -266,7 +258,6 @@ class ClangTidyContext {
bool AllowEnablingAnalyzerAlphaCheckers;
bool EnableModuleHeadersParsing;
- bool ExperimentalCustomChecks;
bool SelfContainedDiags = false;
diff --git a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
index cdf6ce2045a5d..adde9136ff1dd 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
@@ -54,13 +54,6 @@ extern volatile int CppCoreGuidelinesModuleAnchorSource;
static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
CppCoreGuidelinesModuleAnchorSource;
-#if CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
-// This anchor is used to force the linker to link the CustomModule.
-extern volatile int CustomModuleAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED CustomModuleAnchorDestination =
- CustomModuleAnchorSource;
-#endif
-
// This anchor is used to force the linker to link the DarwinModule.
extern volatile int DarwinModuleAnchorSource;
static int LLVM_ATTRIBUTE_UNUSED DarwinModuleAnchorDestination =
diff --git a/clang-tools-extra/clang-tidy/ClangTidyModule.h b/clang-tools-extra/clang-tidy/ClangTidyModule.h
index 8d697c6261286..7407ab580d378 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyModule.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyModule.h
@@ -62,8 +62,6 @@ class ClangTidyCheckFactories {
});
}
- void eraseCheck(llvm::StringRef CheckName) { Factories.erase(CheckName); }
-
/// Create instances of checks that are enabled.
std::vector<std::unique_ptr<ClangTidyCheck>>
createChecks(ClangTidyContext *Context) const;
diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index b752a9beb0e34..dfa3521a25513 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -8,10 +8,8 @@
#include "ClangTidyOptions.h"
#include "ClangTidyModuleRegistry.h"
-#include "clang/Basic/DiagnosticIDs.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/MemoryBufferRef.h"
@@ -131,51 +129,6 @@ void yamlize(IO &IO, ClangTidyOptions::OptionMap &Val, bool,
}
}
-namespace {
-struct MultiLineString {
- std::string &S;
-};
-} // namespace
-
-template <> struct BlockScalarTraits<MultiLineString> {
- static void output(const MultiLineString &S, void *Ctxt, raw_ostream &OS) {
- OS << S.S;
- }
- static StringRef input(StringRef Str, void *Ctxt, MultiLineString &S) {
- S.S = Str;
- return "";
- }
-};
-
-template <> struct ScalarEnumerationTraits<clang::DiagnosticIDs::Level> {
- static void enumeration(IO &IO, clang::DiagnosticIDs::Level &Level) {
- IO.enumCase(Level, "Warning", clang::DiagnosticIDs::Level::Warning);
- IO.enumCase(Level, "Note", clang::DiagnosticIDs::Level::Note);
- }
-};
-template <> struct SequenceElementTraits<ClangTidyOptions::CustomCheckDiag> {
- static const bool flow = false;
-};
-template <> struct MappingTraits<ClangTidyOptions::CustomCheckDiag> {
- static void mapping(IO &IO, ClangTidyOptions::CustomCheckDiag &D) {
- IO.mapRequired("BindName", D.BindName);
- MultiLineString MLS{D.Message};
- IO.mapRequired("Message", MLS);
- IO.mapOptional("Level", D.Level);
- }
-};
-template <> struct SequenceElementTraits<ClangTidyOptions::CustomCheckValue> {
- static const bool flow = false;
-};
-template <> struct MappingTraits<ClangTidyOptions::CustomCheckValue> {
- static void mapping(IO &IO, ClangTidyOptions::CustomCheckValue &V) {
- IO.mapRequired("Name", V.Name);
- MultiLineString MLS{V.Query};
- IO.mapRequired("Query", MLS);
- IO.mapRequired("Diagnostic", V.Diags);
- }
-};
-
struct ChecksVariant {
std::optional<std::string> AsString;
std::optional<std::vector<std::string>> AsVector;
@@ -231,7 +184,6 @@ template <> struct MappingTraits<ClangTidyOptions> {
IO.mapOptional("InheritParentConfig", Options.InheritParentConfig);
IO.mapOptional("UseColor", Options.UseColor);
IO.mapOptional("SystemHeaders", Options.SystemHeaders);
- IO.mapOptional("CustomChecks", Options.CustomChecks);
}
};
@@ -293,8 +245,7 @@ ClangTidyOptions &ClangTidyOptions::mergeWith(const ClangTidyOptions &Other,
overrideValue(UseColor, Other.UseColor);
mergeVectors(ExtraArgs, Other.ExtraArgs);
mergeVectors(ExtraArgsBefore, Other.ExtraArgsBefore);
- // FIXME: how to handle duplicate names check?
- mergeVectors(CustomChecks, Other.CustomChecks);
+
for (const auto &KeyValue : Other.CheckOptions) {
CheckOptions.insert_or_assign(
KeyValue.getKey(),
diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
index 2aae92f1d9eb3..22a954d2ac645 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -9,7 +9,6 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYOPTIONS_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYOPTIONS_H
-#include "clang/Basic/DiagnosticIDs.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringMap.h"
@@ -130,19 +129,6 @@ struct ClangTidyOptions {
/// Key-value mapping used to store check-specific options.
OptionMap CheckOptions;
- struct CustomCheckDiag {
- std::string BindName;
- std::string Message;
- std::optional<DiagnosticIDs::Level> Level;
- };
- struct CustomCheckValue {
- std::string Name;
- std::string Query;
- llvm::SmallVector<CustomCheckDiag> Diags;
- };
- using CustomCheckValueList = llvm::SmallVector<CustomCheckValue>;
- std::optional<CustomCheckValueList> CustomChecks;
-
using ArgList = std::vector<std::string>;
/// Add extra compilation arguments to the end of the list.
diff --git a/clang-tools-extra/clang-tidy/clang-tidy-config.h.cmake b/clang-tools-extra/clang-tidy/clang-tidy-config.h.cmake
index 400e89ea60b33..f4d1a4b38004b 100644
--- a/clang-tools-extra/clang-tidy/clang-tidy-config.h.cmake
+++ b/clang-tools-extra/clang-tidy/clang-tidy-config.h.cmake
@@ -6,6 +6,5 @@
#define CLANG_TIDY_CONFIG_H
#cmakedefine01 CLANG_TIDY_ENABLE_STATIC_ANALYZER
-#cmakedefine01 CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
#endif
diff --git a/clang-tools-extra/clang-tidy/custom/CMakeLists.txt b/clang-tools-extra/clang-tidy/custom/CMakeLists.txt
deleted file mode 100644
index 0b43387970903..0000000000000
--- a/clang-tools-extra/clang-tidy/custom/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-if(CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS)
- set(LLVM_LINK_COMPONENTS
- support
- )
-
- add_clang_library(clangTidyCustomModule STATIC
- CustomTidyModule.cpp
- QueryCheck.cpp
-
- LINK_LIBS
- clangTidy
- clangTidyUtils
-
- DEPENDS
- ClangDriverOptions
- )
-
- clang_target_link_libraries(clangTidyCustomModule
- PRIVATE
- clangQuery
- )
-endif()
diff --git a/clang-tools-extra/clang-tidy/custom/CustomTidyModule.cpp b/clang-tools-extra/clang-tidy/custom/CustomTidyModule.cpp
deleted file mode 100644
index 6aea3e4de4c6d..0000000000000
--- a/clang-tools-extra/clang-tidy/custom/CustomTidyModule.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "../ClangTidy.h"
-#include "../ClangTidyModule.h"
-#include "../ClangTidyModuleRegistry.h"
-#include "../ClangTidyOptions.h"
-#include "QueryCheck.h"
-#include "llvm/ADT/SmallSet.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/StringRef.h"
-#include <cassert>
-#include <memory>
-
-namespace clang::tidy {
-namespace custom {
-
-class CustomModule : public ClangTidyModule {
-public:
- void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {}
-};
-
-// We need to register the checks more flexibly than builtin modules. The checks
-// will changed dynamically when switching to different source file.
-extern void registerCustomChecks(const ClangTidyOptions &Options,
- ClangTidyCheckFactories &Factories) {
- static llvm::SmallSet<llvm::SmallString<32>, 8> CustomCheckNames{};
- if (!Options.CustomChecks.has_value() || Options.CustomChecks->empty())
- return;
- for (const llvm::SmallString<32> &Name : CustomCheckNames)
- Factories.eraseCheck(Name);
- for (const ClangTidyOptions::CustomCheckValue &V :
- Options.CustomChecks.value()) {
- llvm::SmallString<32> Name = llvm::StringRef{"custom-" + V.Name};
- Factories.registerCheckFactory(
- // add custom- prefix to avoid conflicts with builtin checks
- Name, [&V](llvm::StringRef Name, ClangTidyContext *Context) {
- return std::make_unique<custom::QueryCheck>(Name, V, Context);
- });
- CustomCheckNames.insert(std::move(Name));
- }
-}
-
-} // namespace custom
-
-// Register the CustomTidyModule using this statically initialized variable.
-static ClangTidyModuleRegistry::Add<custom::CustomModule>
- X("custom-module", "Adds custom query lint checks.");
-
-// This anchor is used to force the linker to link in the generated object file
-// and thus register the AlteraModule.
-volatile int CustomModuleAnchorSource = 0; // NOLINT (misc-use-internal-linkage)
-
-} // namespace clang::tidy
diff --git a/clang-tools-extra/clang-tidy/custom/QueryCheck.cpp b/clang-tools-extra/clang-tidy/custom/QueryCheck.cpp
deleted file mode 100644
index f83c138fbfaf5..0000000000000
--- a/clang-tools-extra/clang-tidy/custom/QueryCheck.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-//===--- QueryCheck.cpp - clang-tidy --------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "QueryCheck.h"
-#include "../../clang-query/Query.h"
-#include "../../clang-query/QueryParser.h"
-#includ...
[truncated]
|
@llvm/pr-subscribers-clang-tidy Author: Ingo Müller (ingomueller-net) ChangesReverts llvm/llvm-project#131804. This breaks a build bot; see discussion in the original PR. I could reproduce this problem locally. The problem is that the original PR makes use of Patch is 49.80 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/159380.diff 35 Files Affected:
diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt
index 87050db4e0e75..6b6f2b1ca2276 100644
--- a/clang-tools-extra/CMakeLists.txt
+++ b/clang-tools-extra/CMakeLists.txt
@@ -5,8 +5,6 @@ include(GNUInstallDirs)
option(CLANG_TIDY_ENABLE_STATIC_ANALYZER
"Include static analyzer checks in clang-tidy" ON)
-option(CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
- "Enable query-based custom checks in clang-tidy" ON)
if(CLANG_INCLUDE_TESTS)
umbrella_lit_testsuite_begin(check-clang-tools)
diff --git a/clang-tools-extra/clang-tidy/CMakeLists.txt b/clang-tools-extra/clang-tidy/CMakeLists.txt
index 153356245cfd1..93117cf1d6373 100644
--- a/clang-tools-extra/clang-tidy/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/CMakeLists.txt
@@ -58,7 +58,6 @@ add_subdirectory(bugprone)
add_subdirectory(cert)
add_subdirectory(concurrency)
add_subdirectory(cppcoreguidelines)
-add_subdirectory(custom)
add_subdirectory(darwin)
add_subdirectory(fuchsia)
add_subdirectory(google)
@@ -102,10 +101,6 @@ set(ALL_CLANG_TIDY_CHECKS
clangTidyReadabilityModule
clangTidyZirconModule
)
-
-if(CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS)
- list(APPEND ALL_CLANG_TIDY_CHECKS clangTidyCustomModule)
-endif()
if(CLANG_TIDY_ENABLE_STATIC_ANALYZER)
list(APPEND ALL_CLANG_TIDY_CHECKS clangTidyMPIModule)
endif()
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index db3b9eac53b8f..4c36bbccf44d9 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -53,11 +53,6 @@ LLVM_INSTANTIATE_REGISTRY(clang::tidy::ClangTidyModuleRegistry)
namespace clang::tidy {
-namespace custom {
-extern void registerCustomChecks(const ClangTidyOptions &O,
- ClangTidyCheckFactories &Factories);
-} // namespace custom
-
namespace {
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
#define ANALYZER_CHECK_NAME_PREFIX "clang-analyzer-"
@@ -347,10 +342,6 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS)
: Context(Context), OverlayFS(std::move(OverlayFS)),
CheckFactories(new ClangTidyCheckFactories) {
-#if CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
- if (Context.canExperimentalCustomChecks())
- custom::registerCustomChecks(Context.getOptions(), *CheckFactories);
-#endif
for (ClangTidyModuleRegistry::entry E : ClangTidyModuleRegistry::entries()) {
std::unique_ptr<ClangTidyModule> Module = E.instantiate();
Module->addCheckFactories(*CheckFactories);
@@ -420,10 +411,7 @@ ClangTidyASTConsumerFactory::createASTConsumer(
.getCurrentWorkingDirectory();
if (WorkingDir)
Context.setCurrentBuildDirectory(WorkingDir.get());
-#if CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
- if (Context.canExperimentalCustomChecks())
- custom::registerCustomChecks(Context.getOptions(), *CheckFactories);
-#endif
+
std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
CheckFactories->createChecksForLanguage(&Context);
@@ -509,13 +497,13 @@ ClangTidyOptions::OptionMap ClangTidyASTConsumerFactory::getCheckOptions() {
return Options;
}
-std::vector<std::string> getCheckNames(const ClangTidyOptions &Options,
- bool AllowEnablingAnalyzerAlphaCheckers,
- bool ExperimentalCustomChecks) {
+std::vector<std::string>
+getCheckNames(const ClangTidyOptions &Options,
+ bool AllowEnablingAnalyzerAlphaCheckers) {
clang::tidy::ClangTidyContext Context(
std::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(),
Options),
- AllowEnablingAnalyzerAlphaCheckers, false, ExperimentalCustomChecks);
+ AllowEnablingAnalyzerAlphaCheckers);
ClangTidyASTConsumerFactory Factory(Context);
return Factory.getCheckNames();
}
@@ -536,12 +524,11 @@ void filterCheckOptions(ClangTidyOptions &Options,
ClangTidyOptions::OptionMap
getCheckOptions(const ClangTidyOptions &Options,
- bool AllowEnablingAnalyzerAlphaCheckers,
- bool ExperimentalCustomChecks) {
+ bool AllowEnablingAnalyzerAlphaCheckers) {
clang::tidy::ClangTidyContext Context(
std::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(),
Options),
- AllowEnablingAnalyzerAlphaCheckers, false, ExperimentalCustomChecks);
+ AllowEnablingAnalyzerAlphaCheckers);
ClangTidyDiagnosticConsumer DiagConsumer(Context);
auto DiagOpts = std::make_unique<DiagnosticOptions>();
DiagnosticsEngine DE(llvm::makeIntrusiveRefCnt<DiagnosticIDs>(), *DiagOpts,
@@ -678,19 +665,15 @@ void exportReplacements(const llvm::StringRef MainFilePath,
YAML << TUD;
}
-ChecksAndOptions getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers,
- bool ExperimentalCustomChecks) {
+ChecksAndOptions
+getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers) {
ChecksAndOptions Result;
ClangTidyOptions Opts;
Opts.Checks = "*";
clang::tidy::ClangTidyContext Context(
std::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(), Opts),
- AllowEnablingAnalyzerAlphaCheckers, false, ExperimentalCustomChecks);
+ AllowEnablingAnalyzerAlphaCheckers);
ClangTidyCheckFactories Factories;
-#if CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
- if (ExperimentalCustomChecks)
- custom::registerCustomChecks(Context.getOptions(), Factories);
-#endif
for (const ClangTidyModuleRegistry::entry &Module :
ClangTidyModuleRegistry::entries()) {
Module.instantiate()->addCheckFactories(Factories);
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.h b/clang-tools-extra/clang-tidy/ClangTidy.h
index f4e6b7ef34ab0..3d1d3ca0b1791 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.h
+++ b/clang-tools-extra/clang-tidy/ClangTidy.h
@@ -56,16 +56,15 @@ class ClangTidyASTConsumerFactory {
/// Fills the list of check names that are enabled when the provided
/// filters are applied.
std::vector<std::string> getCheckNames(const ClangTidyOptions &Options,
- bool AllowEnablingAnalyzerAlphaCheckers,
- bool ExperimentalCustomChecks);
+ bool AllowEnablingAnalyzerAlphaCheckers);
struct ChecksAndOptions {
llvm::StringSet<> Checks;
llvm::StringSet<> Options;
};
-ChecksAndOptions getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers,
- bool ExperimentalCustomChecks);
+ChecksAndOptions
+getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers = true);
/// Returns the effective check-specific options.
///
@@ -75,8 +74,7 @@ ChecksAndOptions getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers,
/// Options.
ClangTidyOptions::OptionMap
getCheckOptions(const ClangTidyOptions &Options,
- bool AllowEnablingAnalyzerAlphaCheckers,
- bool ExperimentalCustomChecks);
+ bool AllowEnablingAnalyzerAlphaCheckers);
/// Filters CheckOptions in \p Options to only include options specified in
/// the \p EnabledChecks which is a sorted vector.
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 823c7b5626e97..d07f15a10555f 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -160,12 +160,11 @@ ClangTidyError::ClangTidyError(StringRef CheckName,
ClangTidyContext::ClangTidyContext(
std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider,
- bool AllowEnablingAnalyzerAlphaCheckers, bool EnableModuleHeadersParsing,
- bool ExperimentalCustomChecks)
+ bool AllowEnablingAnalyzerAlphaCheckers, bool EnableModuleHeadersParsing)
: OptionsProvider(std::move(OptionsProvider)),
+
AllowEnablingAnalyzerAlphaCheckers(AllowEnablingAnalyzerAlphaCheckers),
- EnableModuleHeadersParsing(EnableModuleHeadersParsing),
- ExperimentalCustomChecks(ExperimentalCustomChecks) {
+ EnableModuleHeadersParsing(EnableModuleHeadersParsing) {
// Before the first translation unit we can get errors related to command-line
// parsing, use dummy string for the file name in this case.
setCurrentFile("dummy");
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index 21ffd9de35c19..a854756d647c2 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -19,7 +19,6 @@
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Regex.h"
#include <optional>
-#include <utility>
namespace clang {
@@ -69,13 +68,10 @@ struct ClangTidyStats {
/// \endcode
class ClangTidyContext {
public:
- ClangTidyContext(std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider)
- : ClangTidyContext(std::move(OptionsProvider), false, false, false) {}
/// Initializes \c ClangTidyContext instance.
ClangTidyContext(std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider,
- bool AllowEnablingAnalyzerAlphaCheckers,
- bool EnableModuleHeadersParsing,
- bool ExperimentalCustomChecks);
+ bool AllowEnablingAnalyzerAlphaCheckers = false,
+ bool EnableModuleHeadersParsing = false);
/// Sets the DiagnosticsEngine that diag() will emit diagnostics to.
// FIXME: this is required initialization, and should be a constructor param.
// Fix the context -> diag engine -> consumer -> context initialization cycle.
@@ -214,10 +210,6 @@ class ClangTidyContext {
return EnableModuleHeadersParsing;
}
- // whether experimental custom checks can be enabled.
- // enabled with `--experimental-custom-checks`
- bool canExperimentalCustomChecks() const { return ExperimentalCustomChecks; }
-
void setSelfContainedDiags(bool Value) { SelfContainedDiags = Value; }
bool areDiagsSelfContained() const { return SelfContainedDiags; }
@@ -266,7 +258,6 @@ class ClangTidyContext {
bool AllowEnablingAnalyzerAlphaCheckers;
bool EnableModuleHeadersParsing;
- bool ExperimentalCustomChecks;
bool SelfContainedDiags = false;
diff --git a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
index cdf6ce2045a5d..adde9136ff1dd 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
@@ -54,13 +54,6 @@ extern volatile int CppCoreGuidelinesModuleAnchorSource;
static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
CppCoreGuidelinesModuleAnchorSource;
-#if CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
-// This anchor is used to force the linker to link the CustomModule.
-extern volatile int CustomModuleAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED CustomModuleAnchorDestination =
- CustomModuleAnchorSource;
-#endif
-
// This anchor is used to force the linker to link the DarwinModule.
extern volatile int DarwinModuleAnchorSource;
static int LLVM_ATTRIBUTE_UNUSED DarwinModuleAnchorDestination =
diff --git a/clang-tools-extra/clang-tidy/ClangTidyModule.h b/clang-tools-extra/clang-tidy/ClangTidyModule.h
index 8d697c6261286..7407ab580d378 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyModule.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyModule.h
@@ -62,8 +62,6 @@ class ClangTidyCheckFactories {
});
}
- void eraseCheck(llvm::StringRef CheckName) { Factories.erase(CheckName); }
-
/// Create instances of checks that are enabled.
std::vector<std::unique_ptr<ClangTidyCheck>>
createChecks(ClangTidyContext *Context) const;
diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index b752a9beb0e34..dfa3521a25513 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -8,10 +8,8 @@
#include "ClangTidyOptions.h"
#include "ClangTidyModuleRegistry.h"
-#include "clang/Basic/DiagnosticIDs.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/MemoryBufferRef.h"
@@ -131,51 +129,6 @@ void yamlize(IO &IO, ClangTidyOptions::OptionMap &Val, bool,
}
}
-namespace {
-struct MultiLineString {
- std::string &S;
-};
-} // namespace
-
-template <> struct BlockScalarTraits<MultiLineString> {
- static void output(const MultiLineString &S, void *Ctxt, raw_ostream &OS) {
- OS << S.S;
- }
- static StringRef input(StringRef Str, void *Ctxt, MultiLineString &S) {
- S.S = Str;
- return "";
- }
-};
-
-template <> struct ScalarEnumerationTraits<clang::DiagnosticIDs::Level> {
- static void enumeration(IO &IO, clang::DiagnosticIDs::Level &Level) {
- IO.enumCase(Level, "Warning", clang::DiagnosticIDs::Level::Warning);
- IO.enumCase(Level, "Note", clang::DiagnosticIDs::Level::Note);
- }
-};
-template <> struct SequenceElementTraits<ClangTidyOptions::CustomCheckDiag> {
- static const bool flow = false;
-};
-template <> struct MappingTraits<ClangTidyOptions::CustomCheckDiag> {
- static void mapping(IO &IO, ClangTidyOptions::CustomCheckDiag &D) {
- IO.mapRequired("BindName", D.BindName);
- MultiLineString MLS{D.Message};
- IO.mapRequired("Message", MLS);
- IO.mapOptional("Level", D.Level);
- }
-};
-template <> struct SequenceElementTraits<ClangTidyOptions::CustomCheckValue> {
- static const bool flow = false;
-};
-template <> struct MappingTraits<ClangTidyOptions::CustomCheckValue> {
- static void mapping(IO &IO, ClangTidyOptions::CustomCheckValue &V) {
- IO.mapRequired("Name", V.Name);
- MultiLineString MLS{V.Query};
- IO.mapRequired("Query", MLS);
- IO.mapRequired("Diagnostic", V.Diags);
- }
-};
-
struct ChecksVariant {
std::optional<std::string> AsString;
std::optional<std::vector<std::string>> AsVector;
@@ -231,7 +184,6 @@ template <> struct MappingTraits<ClangTidyOptions> {
IO.mapOptional("InheritParentConfig", Options.InheritParentConfig);
IO.mapOptional("UseColor", Options.UseColor);
IO.mapOptional("SystemHeaders", Options.SystemHeaders);
- IO.mapOptional("CustomChecks", Options.CustomChecks);
}
};
@@ -293,8 +245,7 @@ ClangTidyOptions &ClangTidyOptions::mergeWith(const ClangTidyOptions &Other,
overrideValue(UseColor, Other.UseColor);
mergeVectors(ExtraArgs, Other.ExtraArgs);
mergeVectors(ExtraArgsBefore, Other.ExtraArgsBefore);
- // FIXME: how to handle duplicate names check?
- mergeVectors(CustomChecks, Other.CustomChecks);
+
for (const auto &KeyValue : Other.CheckOptions) {
CheckOptions.insert_or_assign(
KeyValue.getKey(),
diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
index 2aae92f1d9eb3..22a954d2ac645 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -9,7 +9,6 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYOPTIONS_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYOPTIONS_H
-#include "clang/Basic/DiagnosticIDs.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringMap.h"
@@ -130,19 +129,6 @@ struct ClangTidyOptions {
/// Key-value mapping used to store check-specific options.
OptionMap CheckOptions;
- struct CustomCheckDiag {
- std::string BindName;
- std::string Message;
- std::optional<DiagnosticIDs::Level> Level;
- };
- struct CustomCheckValue {
- std::string Name;
- std::string Query;
- llvm::SmallVector<CustomCheckDiag> Diags;
- };
- using CustomCheckValueList = llvm::SmallVector<CustomCheckValue>;
- std::optional<CustomCheckValueList> CustomChecks;
-
using ArgList = std::vector<std::string>;
/// Add extra compilation arguments to the end of the list.
diff --git a/clang-tools-extra/clang-tidy/clang-tidy-config.h.cmake b/clang-tools-extra/clang-tidy/clang-tidy-config.h.cmake
index 400e89ea60b33..f4d1a4b38004b 100644
--- a/clang-tools-extra/clang-tidy/clang-tidy-config.h.cmake
+++ b/clang-tools-extra/clang-tidy/clang-tidy-config.h.cmake
@@ -6,6 +6,5 @@
#define CLANG_TIDY_CONFIG_H
#cmakedefine01 CLANG_TIDY_ENABLE_STATIC_ANALYZER
-#cmakedefine01 CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
#endif
diff --git a/clang-tools-extra/clang-tidy/custom/CMakeLists.txt b/clang-tools-extra/clang-tidy/custom/CMakeLists.txt
deleted file mode 100644
index 0b43387970903..0000000000000
--- a/clang-tools-extra/clang-tidy/custom/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-if(CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS)
- set(LLVM_LINK_COMPONENTS
- support
- )
-
- add_clang_library(clangTidyCustomModule STATIC
- CustomTidyModule.cpp
- QueryCheck.cpp
-
- LINK_LIBS
- clangTidy
- clangTidyUtils
-
- DEPENDS
- ClangDriverOptions
- )
-
- clang_target_link_libraries(clangTidyCustomModule
- PRIVATE
- clangQuery
- )
-endif()
diff --git a/clang-tools-extra/clang-tidy/custom/CustomTidyModule.cpp b/clang-tools-extra/clang-tidy/custom/CustomTidyModule.cpp
deleted file mode 100644
index 6aea3e4de4c6d..0000000000000
--- a/clang-tools-extra/clang-tidy/custom/CustomTidyModule.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "../ClangTidy.h"
-#include "../ClangTidyModule.h"
-#include "../ClangTidyModuleRegistry.h"
-#include "../ClangTidyOptions.h"
-#include "QueryCheck.h"
-#include "llvm/ADT/SmallSet.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/StringRef.h"
-#include <cassert>
-#include <memory>
-
-namespace clang::tidy {
-namespace custom {
-
-class CustomModule : public ClangTidyModule {
-public:
- void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {}
-};
-
-// We need to register the checks more flexibly than builtin modules. The checks
-// will changed dynamically when switching to different source file.
-extern void registerCustomChecks(const ClangTidyOptions &Options,
- ClangTidyCheckFactories &Factories) {
- static llvm::SmallSet<llvm::SmallString<32>, 8> CustomCheckNames{};
- if (!Options.CustomChecks.has_value() || Options.CustomChecks->empty())
- return;
- for (const llvm::SmallString<32> &Name : CustomCheckNames)
- Factories.eraseCheck(Name);
- for (const ClangTidyOptions::CustomCheckValue &V :
- Options.CustomChecks.value()) {
- llvm::SmallString<32> Name = llvm::StringRef{"custom-" + V.Name};
- Factories.registerCheckFactory(
- // add custom- prefix to avoid conflicts with builtin checks
- Name, [&V](llvm::StringRef Name, ClangTidyContext *Context) {
- return std::make_unique<custom::QueryCheck>(Name, V, Context);
- });
- CustomCheckNames.insert(std::move(Name));
- }
-}
-
-} // namespace custom
-
-// Register the CustomTidyModule using this statically initialized variable.
-static ClangTidyModuleRegistry::Add<custom::CustomModule>
- X("custom-module", "Adds custom query lint checks.");
-
-// This anchor is used to force the linker to link in the generated object file
-// and thus register the AlteraModule.
-volatile int CustomModuleAnchorSource = 0; // NOLINT (misc-use-internal-linkage)
-
-} // namespace clang::tidy
diff --git a/clang-tools-extra/clang-tidy/custom/QueryCheck.cpp b/clang-tools-extra/clang-tidy/custom/QueryCheck.cpp
deleted file mode 100644
index f83c138fbfaf5..0000000000000
--- a/clang-tools-extra/clang-tidy/custom/QueryCheck.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-//===--- QueryCheck.cpp - clang-tidy --------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "QueryCheck.h"
-#include "../../clang-query/Query.h"
-#include "../../clang-query/QueryParser.h"
-#includ...
[truncated]
|
I have tried to add the missing dependency as follows: diff --git a/clang-tools-extra/clang-tidy/CMakeLists.txt b/clang-tools-extra/clang-tidy/CMakeLists.txt
index 153356245cfd..d3bbe0176688 100644
--- a/clang-tools-extra/clang-tidy/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/CMakeLists.txt
@@ -48,6 +48,13 @@ if(CLANG_TIDY_ENABLE_STATIC_ANALYZER)
)
endif()
+if(CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS)
+ clang_target_link_libraries(clangTidy
+ PRIVATE
+ clangTidyCustomModule
+ )
+endif()
+
# Checks.
# If you add a check, also add it to ClangTidyForceLinker.h in this directory.
add_subdirectory(android) This, however, makes the dependency graph cyclic. I get the following error message when running CMake:
I assume that the original author has only built their code using static libraries but the broken build bot and I use dynamic libraries. |
I'll also revert #159289, which adapts the bazel build files to the original change. I would be grateful if that PR were included into a possible new version of the reverted PR or re-applied after that new PR is merged. |
Could you share your system/compilers/cmake version for ease of reproduction? |
I am AFK now but I am pretty sure the only relevant flag is https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html, which I set to ON. I can provide more detail tomorrow if this isn't enough. |
This is how I configure CMake:
|
Reverts llvm#131804. This breaks a build bot; see discussion in the original PR. I could reproduce this problem locally. The problem is that the original PR makes use of `registerCustomChecks` in `ClangTidy.cpp` but does not add the new custom module to the dependencies of the target that builds that file. Adding the dependency would create a cyclic dependency, so the fix doesn't seem obvious. See details in the PR description.
Reverts #131804.
This breaks a build bot; see discussion in the original PR. I could reproduce this problem locally. The problem is that the original PR makes use of
registerCustomChecks
inClangTidy.cpp
but does not add the new custom module to the dependencies of the target that builds that file. Adding the dependency would create a cyclic dependency, so the fix doesn't seem obvious. See details in the PR description.