diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-06 23:25:15 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-06 23:25:15 +0000 |
| commit | 1e1f5abf777feade45af5864fd9f5100fcef9fd4 (patch) | |
| tree | 9bf622a3e39e9300c994bb9985571c152294a8c5 | |
| parent | cda2a8985cd44931e79e26f0037e718225c13404 (diff) | |
| download | bcm5719-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.h | 5 | ||||
| -rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp | 2 |
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())) |

