[PATCH] Bugfix in template instantiation.

David Majnemer david.majnemer at gmail.com
Tue Oct 14 01:59:57 PDT 2014


================
Comment at: lib/Sema/SemaCXXScopeSpec.cpp:144
@@ -143,4 +143,3 @@
   case NestedNameSpecifier::TypeSpecWithTemplate: {
-    const TagType *Tag = NNS->getAsType()->getAs<TagType>();
-    assert(Tag && "Non-tag type in nested-name-specifier");
-    return Tag->getDecl();
+    if (const TagType *Tag = NNS->getAsType()->getAs<TagType>())
+      return Tag->getDecl();
----------------
No need to repeat TagType, we know what it is from the right hand side.  I'd recommend:
  if (const auto *Tag = NNS->getAsType()->getAs<TagType>())

================
Comment at: lib/Sema/SemaExprMember.cpp:599
@@ -598,2 +598,3 @@
     // nested-name-specifier.
-    DC = SemaRef.computeDeclContext(SS, false);
+    if ((DC = SemaRef.computeDeclContext(SS, false)) == nullptr) {
+      SemaRef.Diag(SS.getBeginLoc(), diag::err_expected_class_or_namespace)
----------------
This is unusual in clang's codebase, I'd recommend:
  DC = SemaRef.computeDeclContext(SS, /*EnteringContext=*/false);
  if (!DC) {

http://reviews.llvm.org/D5769






More information about the cfe-commits mailing list