Start migration of static analyzer to using the
implicit lvalue-to-rvalue casts that John McCall
recently introduced. This causes a whole bunch
of logic in the analyzer for handling lvalues
to vanish. It does, however, raise a few issues
in the analyzer w.r.t to modeling various constructs
(e.g., field accesses to compound literals).
The .c/.m analysis test cases that fail are
due to a missing lvalue-to-rvalue cast that
will get introduced into the AST. The .cpp
failures were more than I could investigate in
one go, and the patch was already getting huge.
I have XFAILED some of these tests, and they
should obviously be further investigated.
Some highlights of this patch include:
- CFG no longer requires an lvalue bit for
CFGElements
- StackFrameContext doesn't need an 'asLValue'
flag
- The "VisitLValue" path from GRExprEngine has
been eliminated.
Besides the test case failures (XFAILed), there
are surely other bugs that are fallout from
this change.
llvm-svn: 121960
diff --git a/clang/lib/Checker/GRCXXExprEngine.cpp b/clang/lib/Checker/GRCXXExprEngine.cpp
index 9fb6699..0e2ac04 100644
--- a/clang/lib/Checker/GRCXXExprEngine.cpp
+++ b/clang/lib/Checker/GRCXXExprEngine.cpp
@@ -59,11 +59,7 @@
: false;
}
- if (VisitAsLvalue)
- VisitLValue(*Item.I, Item.N, Tmp);
- else
- Visit(*Item.I, Item.N, Tmp);
-
+ Visit(*Item.I, Item.N, Tmp);
++(Item.I);
for (ExplodedNodeSet::iterator NI=Tmp.begin(), NE=Tmp.end(); NI != NE; ++NI)
WorkList.push_back(CallExprWLItem(Item.I, *NI));
@@ -106,7 +102,7 @@
void GRExprEngine::VisitCXXConstructExpr(const CXXConstructExpr *E,
const MemRegion *Dest,
ExplodedNode *Pred,
- ExplodedNodeSet &Dst, bool asLValue) {
+ ExplodedNodeSet &Dst) {
if (!Dest)
Dest = svalBuilder.getRegionManager().getCXXTempObjectRegion(E,
Pred->getLocationContext());
@@ -131,7 +127,8 @@
// The callee stack frame context used to create the 'this' parameter region.
const StackFrameContext *SFC = AMgr.getStackFrame(CD,
Pred->getLocationContext(),
- E, asLValue, Builder->getBlock(), Builder->getIndex());
+ E, Builder->getBlock(),
+ Builder->getIndex());
const CXXThisRegion *ThisR =getCXXThisRegion(E->getConstructor()->getParent(),
SFC);
@@ -159,7 +156,7 @@
// Create the context for 'this' region.
const StackFrameContext *SFC = AMgr.getStackFrame(DD,
Pred->getLocationContext(),
- S, false, Builder->getBlock(),
+ S, Builder->getBlock(),
Builder->getIndex());
const CXXThisRegion *ThisR = getCXXThisRegion(DD->getParent(), SFC);
@@ -193,10 +190,7 @@
Expr *ObjArgExpr = ME->getBase();
for (ExplodedNodeSet::iterator I = argsEvaluated.begin(),
E = argsEvaluated.end(); I != E; ++I) {
- if (ME->isArrow())
Visit(ObjArgExpr, *I, AllargsEvaluated);
- else
- VisitLValue(ObjArgExpr, *I, AllargsEvaluated);
}
// Now evaluate the call itself.
@@ -211,7 +205,7 @@
const CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(C->getCalleeDecl());
if (!MD) {
// If the operator doesn't represent a method call treat as regural call.
- VisitCall(C, Pred, C->arg_begin(), C->arg_end(), Dst, false);
+ VisitCall(C, Pred, C->arg_begin(), C->arg_end(), Dst);
return;
}
@@ -245,7 +239,7 @@
const StackFrameContext *SFC = AMgr.getStackFrame(MD,
Pred->getLocationContext(),
- MCE, false,
+ MCE,
Builder->getBlock(),
Builder->getIndex());
const CXXThisRegion *ThisR = getCXXThisRegion(MD, SFC);