IntegerLiterals are no longer evaluated to create separate nodes; their

values are determined when evaluating the parent expression.

llvm-svn: 46096
This commit is contained in:
Ted Kremenek 2008-01-16 22:28:08 +00:00
parent 493444fc19
commit a14396d51d
1 changed files with 20 additions and 15 deletions

View File

@ -204,13 +204,19 @@ public:
void BlockStmt_VisitStmt(Stmt* S) { DoStmt(S); }
void VisitAssign(BinaryOperator* O);
void VisitIntegerLiteral(IntegerLiteral* L);
void VisitBinAdd(BinaryOperator* O);
void VisitBinSub(BinaryOperator* O);
void VisitBinAssign(BinaryOperator* D);
};
} // end anonymous namespace
static inline Expr* IgnoreParen(Expr* E) {
while (ParenExpr* P = dyn_cast<ParenExpr>(E))
E = P->getSubExpr();
return E;
}
void GRConstants::ProcessStmt(Stmt* S, NodeBuilder& builder) {
Builder = &builder;
Nodes->clear();
@ -224,9 +230,20 @@ void GRConstants::ProcessStmt(Stmt* S, NodeBuilder& builder) {
ExprVariantTy GRConstants::GetBinding(Expr* E) {
DSPtr P(NULL);
E = IgnoreParen(E);
if (DeclRefExpr* D = dyn_cast<DeclRefExpr>(E)) P = DSPtr(D->getDecl());
else P = DSPtr(E, getCFG().isBlkExpr(E));
switch (E->getStmtClass()) {
case Stmt::DeclRefExprClass:
P = DSPtr(cast<DeclRefExpr>(E)->getDecl());
break;
case Stmt::IntegerLiteralClass:
return cast<IntegerLiteral>(E)->getValue().getZExtValue();
default:
P = DSPtr(E, getCFG().isBlkExpr(E));
break;
}
StateTy::iterator I = CurrentState.find(P);
@ -297,10 +314,6 @@ void GRConstants::DoStmt(Stmt* S) {
SwitchNodeSets();
}
void GRConstants::VisitIntegerLiteral(IntegerLiteral* L) {
AddBinding(L, L->getValue().getZExtValue());
}
void GRConstants::VisitBinAdd(BinaryOperator* B) {
AddBinding(B, GetBinding(B->getLHS()) + GetBinding(B->getRHS()));
}
@ -310,14 +323,6 @@ void GRConstants::VisitBinSub(BinaryOperator* B) {
}
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()));