diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2013-07-20 00:40:58 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2013-07-20 00:40:58 +0000 |
commit | a5e660188a3c654cf0c88ed1093b28207e870b2b (patch) | |
tree | d6fbac0c3542c6428acd7c93ce9bfd7bb0bb1ff0 /lib/Sema/SemaPseudoObject.cpp | |
parent | 4384712b3a0aedd7c68d6abdb0407850f7b46c8b (diff) |
Make IgnoreParens() look through ChooseExprs.
This is the same way GenericSelectionExpr works, and it's generally a
more consistent approach.
A large part of this patch is devoted to caching the value of the condition
of a ChooseExpr; it's needed to avoid threading an ASTContext into
IgnoreParens().
Fixes <rdar://problem/14438917>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186738 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaPseudoObject.cpp')
-rw-r--r-- | lib/Sema/SemaPseudoObject.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp index a10612a8b0..106250fe0f 100644 --- a/lib/Sema/SemaPseudoObject.cpp +++ b/lib/Sema/SemaPseudoObject.cpp @@ -101,6 +101,25 @@ namespace { resultIndex); } + if (ChooseExpr *ce = dyn_cast<ChooseExpr>(e)) { + assert(!ce->isConditionDependent()); + + Expr *LHS = ce->getLHS(), *RHS = ce->getRHS(); + Expr *&rebuiltExpr = ce->isConditionTrue() ? LHS : RHS; + rebuiltExpr = rebuild(rebuiltExpr); + + return new (S.Context) ChooseExpr(ce->getBuiltinLoc(), + ce->getCond(), + LHS, RHS, + rebuiltExpr->getType(), + rebuiltExpr->getValueKind(), + rebuiltExpr->getObjectKind(), + ce->getRParenLoc(), + ce->isConditionTrue(), + rebuiltExpr->isTypeDependent(), + rebuiltExpr->isValueDependent()); + } + llvm_unreachable("bad expression to rebuild!"); } }; |