aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/Parser.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard@metafoo.co.uk>2020-03-27 17:08:26 -0700
committerRichard Smith <richard@metafoo.co.uk>2020-03-27 17:11:04 -0700
commitb3f6e3d6d64d77a9c840b8407b7e3c49b62b46dd (patch)
treee895b196f86f66c63f133bf648951ee78f75fec8 /clang/lib/Parse/Parser.cpp
parent569e4f9bc99a755cc30f0102b29b1eefd4fa33b4 (diff)
downloadllvm-b3f6e3d6d64d77a9c840b8407b7e3c49b62b46dd.zip
llvm-b3f6e3d6d64d77a9c840b8407b7e3c49b62b46dd.tar.gz
llvm-b3f6e3d6d64d77a9c840b8407b7e3c49b62b46dd.tar.bz2
Improve recovery from invalid template-ids.
Instead of bailing out of parsing when we encounter an invalid template-name or template arguments in a template-id, produce an annotation token describing the invalid construct. This avoids duplicate errors and generally allows us to recover better. In principle we should be able to extend this to store some kinds of invalid template-id in the AST for tooling use, but that isn't handled as part of this change.
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r--clang/lib/Parse/Parser.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 0a63ac2..47b5de3 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -1878,6 +1878,8 @@ bool Parser::TryAnnotateTypeOrScopeToken() {
Tok.getLocation());
} else if (Tok.is(tok::annot_template_id)) {
TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
+ if (TemplateId->isInvalid())
+ return true;
if (TemplateId->Kind != TNK_Type_template &&
TemplateId->Kind != TNK_Dependent_template_name &&
TemplateId->Kind != TNK_Undeclared_template) {