summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2011-12-06 23:25:15 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2011-12-06 23:25:15 +0000
commit1e1f5abf777feade45af5864fd9f5100fcef9fd4 (patch)
tree9bf622a3e39e9300c994bb9985571c152294a8c5
parentcda2a8985cd44931e79e26f0037e718225c13404 (diff)
downloadbcm5719-llvm-1e1f5abf777feade45af5864fd9f5100fcef9fd4.tar.gz
bcm5719-llvm-1e1f5abf777feade45af5864fd9f5100fcef9fd4.zip
DeadStoresChecker: when whitelisting dead initializations with constants, look
for a foldable constant rather than an IR-level constant. This is still far too liberal, but is a step in the right direction. llvm-svn: 145990
-rw-r--r--clang/include/clang/AST/Expr.h5
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp2
2 files changed, 4 insertions, 3 deletions
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index ac4ffe0b438..5162941f9b5 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -421,8 +421,9 @@ public:
llvm::APSInt X;
return isIntegerConstantExpr(X, Ctx, Loc);
}
- /// isConstantInitializer - Returns true if this expression is a constant
- /// initializer, which can be emitted at compile-time.
+
+ /// isConstantInitializer - Returns true if this expression can be emitted to
+ /// IR as a constant, and thus can be used as a constant initializer in C.
bool isConstantInitializer(ASTContext &Ctx, bool ForRef) const;
/// EvalStatus is a struct with detailed info about an evaluation in progress.
diff --git a/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
index 79c889d78a9..448c7500392 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -274,7 +274,7 @@ public:
// If x is EVER assigned a new value later, don't issue
// a warning. This is because such initialization can be
// due to defensive programming.
- if (E->isConstantInitializer(Ctx, false))
+ if (E->isEvaluatable(Ctx))
return;
if (DeclRefExpr *DRE=dyn_cast<DeclRefExpr>(E->IgnoreParenCasts()))
OpenPOWER on IntegriCloud