]> granicus.if.org Git - clang/commitdiff
Teach GRState::getSValAsScalarOrLoc() about C++ references.
authorTed Kremenek <kremenek@apple.com>
Tue, 12 Apr 2011 00:28:12 +0000 (00:28 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 12 Apr 2011 00:28:12 +0000 (00:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129329 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h
test/Analysis/misc-ps-region-store.cpp

index c90625110c7e8c23ea074f4c33dc3acb1fac339e..827373870fff26c44b771d9a7d16a819c8e7eac5 100644 (file)
@@ -690,7 +690,7 @@ inline SVal GRState::getSVal(const Stmt* Ex) const {
 inline SVal GRState::getSValAsScalarOrLoc(const Stmt *S) const {
   if (const Expr *Ex = dyn_cast<Expr>(S)) {
     QualType T = Ex->getType();
-    if (Loc::isLocType(T) || T->isIntegerType())
+    if (Ex->isLValue() || Loc::isLocType(T) || T->isIntegerType())
       return getSVal(S);
   }
 
index 94bfc278b545a90cd93669f83ce089413d89b521..e01c348e3282053903cb6e46e7678995da158b01 100644 (file)
@@ -336,3 +336,13 @@ void RDar9267815::test2() {
     *p = 0xDEADBEEF; // expected-warning {{null}}
 }
 
+// Test reference parameters.
+void test_ref_double_aux(double &Value);
+float test_ref_double() {
+  double dVal;
+  test_ref_double_aux(dVal);
+  // This previously warned because 'dVal' was thought to be uninitialized.
+  float Val = (float)dVal; // no-warning
+  return Val;
+}
+