summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-06-22 20:57:11 +0000
committerDouglas Gregor <dgregor@apple.com>2009-06-22 20:57:11 +0000
commit0b6a6242ede6620b90c8b1d5db1c85e5cb29d91c (patch)
treefdae8a15a6b8ae4c84458c65df95cd3cc651270c /clang/lib/Parse
parent8cbbc7944d30c38c2f8e235ebbcfb3fba9427f6a (diff)
downloadbcm5719-llvm-0b6a6242ede6620b90c8b1d5db1c85e5cb29d91c.tar.gz
bcm5719-llvm-0b6a6242ede6620b90c8b1d5db1c85e5cb29d91c.zip
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. llvm-svn: 73899
Diffstat (limited to 'clang/lib/Parse')
-rw-r--r--clang/lib/Parse/ParseExpr.cpp9
-rw-r--r--clang/lib/Parse/ParseExprCXX.cpp7
-rw-r--r--clang/lib/Parse/ParseTemplate.cpp4
3 files changed, 11 insertions, 9 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 4a07d05650b..13b32acd5b2 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/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);
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index 87aa5dc6711..2be44a4e77a 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -384,10 +384,9 @@ Parser::OwningExprResult Parser::ParseCXXTypeid() {
//
// Note that we can't tell whether the expression is an lvalue of a
// polymorphic class type until after we've parsed the expression, so
- // we treat the expression as an unevaluated operand and let semantic
- // analysis cope with case where the expression is not an unevaluated
- // operand.
- EnterUnevaluatedOperand Unevaluated(Actions);
+ // we the expression is potentially potentially evaluated.
+ EnterExpressionEvaluationContext Unevaluated(Actions,
+ Action::PotentiallyPotentiallyEvaluated);
Result = ParseExpression();
// Match the ')'.
diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp
index a9f75d8be17..eabe10f1450 100644
--- a/clang/lib/Parse/ParseTemplate.cpp
+++ b/clang/lib/Parse/ParseTemplate.cpp
@@ -750,7 +750,7 @@ void Parser::AnnotateTemplateIdTokenAsType(const CXXScopeSpec *SS) {
/// ParseTemplateArgument - Parse a C++ template argument (C++ [temp.names]).
///
/// template-argument: [C++ 14.2]
-/// assignment-expression
+/// constant-expression
/// type-id
/// id-expression
void *Parser::ParseTemplateArgument(bool &ArgIsType) {
@@ -768,7 +768,7 @@ void *Parser::ParseTemplateArgument(bool &ArgIsType) {
return TypeArg.get();
}
- OwningExprResult ExprArg = ParseAssignmentExpression();
+ OwningExprResult ExprArg = ParseConstantExpression();
if (ExprArg.isInvalid() || !ExprArg.get())
return 0;
OpenPOWER on IntegriCloud