Skip to content

Commit 8b3b755

Browse files
[clang] Persist Attr::IsPackExpansion into the PCH
Summary: Fixes clangd/clangd#309 Subscribers: ilya-biryukov, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D77194
1 parent 419a559 commit 8b3b755

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Test this without pch.
2+
// RUN: %clang_cc1 -include %s -emit-llvm -o - %s
3+
4+
// Test with pch.
5+
// RUN: %clang_cc1 -emit-pch -o %t %s
6+
// RUN: %clang_cc1 -include-pch %t -emit-llvm -o - %s
7+
8+
#ifndef HEADER
9+
#define HEADER
10+
11+
template<typename T, typename... Types>
12+
struct static_variant {
13+
alignas(Types...) T storage[10];
14+
};
15+
16+
#else
17+
18+
struct A {
19+
static_variant<int> a;
20+
};
21+
struct B {
22+
static_variant<A> _b;
23+
};
24+
25+
#endif

clang/utils/TableGen/ClangAttrEmitter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2911,6 +2911,7 @@ void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS) {
29112911
if (R.isSubClassOf(InhClass))
29122912
OS << " bool isInherited = Record.readInt();\n";
29132913
OS << " bool isImplicit = Record.readInt();\n";
2914+
OS << " bool isPackExpansion = Record.readInt();\n";
29142915
ArgRecords = R.getValueAsListOfDefs("Args");
29152916
Args.clear();
29162917
for (const auto *Arg : ArgRecords) {
@@ -2926,6 +2927,7 @@ void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS) {
29262927
if (R.isSubClassOf(InhClass))
29272928
OS << " cast<InheritableAttr>(New)->setInherited(isInherited);\n";
29282929
OS << " New->setImplicit(isImplicit);\n";
2930+
OS << " New->setPackExpansion(isPackExpansion);\n";
29292931
OS << " break;\n";
29302932
OS << " }\n";
29312933
}
@@ -2952,6 +2954,7 @@ void EmitClangAttrPCHWrite(RecordKeeper &Records, raw_ostream &OS) {
29522954
if (R.isSubClassOf(InhClass))
29532955
OS << " Record.push_back(SA->isInherited());\n";
29542956
OS << " Record.push_back(A->isImplicit());\n";
2957+
OS << " Record.push_back(A->isPackExpansion());\n";
29552958

29562959
for (const auto *Arg : Args)
29572960
createArgument(*Arg, R.getName())->writePCHWrite(OS);

0 commit comments

Comments
 (0)