diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-06-22 20:57:11 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-06-22 20:57:11 +0000 |
commit | ac7610dad6653bad02dd42de198ca358b6fb1f1d (patch) | |
tree | 788285341527ca7351391c7d608b6386fbd98dd2 /lib/Parse/ParseExpr.cpp | |
parent | 05a5c45507243b88ee9e1b3f1ac2fb05b611d7d2 (diff) |
Rework the way we track which declarations are "used" during
compilation, and (hopefully) introduce RAII objects for changing the
"potentially evaluated" state at all of the necessary places within
Sema and Parser. Other changes:
- Set the unevaluated/potentially-evaluated context appropriately
during template instantiation.
- We now recognize three different states while parsing or
instantiating expressions: unevaluated, potentially evaluated, and
potentially potentially evaluated (for C++'s typeid).
- When we're in a potentially potentially-evaluated context, queue
up MarkDeclarationReferenced calls in a stack. For C++ typeid
expressions that are potentially evaluated, we will play back
these MarkDeclarationReferenced calls when we exit the
corresponding potentially potentially-evaluated context.
- Non-type template arguments are now parsed as constant
expressions, so they are not potentially-evaluated.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73899 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 4a07d05650..13b32acd5b 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -279,7 +279,8 @@ Parser::OwningExprResult Parser::ParseConstantExpression() { // C++ [basic.def.odr]p2: // An expression is potentially evaluated unless it appears where an // integral constant expression is required (see 5.19) [...]. - EnterUnevaluatedOperand Unevaluated(Actions); + EnterExpressionEvaluationContext Unevaluated(Actions, + Action::Unevaluated); OwningExprResult LHS(ParseCastExpression(false)); if (LHS.isInvalid()) return move(LHS); @@ -983,7 +984,8 @@ Parser::ParseExprAfterTypeofSizeofAlignof(const Token &OpTok, // // The GNU typeof and alignof extensions also behave as unevaluated // operands. - EnterUnevaluatedOperand Unevaluated(Actions); + EnterExpressionEvaluationContext Unevaluated(Actions, + Action::Unevaluated); Operand = ParseCastExpression(true/*isUnaryExpression*/); } else { // If it starts with a '(', we know that it is either a parenthesized @@ -999,7 +1001,8 @@ Parser::ParseExprAfterTypeofSizeofAlignof(const Token &OpTok, // // The GNU typeof and alignof extensions also behave as unevaluated // operands. - EnterUnevaluatedOperand Unevaluated(Actions); + EnterExpressionEvaluationContext Unevaluated(Actions, + Action::Unevaluated); Operand = ParseParenExpression(ExprType, true/*stopIfCastExpr*/, CastTy, RParenLoc); CastRange = SourceRange(LParenLoc, RParenLoc); |