Mordante created this revision.
Mordante added a reviewer: rsmith.
Mordante added a project: clang.
This fixes bug 35682. I was not able to easily generate a test-case so I
haven't been able to add unit tests. I'll update the bug in bugzilla with some
additional information.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D64644
Files:
clang/lib/Sema/SemaTemplate.cpp
Index: clang/lib/Sema/SemaTemplate.cpp
===================================================================
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -718,9 +718,15 @@
SourceLocation TemplateKWLoc,
const DeclarationNameInfo &NameInfo,
const TemplateArgumentListInfo *TemplateArgs) {
- return DependentScopeDeclRefExpr::Create(
- Context, SS.getWithLocInContext(Context), TemplateKWLoc, NameInfo,
- TemplateArgs);
+ // DependentScopeDeclRefExpr::Create requires a valid QualifierLoc
+ // See https://bugs.llvm.org/show_bug.cgi?id=35682
+ NestedNameSpecifierLoc QualifierLoc = SS.getWithLocInContext(Context);
+ if (!QualifierLoc)
+ return ExprError();
+ else
+ return DependentScopeDeclRefExpr::Create(Context, std::move(QualifierLoc),
+ TemplateKWLoc, NameInfo,
+ TemplateArgs);
}
Index: clang/lib/Sema/SemaTemplate.cpp
===================================================================
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -718,9 +718,15 @@
SourceLocation TemplateKWLoc,
const DeclarationNameInfo &NameInfo,
const TemplateArgumentListInfo *TemplateArgs) {
- return DependentScopeDeclRefExpr::Create(
- Context, SS.getWithLocInContext(Context), TemplateKWLoc, NameInfo,
- TemplateArgs);
+ // DependentScopeDeclRefExpr::Create requires a valid QualifierLoc
+ // See https://bugs.llvm.org/show_bug.cgi?id=35682
+ NestedNameSpecifierLoc QualifierLoc = SS.getWithLocInContext(Context);
+ if (!QualifierLoc)
+ return ExprError();
+ else
+ return DependentScopeDeclRefExpr::Create(Context, std::move(QualifierLoc),
+ TemplateKWLoc, NameInfo,
+ TemplateArgs);
}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits