[cfe-commits] r46086 - /cfe/trunk/Analysis/GRConstants.cpp
Ted Kremenek
kremenek at apple.com
Wed Jan 16 11:43:00 PST 2008
Author: kremenek
Date: Wed Jan 16 13:42:59 2008
New Revision: 46086
URL: http://llvm.org/viewvc/llvm-project?rev=46086&view=rev
Log:
Added support for assignments in GRConstants.
Modified:
cfe/trunk/Analysis/GRConstants.cpp
Modified: cfe/trunk/Analysis/GRConstants.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRConstants.cpp?rev=46086&r1=46085&r2=46086&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRConstants.cpp (original)
+++ cfe/trunk/Analysis/GRConstants.cpp Wed Jan 16 13:42:59 2008
@@ -192,6 +192,8 @@
StateTy RemoveGrandchildrenMappings(Stmt* S, StateTy M);
void AddBinding(Expr* E, ExprVariantTy V, bool isBlkLvl = false);
+ void AddBinding(Decl* D, ExprVariantTy V);
+
ExprVariantTy GetBinding(Expr* E);
void BlockStmt_VisitStmt(Stmt* S) { DoStmt(S); }
@@ -200,6 +202,7 @@
void VisitIntegerLiteral(IntegerLiteral* L);
void VisitBinAdd(BinaryOperator* O);
void VisitBinSub(BinaryOperator* O);
+ void VisitBinAssign(BinaryOperator* D);
};
} // end anonymous namespace
@@ -229,6 +232,13 @@
CurrentState = StateMgr.Add(CurrentState, DSPtr(E,isBlkLvl), V.getVal());
}
+void GRConstants::AddBinding(Decl* D, ExprVariantTy V) {
+ if (V)
+ CurrentState = StateMgr.Add(CurrentState, DSPtr(D), V.getVal());
+ else
+ CurrentState = StateMgr.Remove(CurrentState, DSPtr(D));
+}
+
void GRConstants::SwitchNodeSets() {
NodeSetTy* Tmp = OldNodes;
OldNodes = Nodes;
@@ -290,6 +300,20 @@
AddBinding(B, GetBinding(B->getLHS()) - GetBinding(B->getRHS()));
}
+
+static inline Expr* IgnoreParen(Expr* E) {
+ while (ParenExpr* P = dyn_cast<ParenExpr>(E))
+ E = P->getSubExpr();
+
+ return E;
+}
+
+
+void GRConstants::VisitBinAssign(BinaryOperator* B) {
+ if (DeclRefExpr* D = dyn_cast<DeclRefExpr>(IgnoreParen(B->getLHS())))
+ AddBinding(D->getDecl(), GetBinding(B->getRHS()));
+}
+
//===----------------------------------------------------------------------===//
// Driver.
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list