r291781 - [analyzer] Don't dereference the array value when binding it to a reference.
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 12 10:00:03 PST 2017
Author: dergachev
Date: Thu Jan 12 12:00:03 2017
New Revision: 291781
URL: http://llvm.org/viewvc/llvm-project?rev=291781&view=rev
Log:
[analyzer] Don't dereference the array value when binding it to a reference.
This replaces the hack in r291754, which was fixing pr31592, which was
caused by r291754, with a more appropriate solution.
rdar://problem/28832541
Differential revision: https://reviews.llvm.org/D28602
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp?rev=291781&r1=291780&r2=291781&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp Thu Jan 12 12:00:03 2017
@@ -253,12 +253,6 @@ void DereferenceChecker::checkBind(SVal
if (!TVR->getValueType()->isReferenceType())
return;
- // FIXME: This is a hotfix for https://llvm.org/bugs/show_bug.cgi?id=31592
- // A proper fix is very much necessary. Otherwise we would never normally bind
- // a NonLoc to a reference.
- if (V.getAs<NonLoc>())
- return;
-
ProgramStateRef State = C.getState();
ProgramStateRef StNonNull, StNull;
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=291781&r1=291780&r2=291781&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Thu Jan 12 12:00:03 2017
@@ -515,8 +515,9 @@ void ExprEngine::ProcessInitializer(cons
Init = ASE->getBase()->IgnoreImplicit();
SVal LValue = State->getSVal(Init, stackFrame);
- if (Optional<Loc> LValueLoc = LValue.getAs<Loc>())
- InitVal = State->getSVal(*LValueLoc);
+ if (!Field->getType()->isReferenceType())
+ if (Optional<Loc> LValueLoc = LValue.getAs<Loc>())
+ InitVal = State->getSVal(*LValueLoc);
// If we fail to get the value for some reason, use a symbolic value.
if (InitVal.isUnknownOrUndef()) {
More information about the cfe-commits
mailing list