Module debug info: Don't assert when encountering an incomplete definition
authorAdrian Prantl <aprantl@apple.com>
Mon, 22 Aug 2016 22:23:58 +0000 (22:23 +0000)
committerAdrian Prantl <aprantl@apple.com>
Mon, 22 Aug 2016 22:23:58 +0000 (22:23 +0000)
in isDefinedInClangModule() and assume that the incomplete definition
is not defined in the module.

This broke the -gmodules self host recently.
rdar://problem/27894367

llvm-svn: 279485

clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/Modules/Inputs/DebugNestedA.h [new file with mode: 0644]
clang/test/Modules/Inputs/DebugNestedB.h [new file with mode: 0644]
clang/test/Modules/Inputs/module.map

index a153193..af0cd02 100644 (file)
@@ -1655,7 +1655,8 @@ static bool isDefinedInClangModule(const RecordDecl *RD) {
   if (!RD->isExternallyVisible() && RD->getName().empty())
     return false;
   if (auto *CXXDecl = dyn_cast<CXXRecordDecl>(RD)) {
-    assert(CXXDecl->isCompleteDefinition() && "incomplete record definition");
+    if (!CXXDecl->isCompleteDefinition())
+      return false;
     auto TemplateKind = CXXDecl->getTemplateSpecializationKind();
     if (TemplateKind != TSK_Undeclared) {
       // This is a template, check the origin of the first member.
diff --git a/clang/test/Modules/Inputs/DebugNestedA.h b/clang/test/Modules/Inputs/DebugNestedA.h
new file mode 100644 (file)
index 0000000..58dc2a7
--- /dev/null
@@ -0,0 +1,8 @@
+/* -*- C++ -*- */
+template <typename T> class Base {};
+template <typename T> struct A : public Base<A<T>> {
+  void f();
+};
+
+class F {};
+typedef A<F> AF;
diff --git a/clang/test/Modules/Inputs/DebugNestedB.h b/clang/test/Modules/Inputs/DebugNestedB.h
new file mode 100644 (file)
index 0000000..7f75d09
--- /dev/null
@@ -0,0 +1,7 @@
+/* -*- C++ -*- */
+#include "DebugNestedA.h"
+class C {
+  void run(AF &af) {
+    af.f();
+  }
+};
index a683190..2beb942 100644 (file)
@@ -422,3 +422,13 @@ module MacroFabs1 {
 module DiagOutOfDate {
   header "DiagOutOfDate.h"
 }
+
+module DebugNestedA {
+  header "DebugNestedA.h"
+  export *
+}
+
+module DebugNestedB {
+  header "DebugNestedB.h"
+  export *
+}