From: Ted Kremenek Date: Sat, 5 Nov 2011 07:34:28 +0000 (+0000) Subject: Tweak LookThroughStmt() in LiveVariables to properly look through alternativing Paren... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6bbecd5e96c2bfe6dcb935a3ca0deb06782a5b14;p=clang Tweak LookThroughStmt() in LiveVariables to properly look through alternativing ParenExprs and OpaqueValueExprs. Thanks to Anna and Argiris for iterating on this function. My original patch embarssingly didn't even pass the Clang tests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143797 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp index 69b0933042..cd6f09f2a7 100644 --- a/lib/Analysis/LiveVariables.cpp +++ b/lib/Analysis/LiveVariables.cpp @@ -232,10 +232,15 @@ static const VariableArrayType *FindVA(QualType Ty) { } static const Stmt *LookThroughStmt(const Stmt *S) { - if (const OpaqueValueExpr *OVE = dyn_cast(S)) - return OVE->getSourceExpr()->IgnoreParens(); - if (const Expr *E = dyn_cast(S)) - return E->IgnoreParens(); + while (S) { + if (const Expr *Ex = dyn_cast(S)) + S = Ex->IgnoreParens(); + if (const OpaqueValueExpr *OVE = dyn_cast(S)) { + S = OVE->getSourceExpr(); + continue; + } + break; + } return S; }