[clang] Persist Attr::IsPackExpansion into the PCH

Summary: Fixes https://github.com/clangd/clangd/issues/309

Subscribers: ilya-biryukov, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77194
This commit is contained in:
Nathan Ridge 2020-04-01 01:29:58 -04:00
parent 419a559c5a
commit 8b3b7556e9
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,25 @@
// Test this without pch.
// RUN: %clang_cc1 -include %s -emit-llvm -o - %s
// Test with pch.
// RUN: %clang_cc1 -emit-pch -o %t %s
// RUN: %clang_cc1 -include-pch %t -emit-llvm -o - %s
#ifndef HEADER
#define HEADER
template<typename T, typename... Types>
struct static_variant {
alignas(Types...) T storage[10];
};
#else
struct A {
static_variant<int> a;
};
struct B {
static_variant<A> _b;
};
#endif

View File

@ -2911,6 +2911,7 @@ void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS) {
if (R.isSubClassOf(InhClass)) if (R.isSubClassOf(InhClass))
OS << " bool isInherited = Record.readInt();\n"; OS << " bool isInherited = Record.readInt();\n";
OS << " bool isImplicit = Record.readInt();\n"; OS << " bool isImplicit = Record.readInt();\n";
OS << " bool isPackExpansion = Record.readInt();\n";
ArgRecords = R.getValueAsListOfDefs("Args"); ArgRecords = R.getValueAsListOfDefs("Args");
Args.clear(); Args.clear();
for (const auto *Arg : ArgRecords) { for (const auto *Arg : ArgRecords) {
@ -2926,6 +2927,7 @@ void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS) {
if (R.isSubClassOf(InhClass)) if (R.isSubClassOf(InhClass))
OS << " cast<InheritableAttr>(New)->setInherited(isInherited);\n"; OS << " cast<InheritableAttr>(New)->setInherited(isInherited);\n";
OS << " New->setImplicit(isImplicit);\n"; OS << " New->setImplicit(isImplicit);\n";
OS << " New->setPackExpansion(isPackExpansion);\n";
OS << " break;\n"; OS << " break;\n";
OS << " }\n"; OS << " }\n";
} }
@ -2952,6 +2954,7 @@ void EmitClangAttrPCHWrite(RecordKeeper &Records, raw_ostream &OS) {
if (R.isSubClassOf(InhClass)) if (R.isSubClassOf(InhClass))
OS << " Record.push_back(SA->isInherited());\n"; OS << " Record.push_back(SA->isInherited());\n";
OS << " Record.push_back(A->isImplicit());\n"; OS << " Record.push_back(A->isImplicit());\n";
OS << " Record.push_back(A->isPackExpansion());\n";
for (const auto *Arg : Args) for (const auto *Arg : Args)
createArgument(*Arg, R.getName())->writePCHWrite(OS); createArgument(*Arg, R.getName())->writePCHWrite(OS);