summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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