[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

llvm-svn: 291781
This commit is contained in:
Artem Dergachev 2017-01-12 18:00:03 +00:00
parent 18e165f50d
commit 1d4fb84d82
2 changed files with 3 additions and 8 deletions

View File

@ -253,12 +253,6 @@ void DereferenceChecker::checkBind(SVal L, SVal V, const Stmt *S,
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;

View File

@ -515,8 +515,9 @@ void ExprEngine::ProcessInitializer(const CFGInitializer Init,
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()) {