From 235c02f79e0ece9463490aa87eaaa02bad300dac Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 12 Apr 2011 00:28:12 +0000 Subject: [PATCH] Teach GRState::getSValAsScalarOrLoc() about C++ references. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129329 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../clang/StaticAnalyzer/Core/PathSensitive/GRState.h | 2 +- test/Analysis/misc-ps-region-store.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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(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; +} + -- 2.40.0