Reduce -Wuninitialized time by 22% (on sqlite) by removing the recursive AST crawl.
This is accomplished by forcing the needed expressions for -Wuninitialized to always be CFGElements in the CFG.
This allows us to remove a fair amount of the code for -Wuninitialized.
Some fallout:
- AnalysisBasedWarnings.cpp now specifically toggles the CFGBuilder to create a CFG that is suitable for -Wuninitialized. This
is a layering violation, since the logic for -Wuninitialized is in libAnalysis. This can be fixed with the proper refactoring.
- Some of the source locations for -Wunreachable-code warnings have shifted. While not ideal, this is okay because that analysis
already needs some serious reworking.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135480 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index 7a14855..c0e2715 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -660,6 +660,20 @@
// explosion for destrutors that can result and the compile time hit.
AnalysisContext AC(D, 0, /*useUnoptimizedCFG=*/false, /*addehedges=*/false,
/*addImplicitDtors=*/true, /*addInitializers=*/true);
+
+ // Force that certain expressions appear as CFGElements in the CFG. This
+ // is used to speed up various analyses.
+ // FIXME: This isn't the right factoring. This is here for initial
+ // prototyping, but we need a way for analyses to say what expressions they
+ // expect to always be CFGElements and then fill in the BuildOptions
+ // appropriately. This is essentially a layering violation.
+ CFG::BuildOptions &buildOptions = AC.getCFGBuildOptions();
+ buildOptions.setAlwaysAdd(Stmt::BinaryOperatorClass);
+ buildOptions.setAlwaysAdd(Stmt::BlockExprClass);
+ buildOptions.setAlwaysAdd(Stmt::CStyleCastExprClass);
+ buildOptions.setAlwaysAdd(Stmt::DeclRefExprClass);
+ buildOptions.setAlwaysAdd(Stmt::ImplicitCastExprClass);
+ buildOptions.setAlwaysAdd(Stmt::UnaryOperatorClass);
// Emit delayed diagnostics.
if (!fscope->PossiblyUnreachableDiags.empty()) {