[PATCH] D64644: Fixes a clang frontend assertion failure (bug 35682)

Mark de Wever via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 12 09:44:01 PDT 2019


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);
 }
 
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64644.209516.patch
Type: text/x-patch
Size: 1027 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190712/9ac41d9e/attachment-0001.bin>


More information about the cfe-commits mailing list