mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-15 04:00:56 +00:00
[clang-tidy][NFC] Add createChecks method that also checks for LangaugeOptions
This method won't add a check if it isn't supported in the Contexts current LanguageOptions. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D124320
This commit is contained in:
parent
76f90a9d71
commit
dd87aceb51
@ -402,11 +402,7 @@ ClangTidyASTConsumerFactory::createASTConsumer(
|
||||
Context.setCurrentBuildDirectory(WorkingDir.get());
|
||||
|
||||
std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
|
||||
CheckFactories->createChecks(&Context);
|
||||
|
||||
llvm::erase_if(Checks, [&](std::unique_ptr<ClangTidyCheck> &Check) {
|
||||
return !Check->isLanguageVersionSupported(Context.getLangOpts());
|
||||
});
|
||||
CheckFactories->createChecksForLanguage(&Context);
|
||||
|
||||
ast_matchers::MatchFinder::MatchFinderOptions FinderOptions;
|
||||
|
||||
|
@ -31,6 +31,21 @@ ClangTidyCheckFactories::createChecks(ClangTidyContext *Context) {
|
||||
return Checks;
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<ClangTidyCheck>>
|
||||
ClangTidyCheckFactories::createChecksForLanguage(ClangTidyContext *Context) {
|
||||
std::vector<std::unique_ptr<ClangTidyCheck>> Checks;
|
||||
const LangOptions &LO = Context->getLangOpts();
|
||||
for (const auto &Factory : Factories) {
|
||||
if (!Context->isCheckEnabled(Factory.getKey()))
|
||||
continue;
|
||||
std::unique_ptr<ClangTidyCheck> Check =
|
||||
Factory.getValue()(Factory.getKey(), Context);
|
||||
if (Check->isLanguageVersionSupported(LO))
|
||||
Checks.push_back(std::move(Check));
|
||||
}
|
||||
return Checks;
|
||||
}
|
||||
|
||||
ClangTidyOptions ClangTidyModule::getModuleOptions() {
|
||||
return ClangTidyOptions();
|
||||
}
|
||||
|
@ -67,6 +67,10 @@ public:
|
||||
std::vector<std::unique_ptr<ClangTidyCheck>>
|
||||
createChecks(ClangTidyContext *Context);
|
||||
|
||||
/// Create instances of checks that are enabled for the current Language.
|
||||
std::vector<std::unique_ptr<ClangTidyCheck>>
|
||||
createChecksForLanguage(ClangTidyContext *Context);
|
||||
|
||||
typedef llvm::StringMap<CheckFactory> FactoryMap;
|
||||
FactoryMap::const_iterator begin() const { return Factories.begin(); }
|
||||
FactoryMap::const_iterator end() const { return Factories.end(); }
|
||||
|
@ -480,10 +480,7 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
|
||||
CTContext->setASTContext(&Clang->getASTContext());
|
||||
CTContext->setCurrentFile(Filename);
|
||||
CTContext->setSelfContainedDiags(true);
|
||||
CTChecks = CTFactories.createChecks(CTContext.getPointer());
|
||||
llvm::erase_if(CTChecks, [&](const auto &Check) {
|
||||
return !Check->isLanguageVersionSupported(CTContext->getLangOpts());
|
||||
});
|
||||
CTChecks = CTFactories.createChecksForLanguage(CTContext.getPointer());
|
||||
Preprocessor *PP = &Clang->getPreprocessor();
|
||||
for (const auto &Check : CTChecks) {
|
||||
Check->registerPPCallbacks(Clang->getSourceManager(), PP, PP);
|
||||
|
Loading…
Reference in New Issue
Block a user