[cfe-commits] r129329 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h test/Analysis/misc-ps-region-store.cpp

Ted Kremenek kremenek at apple.com
Mon Apr 11 17:28:13 PDT 2011


Author: kremenek
Date: Mon Apr 11 19:28:12 2011
New Revision: 129329

URL: http://llvm.org/viewvc/llvm-project?rev=129329&view=rev
Log:
Teach GRState::getSValAsScalarOrLoc() about C++ references.

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

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h?rev=129329&r1=129328&r2=129329&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h Mon Apr 11 19:28:12 2011
@@ -690,7 +690,7 @@
 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);
   }
 

Modified: cfe/trunk/test/Analysis/misc-ps-region-store.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps-region-store.cpp?rev=129329&r1=129328&r2=129329&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-region-store.cpp (original)
+++ cfe/trunk/test/Analysis/misc-ps-region-store.cpp Mon Apr 11 19:28:12 2011
@@ -336,3 +336,13 @@
     *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;
+}
+





More information about the cfe-commits mailing list