]> granicus.if.org Git - clang/commitdiff
DeadStoresChecker: when whitelisting dead initializations with constants, look
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 6 Dec 2011 23:25:15 +0000 (23:25 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 6 Dec 2011 23:25:15 +0000 (23:25 +0000)
for a foldable constant rather than an IR-level constant. This is still far too
liberal, but is a step in the right direction.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145990 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Expr.h
lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp

index ac4ffe0b438431f837137988909d2f1daa7bf83e..5162941f9b54c9605960ceb9fd108d37f6387e95 100644 (file)
@@ -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.
index 79c889d78a912ac8f37a9afa167c38e73ba8498c..448c75003925ddd02a72f2b53c0e7baaa942f963 100644 (file)
@@ -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()))