diff options
author | Ted Kremenek <kremenek@apple.com> | 2013-03-29 00:09:22 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2013-03-29 00:09:22 +0000 |
commit | 233c1b0c77cce6509aa8bd9e87ff672b8a5c5217 (patch) | |
tree | 789ed8cddb826b9e6476af7174a36ca063838c74 | |
parent | 311246c6d51a99439172ddf2cea28be4f53df4dd (diff) | |
download | bcm5719-llvm-233c1b0c77cce6509aa8bd9e87ff672b8a5c5217.tar.gz bcm5719-llvm-233c1b0c77cce6509aa8bd9e87ff672b8a5c5217.zip |
Add configuration plumbing to enable static initializer branching in the CFG for the analyzer.
This setting still isn't enabled yet in the analyzer. This is
just prep work.
llvm-svn: 178317
5 files changed, 16 insertions, 3 deletions
diff --git a/clang/include/clang/Analysis/AnalysisContext.h b/clang/include/clang/Analysis/AnalysisContext.h index 880176ce517..59140d4736d 100644 --- a/clang/include/clang/Analysis/AnalysisContext.h +++ b/clang/include/clang/Analysis/AnalysisContext.h @@ -410,7 +410,8 @@ public: bool addImplicitDtors = false, bool addInitializers = false, bool addTemporaryDtors = false, - bool synthesizeBodies = false); + bool synthesizeBodies = false, + bool addStaticInitBranches = false); ~AnalysisDeclContextManager(); diff --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h index eb58803065f..5e29201447a 100644 --- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h @@ -313,6 +313,10 @@ public: /// values "true" and "false". bool shouldPrunePaths(); + /// Returns true if 'static' initializers should be in conditional logic + /// in the CFG. + bool shouldConditionalizeStaticInitializers(); + // Returns the size of the functions (in basic blocks), which should be // considered to be small enough to always inline. // diff --git a/clang/lib/Analysis/AnalysisDeclContext.cpp b/clang/lib/Analysis/AnalysisDeclContext.cpp index 36d1dba5e3b..ebbafbf4a9a 100644 --- a/clang/lib/Analysis/AnalysisDeclContext.cpp +++ b/clang/lib/Analysis/AnalysisDeclContext.cpp @@ -66,13 +66,15 @@ AnalysisDeclContextManager::AnalysisDeclContextManager(bool useUnoptimizedCFG, bool addImplicitDtors, bool addInitializers, bool addTemporaryDtors, - bool synthesizeBodies) + bool synthesizeBodies, + bool addStaticInitBranch) : SynthesizeBodies(synthesizeBodies) { cfgBuildOptions.PruneTriviallyFalseEdges = !useUnoptimizedCFG; cfgBuildOptions.AddImplicitDtors = addImplicitDtors; cfgBuildOptions.AddInitializers = addInitializers; cfgBuildOptions.AddTemporaryDtors = addTemporaryDtors; + cfgBuildOptions.AddStaticInitBranches = addStaticInitBranch; } void AnalysisDeclContextManager::clear() { diff --git a/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp b/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp index 011d4c09a23..747b73c4164 100644 --- a/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp @@ -25,7 +25,8 @@ AnalysisManager::AnalysisManager(ASTContext &ctx, DiagnosticsEngine &diags, /*AddImplicitDtors=*/true, /*AddInitializers=*/true, Options.includeTemporaryDtorsInCFG(), - Options.shouldSynthesizeBodies()), + Options.shouldSynthesizeBodies(), + Options.shouldConditionalizeStaticInitializers()), Ctx(ctx), Diags(diags), LangOpts(lang), diff --git a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp index dca68f71ab5..1326d0d01b0 100644 --- a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp +++ b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp @@ -236,3 +236,8 @@ bool AnalyzerOptions::shouldSynthesizeBodies() { bool AnalyzerOptions::shouldPrunePaths() { return getBooleanOption("prune-paths", true); } + +bool AnalyzerOptions::shouldConditionalizeStaticInitializers() { + return getBooleanOption("conditional-static-initializers", false); +} + |