daltenty created this revision.
daltenty added a reviewer: stevewan.
daltenty requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A follow on to D104484 <https://reviews.llvm.org/D104484>, this blocks the 
emitting of some template cases
where we would hit an assert because though the type was complete,
the class template wasn't fully specialized and adds a test case for the
corresponding test case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105242

Files:
  clang/lib/AST/Decl.cpp
  clang/test/Layout/dump-complete.cpp


Index: clang/test/Layout/dump-complete.cpp
===================================================================
--- clang/test/Layout/dump-complete.cpp
+++ clang/test/Layout/dump-complete.cpp
@@ -12,7 +12,23 @@
 
 class d;
 
+template <class A>
+struct B : public A {};
+
+template <class C>
+struct D : public C {};
+
+template<> struct D<a>;
+
+template <class E>
+struct F : public E {};
+
+F<a> bar;
+
 // CHECK:          0 | struct a
 // CHECK:          0 | struct b
 // CHECK:          0 | class c
 // CHECK-NOT:      0 | class d
+// CHECK-NOT:      0 | struct B
+// CHECK-NOT:      0 | struct D
+// CHECK :         0 | struct F<struct a>
Index: clang/lib/AST/Decl.cpp
===================================================================
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -4585,7 +4585,9 @@
 
   // Layouts are dumped when computed, so if we are dumping for all complete
   // types, we need to force usage to get types that wouldn't be used 
elsewhere.
-  if (Ctx.getLangOpts().DumpRecordLayoutsComplete)
+  if (Ctx.getLangOpts().DumpRecordLayoutsComplete &&
+      (!isa<CXXRecordDecl>(this) ||
+       !cast<CXXRecordDecl>(this)->getDescribedClassTemplate()))
     (void)Ctx.getASTRecordLayout(this);
 }
 


Index: clang/test/Layout/dump-complete.cpp
===================================================================
--- clang/test/Layout/dump-complete.cpp
+++ clang/test/Layout/dump-complete.cpp
@@ -12,7 +12,23 @@
 
 class d;
 
+template <class A>
+struct B : public A {};
+
+template <class C>
+struct D : public C {};
+
+template<> struct D<a>;
+
+template <class E>
+struct F : public E {};
+
+F<a> bar;
+
 // CHECK:          0 | struct a
 // CHECK:          0 | struct b
 // CHECK:          0 | class c
 // CHECK-NOT:      0 | class d
+// CHECK-NOT:      0 | struct B
+// CHECK-NOT:      0 | struct D
+// CHECK :         0 | struct F<struct a>
Index: clang/lib/AST/Decl.cpp
===================================================================
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -4585,7 +4585,9 @@
 
   // Layouts are dumped when computed, so if we are dumping for all complete
   // types, we need to force usage to get types that wouldn't be used elsewhere.
-  if (Ctx.getLangOpts().DumpRecordLayoutsComplete)
+  if (Ctx.getLangOpts().DumpRecordLayoutsComplete &&
+      (!isa<CXXRecordDecl>(this) ||
+       !cast<CXXRecordDecl>(this)->getDescribedClassTemplate()))
     (void)Ctx.getASTRecordLayout(this);
 }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to