aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-11-12 00:03:40 +0000
committerDouglas Gregor <dgregor@apple.com>2009-11-12 00:03:40 +0000
commiteaf75f4e0f65444bb122ade7725a4a32badcbf77 (patch)
tree33c9e09d3fa75f710f853124532dab5a11530287 /lib
parentc7162937a4ccd044a0df67eed4a73ee828c49162 (diff)
Remove an overly-eager assertion when replacing tokens with an
annotation token, because some of the tokens we're annotating might not be in the set of cached tokens (we could have consumed them unconditionally). Also, move the tentative parsing from ParseTemplateTemplateArgument into the one caller that needs it, improving recovery. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86904 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Lex/PPCaching.cpp2
-rw-r--r--lib/Parse/ParseTemplate.cpp33
2 files changed, 17 insertions, 18 deletions
diff --git a/lib/Lex/PPCaching.cpp b/lib/Lex/PPCaching.cpp
index c3f0eeab58..7c3780ffc0 100644
--- a/lib/Lex/PPCaching.cpp
+++ b/lib/Lex/PPCaching.cpp
@@ -109,6 +109,4 @@ void Preprocessor::AnnotatePreviousCachedTokens(const Token &Tok) {
return;
}
}
-
- assert(0&&"Didn't find the first token represented by the annotation token!");
}
diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp
index b5063ee44b..16b1c80080 100644
--- a/lib/Parse/ParseTemplate.cpp
+++ b/lib/Parse/ParseTemplate.cpp
@@ -823,15 +823,13 @@ ParsedTemplateArgument Parser::ParseTemplateTemplateArgument() {
// A template-argument for a template template-parameter shall be the name
// of a class template or a template alias, expressed as id-expression.
//
- // We perform some tentative parsing at this point, to determine whether
- // we have an id-expression that refers to a class template or template
- // alias. The grammar we tentatively parse is:
+ // We parse an id-expression that refers to a class template or template
+ // alias. The grammar we parse is:
//
// nested-name-specifier[opt] template[opt] identifier
//
// followed by a token that terminates a template argument, such as ',',
// '>', or (in some cases) '>>'.
- TentativeParsingAction TPA(*this);
CXXScopeSpec SS; // nested-name-specifier, if present
ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0,
/*EnteringContext=*/false);
@@ -854,10 +852,8 @@ ParsedTemplateArgument Parser::ParseTemplateTemplateArgument() {
TemplateTy Template
= Actions.ActOnDependentTemplateName(TemplateLoc, SS, Name,
/*ObjectType=*/0);
- if (Template.get()) {
- TPA.Commit();
+ if (Template.get())
return ParsedTemplateArgument(SS, Template, Name.StartLocation);
- }
}
}
} else if (Tok.is(tok::identifier)) {
@@ -875,16 +871,12 @@ ParsedTemplateArgument Parser::ParseTemplateTemplateArgument() {
if (TNK == TNK_Dependent_template_name || TNK == TNK_Type_template) {
// We have an id-expression that refers to a class template or
// (C++0x) template alias.
- TPA.Commit();
return ParsedTemplateArgument(SS, Template, Name.StartLocation);
}
}
}
- // We don't have a template template argument; revert everything we have
- // tentatively parsed.
- TPA.Revert();
-
+ // We don't have a template template argument.
return ParsedTemplateArgument();
}
@@ -912,10 +904,19 @@ ParsedTemplateArgument Parser::ParseTemplateArgument() {
}
// Try to parse a template template argument.
- ParsedTemplateArgument TemplateTemplateArgument
- = ParseTemplateTemplateArgument();
- if (!TemplateTemplateArgument.isInvalid())
- return TemplateTemplateArgument;
+ {
+ TentativeParsingAction TPA(*this);
+
+ ParsedTemplateArgument TemplateTemplateArgument
+ = ParseTemplateTemplateArgument();
+ if (!TemplateTemplateArgument.isInvalid()) {
+ TPA.Commit();
+ return TemplateTemplateArgument;
+ }
+
+ // Revert this tentative parse to parse a non-type template argument.
+ TPA.Revert();
+ }
// Parse a non-type template argument.
SourceLocation Loc = Tok.getLocation();