diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2011-04-15 00:35:48 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2011-04-15 00:35:48 +0000 |
commit | f111d935722ed488144600cea5ed03a6b5069e8f (patch) | |
tree | b9890fee5ac2d94380e448777c0a49223fbc578d /lib/Sema/SemaChecking.cpp | |
parent | 7e7fbd05a5dfdb0addfc8b5af2fcbed8c7b5fb87 (diff) |
C1X: implement generic selections
As an extension, generic selection support has been added for all
supported languages. The syntax is the same as for C1X.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129554 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 9372a16bf1..cc4a089bf5 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -905,6 +905,8 @@ bool Sema::SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall, if (E->isTypeDependent() || E->isValueDependent()) return false; + E = E->IgnoreParens(); + switch (E->getStmtClass()) { case Stmt::BinaryConditionalOperatorClass: case Stmt::ConditionalOperatorClass: { @@ -927,11 +929,6 @@ bool Sema::SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall, goto tryAgain; } - case Stmt::ParenExprClass: { - E = cast<ParenExpr>(E)->getSubExpr(); - goto tryAgain; - } - case Stmt::OpaqueValueExprClass: if (const Expr *src = cast<OpaqueValueExpr>(E)->getSourceExpr()) { E = src; @@ -1897,14 +1894,12 @@ static Expr *EvalAddr(Expr *E, llvm::SmallVectorImpl<DeclRefExpr *> &refVars) { E->getType()->isObjCQualifiedIdType()) && "EvalAddr only works on pointers"); + E = E->IgnoreParens(); + // Our "symbolic interpreter" is just a dispatch off the currently // viewed AST node. We then recursively traverse the AST by calling // EvalAddr and EvalVal appropriately. switch (E->getStmtClass()) { - case Stmt::ParenExprClass: - // Ignore parentheses. - return EvalAddr(cast<ParenExpr>(E)->getSubExpr(), refVars); - case Stmt::DeclRefExprClass: { DeclRefExpr *DR = cast<DeclRefExpr>(E); @@ -2034,6 +2029,8 @@ do { // Our "symbolic interpreter" is just a dispatch off the currently // viewed AST node. We then recursively traverse the AST by calling // EvalAddr and EvalVal appropriately. + + E = E->IgnoreParens(); switch (E->getStmtClass()) { case Stmt::ImplicitCastExprClass: { ImplicitCastExpr *IE = cast<ImplicitCastExpr>(E); @@ -2067,12 +2064,6 @@ do { return NULL; } - case Stmt::ParenExprClass: { - // Ignore parentheses. - E = cast<ParenExpr>(E)->getSubExpr(); - continue; - } - case Stmt::UnaryOperatorClass: { // The only unary operator that make sense to handle here // is Deref. All others don't resolve to a "name." This includes @@ -3272,11 +3263,9 @@ static void CheckArrayAccess_Check(Sema &S, } void Sema::CheckArrayAccess(const Expr *expr) { - while (true) + while (true) { + expr = expr->IgnoreParens(); switch (expr->getStmtClass()) { - case Stmt::ParenExprClass: - expr = cast<ParenExpr>(expr)->getSubExpr(); - continue; case Stmt::ArraySubscriptExprClass: CheckArrayAccess_Check(*this, cast<ArraySubscriptExpr>(expr)); return; @@ -3291,4 +3280,5 @@ void Sema::CheckArrayAccess(const Expr *expr) { default: return; } + } } |