[PATCH] D17143: When trying to get destructor name, make we have a complete type before calling LookupQualifiedName(), which will assert otherwise.

don hinton via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 11 08:18:07 PST 2016


hintonda created this revision.
hintonda added reviewers: doug.gregor, majnemer.
hintonda added a subscriber: cfe-commits.

Fix crash from PR25156 where getDestructorName() calls LookupQualifiedName() on incomplete type.

http://reviews.llvm.org/D17143

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/pr25156-crash-on-invalid.cpp

Index: test/SemaCXX/pr25156-crash-on-invalid.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/pr25156-crash-on-invalid.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Don't crash (PR25156).
+
+class foo; // expected-note {{forward declaration of 'foo'}}
+void f() {
+  foo::~foo(); // expected-error {{incomplete type 'foo' named in nested name specifier}}
+}
Index: lib/Sema/SemaExprCXX.cpp
===================================================================
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -189,9 +189,10 @@
     // have one) and, if that fails to find a match, in the scope (if
     // we're allowed to look there).
     Found.clear();
-    if (Step == 0 && LookupCtx)
-      LookupQualifiedName(Found, LookupCtx);
-    else if (Step == 1 && LookInScope && S)
+    if (Step == 0 && LookupCtx) {
+      if (!RequireCompleteDeclContext(SS, LookupCtx))
+        LookupQualifiedName(Found, LookupCtx);
+    } else if (Step == 1 && LookInScope && S)
       LookupName(Found, S);
     else
       continue;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17143.47652.patch
Type: text/x-patch
Size: 1108 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160211/ef0add24/attachment.bin>


More information about the cfe-commits mailing list