summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-04-12 00:28:12 +0000
committerTed Kremenek <kremenek@apple.com>2011-04-12 00:28:12 +0000
commite0d2b8c58c0449de8abe2618a0ae3f8c6f0d12f1 (patch)
treeb26b0e1e1e4edaada5f115718de7a970ebecb2a1
parent3ed03f18d1c4e8ee78e8568f9f0ee34d56d0aef8 (diff)
downloadbcm5719-llvm-e0d2b8c58c0449de8abe2618a0ae3f8c6f0d12f1.tar.gz
bcm5719-llvm-e0d2b8c58c0449de8abe2618a0ae3f8c6f0d12f1.zip
Teach GRState::getSValAsScalarOrLoc() about C++ references.
llvm-svn: 129329
-rw-r--r--clang/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h2
-rw-r--r--clang/test/Analysis/misc-ps-region-store.cpp10
2 files changed, 11 insertions, 1 deletions
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h
index c90625110c7..827373870ff 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h
@@ -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);
}
diff --git a/clang/test/Analysis/misc-ps-region-store.cpp b/clang/test/Analysis/misc-ps-region-store.cpp
index 94bfc278b54..e01c348e328 100644
--- a/clang/test/Analysis/misc-ps-region-store.cpp
+++ b/clang/test/Analysis/misc-ps-region-store.cpp
@@ -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;
+}
+
OpenPOWER on IntegriCloud