[cfe-commits] r46096 - /cfe/trunk/Analysis/GRConstants.cpp

Chris Lattner clattner at apple.com
Wed Jan 16 16:32:59 PST 2008


On Jan 16, 2008, at 2:28 PM, Ted Kremenek wrote:
> Modified: cfe/trunk/Analysis/GRConstants.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRConstants.cpp?rev=46096&r1=46095&r2=46096&view=diff
>
> +static inline Expr* IgnoreParen(Expr* E) {
> +  while (ParenExpr* P = dyn_cast<ParenExpr>(E))
> +    E = P->getSubExpr();
> +
> +  return E;
> +}

How about making this be a method on Expr?

E = E->IgnoreParens(); ?

-Chris

>
> +
> void GRConstants::ProcessStmt(Stmt* S, NodeBuilder& builder) {
>   Builder = &builder;
>   Nodes->clear();
> @@ -224,9 +230,20 @@
>
> 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 @@
>   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 @@
> }
>
>
> -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()));
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list