[PATCH] Clang-tidy: don't create ASTConsumers not needed for the set of checks we perform.
Alexander Kornienko
alexfh at google.com
Thu Feb 13 06:21:12 PST 2014
Removed {}
Hi djasper, klimek,
http://llvm-reviews.chandlerc.com/D2763
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D2763?vs=7053&id=7054#toc
Files:
clang-tidy/ClangTidy.cpp
Index: clang-tidy/ClangTidy.cpp
===================================================================
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -152,18 +152,24 @@
I != E; ++I)
(*I)->registerPPCallbacks(Compiler);
+ SmallVector<ASTConsumer *, 2> Consumers;
+ if (CheckFactories->begin() != CheckFactories->end())
+ Consumers.push_back(Finder.newASTConsumer());
+
AnalyzerOptionsRef Options = Compiler.getAnalyzerOpts();
Options->CheckersControlList = getCheckersControlList();
- Options->AnalysisStoreOpt = RegionStoreModel;
- Options->AnalysisDiagOpt = PD_NONE;
- Options->AnalyzeNestedBlocks = true;
- Options->eagerlyAssumeBinOpBifurcation = true;
- ento::AnalysisASTConsumer *AnalysisConsumer = ento::CreateAnalysisConsumer(
- Compiler.getPreprocessor(), Compiler.getFrontendOpts().OutputFile,
- Options, Compiler.getFrontendOpts().Plugins);
- AnalysisConsumer->AddDiagnosticConsumer(
- new AnalyzerDiagnosticConsumer(Context));
- ASTConsumer *Consumers[] = { Finder.newASTConsumer(), AnalysisConsumer };
+ if (!Options->CheckersControlList.empty()) {
+ Options->AnalysisStoreOpt = RegionStoreModel;
+ Options->AnalysisDiagOpt = PD_NONE;
+ Options->AnalyzeNestedBlocks = true;
+ Options->eagerlyAssumeBinOpBifurcation = true;
+ ento::AnalysisASTConsumer *AnalysisConsumer = ento::CreateAnalysisConsumer(
+ Compiler.getPreprocessor(), Compiler.getFrontendOpts().OutputFile,
+ Options, Compiler.getFrontendOpts().Plugins);
+ AnalysisConsumer->AddDiagnosticConsumer(
+ new AnalyzerDiagnosticConsumer(Context));
+ Consumers.push_back(AnalysisConsumer);
+ }
return new MultiplexConsumer(Consumers);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2763.2.patch
Type: text/x-patch
Size: 1714 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140213/8eaac3eb/attachment.bin>
More information about the cfe-commits
mailing list