]> granicus.if.org Git - clang/commitdiff
Removed FindDeclRef, and used Expr::IgnoreParens instead (code refactoring).
authorTed Kremenek <kremenek@apple.com>
Thu, 17 Jan 2008 17:50:49 +0000 (17:50 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 17 Jan 2008 17:50:49 +0000 (17:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46133 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/LiveVariables.cpp

index 5634c3c966a5ca104988ac8b81d87ea6671fba36..256b00d70d3dba0add4081fa0a942c2ed33d4155 100644 (file)
@@ -71,8 +71,6 @@ public:
   void VisitDeclStmt(DeclStmt* DS);
   void VisitUnaryOperator(UnaryOperator* U);
   void Visit(Stmt *S);
-  
-  DeclRefExpr* FindDeclRef(Stmt *S);
 };
       
 void TransferFuncs::Visit(Stmt *S) {
@@ -93,7 +91,7 @@ void TransferFuncs::VisitBinaryOperator(BinaryOperator* B) {
 }
 
 void TransferFuncs::VisitUnaryOperator(UnaryOperator* U) {
-  Stmt *S = U->getSubExpr();
+  Expr *E = U->getSubExpr();
   
   switch (U->getOpcode()) {
   case UnaryOperator::SizeOf: return;      
@@ -105,7 +103,7 @@ void TransferFuncs::VisitUnaryOperator(UnaryOperator* U) {
     // Walk through the subexpressions, blasting through ParenExprs
     // until we either find a DeclRefExpr or some non-DeclRefExpr
     // expression.
-    if (DeclRefExpr* DR = FindDeclRef(S)) {
+    if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(E->IgnoreParens())) {
       // Treat the --/++/& operator as a kill.
       LiveState(DR->getDecl(),AD) = Dead;
       if (AD.Observer) { AD.Observer->ObserverKill(DR); }
@@ -115,26 +113,15 @@ void TransferFuncs::VisitUnaryOperator(UnaryOperator* U) {
     // Fall-through.
   
   default:
-    return Visit(S);
+    return Visit(E);
   }
 }
-
-DeclRefExpr* TransferFuncs::FindDeclRef(Stmt *S) {
-  for (;;)
-    if (ParenExpr* P = dyn_cast<ParenExpr>(S)) {
-      S = P->getSubExpr(); continue;
-    }
-    else if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(S))
-      return DR;
-    else
-      return NULL;
-}
   
 void TransferFuncs::VisitAssign(BinaryOperator* B) {    
-  Stmt* LHS = B->getLHS();
+  Expr* LHS = B->getLHS();
 
   // Assigning to a variable?
-  if (DeclRefExpr* DR = FindDeclRef(LHS)) {
+  if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(LHS->IgnoreParens())) {
     LiveState(DR->getDecl(),AD) = Dead;
     if (AD.Observer) { AD.Observer->ObserverKill(DR); }