diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp --- a/clang/lib/AST/Decl.cpp +++ b/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(this) || + !cast(this)->getDescribedClassTemplate())) (void)Ctx.getASTRecordLayout(this); } diff --git a/clang/test/Layout/dump-complete.cpp b/clang/test/Layout/dump-complete.cpp --- a/clang/test/Layout/dump-complete.cpp +++ b/clang/test/Layout/dump-complete.cpp @@ -12,7 +12,23 @@ class d; +template +struct B : public A {}; + +template +struct D : public C {}; + +template<> struct D; + +template +struct F : public E {}; + +F 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