aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/AnalysisBasedWarnings.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-02-01 17:43:21 +0000
committerTed Kremenek <kremenek@apple.com>2011-02-01 17:43:21 +0000
commit63b54104700873dc4a5b95b3108052580b5370e7 (patch)
tree689f9327e87f5d3bb56a7b9a7a811408b5c47f38 /lib/Sema/AnalysisBasedWarnings.cpp
parent9fcbceed43e5610fdff43defe533934733453ae2 (diff)
Add temporary hack to -Wuninitialize to create a separate CFG (for C++ code) that doesn't include implicit dtors.
Implicit dtors confuse the ad hoc path-sensitivity of UninitializedValuesV2.cpp. This isn't the ideal solution, as it will directly impact compile time, but should significantly reduce the noise of -Wuninitialized on some code bases. This immediately "fixes" the false positive reported in PR 9063, although this isn't the right fix in the long run. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124667 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/AnalysisBasedWarnings.cpp')
-rw-r--r--lib/Sema/AnalysisBasedWarnings.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index 355e114746..3e6cd81b76 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -519,7 +519,24 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P,
if (Diags.getDiagnosticLevel(diag::warn_uninit_var, D->getLocStart())
!= Diagnostic::Ignored) {
- if (CFG *cfg = AC.getCFG()) {
+ ASTContext &ctx = D->getASTContext();
+ llvm::OwningPtr<CFG> tmpCFG;
+ bool useAlternateCFG = false;
+ if (ctx.getLangOptions().CPlusPlus) {
+ // Temporary workaround: implicit dtors in the CFG can confuse
+ // the path-sensitivity in the uninitialized values analysis.
+ // For now create (if necessary) a separate CFG without implicit dtors.
+ // FIXME: We should not need to do this, as it results in multiple
+ // CFGs getting constructed.
+ CFG::BuildOptions B;
+ B.AddEHEdges = false;
+ B.AddImplicitDtors = false;
+ B.AddInitializers = true;
+ tmpCFG.reset(CFG::buildCFG(D, AC.getBody(), &ctx, B));
+ useAlternateCFG = true;
+ }
+ CFG *cfg = useAlternateCFG ? tmpCFG.get() : AC.getCFG();
+ if (cfg) {
UninitValsDiagReporter reporter(S);
runUninitializedVariablesAnalysis(*cast<DeclContext>(D), *cfg, AC,
reporter);