aboutsummaryrefslogtreecommitdiff
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
commit235c02f79e0ece9463490aa87eaaa02bad300dac (patch)
treebeb23e7d89054c1383ad930daf616cc038b034cf
parent9fec9b1fbd32e71ce8acb701165fd6649b3d8285 (diff)
Teach GRState::getSValAsScalarOrLoc() about C++ references.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129329 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h2
-rw-r--r--test/Analysis/misc-ps-region-store.cpp10
2 files changed, 11 insertions, 1 deletions
diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h b/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h
index c90625110c..827373870f 100644
--- a/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h
+++ b/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/test/Analysis/misc-ps-region-store.cpp b/test/Analysis/misc-ps-region-store.cpp
index 94bfc278b5..e01c348e32 100644
--- a/test/Analysis/misc-ps-region-store.cpp
+++ b/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;
+}
+