]> granicus.if.org Git - clang/commitdiff
Make IgnoreParenLValueCasts skip __extension__ nodes like IgnoreParens().
authorJohn McCall <rjmccall@apple.com>
Sat, 4 Dec 2010 08:24:19 +0000 (08:24 +0000)
committerJohn McCall <rjmccall@apple.com>
Sat, 4 Dec 2010 08:24:19 +0000 (08:24 +0000)
Abramo noticed this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120898 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Expr.cpp

index fbc5a67af1f097325047be8bc22d9e1018006eb5..eef45e388a9bcf395a807b9f4c195ee5e2fe889c 100644 (file)
@@ -1724,18 +1724,26 @@ Expr *Expr::IgnoreParenCasts() {
   }
 }
 
+/// IgnoreParenLValueCasts - Ignore parentheses and lvalue-to-rvalue
+/// casts.  This is intended purely as a temporary workaround for code
+/// that hasn't yet been rewritten to do the right thing about those
+/// casts, and may disappear along with the last internal use.
 Expr *Expr::IgnoreParenLValueCasts() {
   Expr *E = this;
-  while (E) {
+  while (true) {
     if (ParenExpr *P = dyn_cast<ParenExpr>(E)) {
       E = P->getSubExpr();
       continue;
-    }
-    if (CastExpr *P = dyn_cast<CastExpr>(E)) {
+    } else if (CastExpr *P = dyn_cast<CastExpr>(E)) {
       if (P->getCastKind() == CK_LValueToRValue) {
         E = P->getSubExpr();
         continue;
       }
+    } else if (UnaryOperator* P = dyn_cast<UnaryOperator>(E)) {
+      if (P->getOpcode() == UO_Extension) {
+        E = P->getSubExpr();
+        continue;
+      }
     }
     break;
   }