[PATCH] D105242: [clang] Don't emit uninstantiated templates with -fdump-record-layouts-complete
David Tenty via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 30 16:00:54 PDT 2021
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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105242.355713.patch
Type: text/x-patch
Size: 1235 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210630/51f08e5b/attachment.bin>
More information about the cfe-commits
mailing list