]> granicus.if.org Git - clang/commitdiff
[analyzer] Don't dereference the array value when binding it to a reference.
authorArtem Dergachev <artem.dergachev@gmail.com>
Thu, 12 Jan 2017 18:00:03 +0000 (18:00 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Thu, 12 Jan 2017 18:00:03 +0000 (18:00 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291781 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
lib/StaticAnalyzer/Core/ExprEngine.cpp

index a98d379bb84ed86fa59e1d74175afe9c54761494..152b937bb03f4061f578f5a6b2b544f991adab85 100644 (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;
index 0dd8469f2783de29d3b0cc9b5524878bc1256d41..d563f8e9eac02898a1ec30f6b1b057c2f9e7151a 100644 (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()) {