[PATCH] D28602: [analyzer] Don't dereference the array bound to a reference.
This revision was automatically updated to reflect the committed changes. Closed by commit rL291781: [analyzer] Don't dereference the array value when binding it to a reference. (authored by dergachev). Changed prior to commit: https://reviews.llvm.org/D28602?vs=84097&id=84140#toc Repository: rL LLVM https://reviews.llvm.org/D28602 Files: cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -515,8 +515,9 @@ Init = ASE->getBase()->IgnoreImplicit(); SVal LValue = State->getSVal(Init, stackFrame); -if (Optional LValueLoc = LValue.getAs()) - InitVal = State->getSVal(*LValueLoc); +if (!Field->getType()->isReferenceType()) + if (Optional LValueLoc = LValue.getAs()) +InitVal = State->getSVal(*LValueLoc); // If we fail to get the value for some reason, use a symbolic value. if (InitVal.isUnknownOrUndef()) { Index: cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp === --- cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp @@ -253,12 +253,6 @@ 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()) -return; - ProgramStateRef State = C.getState(); ProgramStateRef StNonNull, StNull; Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -515,8 +515,9 @@ Init = ASE->getBase()->IgnoreImplicit(); SVal LValue = State->getSVal(Init, stackFrame); -if (Optional LValueLoc = LValue.getAs()) - InitVal = State->getSVal(*LValueLoc); +if (!Field->getType()->isReferenceType()) + if (Optional LValueLoc = LValue.getAs()) +InitVal = State->getSVal(*LValueLoc); // If we fail to get the value for some reason, use a symbolic value. if (InitVal.isUnknownOrUndef()) { Index: cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp === --- cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp @@ -253,12 +253,6 @@ 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()) -return; - ProgramStateRef State = C.getState(); ProgramStateRef StNonNull, StNull; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28602: [analyzer] Don't dereference the array bound to a reference.
NoQ created this revision. NoQ added reviewers: zaks.anna, dcoughlin, xazax.hun, a.sidorin. NoQ added a subscriber: cfe-commits. An attempt to fix pr31592 (https://llvm.org/bugs/show_bug.cgi?id=31592), more sensible than what i did in the hot pre-4.0-release fix in r291754 (http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20170109/182399.html), which this patch reverts. That's the place where we model member array initializers, and i'm adding a special case for reference-to-array initializers. https://reviews.llvm.org/D28602 Files: lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp Index: lib/StaticAnalyzer/Core/ExprEngine.cpp === --- lib/StaticAnalyzer/Core/ExprEngine.cpp +++ lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -515,8 +515,9 @@ Init = ASE->getBase()->IgnoreImplicit(); SVal LValue = State->getSVal(Init, stackFrame); -if (Optional LValueLoc = LValue.getAs()) - InitVal = State->getSVal(*LValueLoc); +if (!Field->getType()->isReferenceType()) + if (Optional LValueLoc = LValue.getAs()) +InitVal = State->getSVal(*LValueLoc); // If we fail to get the value for some reason, use a symbolic value. if (InitVal.isUnknownOrUndef()) { Index: lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp === --- lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp +++ lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp @@ -253,12 +253,6 @@ 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()) -return; - ProgramStateRef State = C.getState(); ProgramStateRef StNonNull, StNull; Index: lib/StaticAnalyzer/Core/ExprEngine.cpp === --- lib/StaticAnalyzer/Core/ExprEngine.cpp +++ lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -515,8 +515,9 @@ Init = ASE->getBase()->IgnoreImplicit(); SVal LValue = State->getSVal(Init, stackFrame); -if (Optional LValueLoc = LValue.getAs()) - InitVal = State->getSVal(*LValueLoc); +if (!Field->getType()->isReferenceType()) + if (Optional LValueLoc = LValue.getAs()) +InitVal = State->getSVal(*LValueLoc); // If we fail to get the value for some reason, use a symbolic value. if (InitVal.isUnknownOrUndef()) { Index: lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp === --- lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp +++ lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp @@ -253,12 +253,6 @@ 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()) -return; - ProgramStateRef State = C.getState(); ProgramStateRef StNonNull, StNull; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits