Skip to content

Commit cbc9b92

Browse files
HighCommander4hokein
authored andcommitted
[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 (cherry picked from commit 8b3b755)
1 parent 38f995e commit cbc9b92

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
@@ -2825,6 +2825,7 @@ void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS) {
28252825
if (R.isSubClassOf(InhClass))
28262826
OS << " bool isInherited = Record.readInt();\n";
28272827
OS << " bool isImplicit = Record.readInt();\n";
2828+
OS << " bool isPackExpansion = Record.readInt();\n";
28282829
ArgRecords = R.getValueAsListOfDefs("Args");
28292830
Args.clear();
28302831
for (const auto *Arg : ArgRecords) {
@@ -2840,6 +2841,7 @@ void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS) {
28402841
if (R.isSubClassOf(InhClass))
28412842
OS << " cast<InheritableAttr>(New)->setInherited(isInherited);\n";
28422843
OS << " New->setImplicit(isImplicit);\n";
2844+
OS << " New->setPackExpansion(isPackExpansion);\n";
28432845
OS << " break;\n";
28442846
OS << " }\n";
28452847
}
@@ -2866,6 +2868,7 @@ void EmitClangAttrPCHWrite(RecordKeeper &Records, raw_ostream &OS) {
28662868
if (R.isSubClassOf(InhClass))
28672869
OS << " Record.push_back(SA->isInherited());\n";
28682870
OS << " Record.push_back(A->isImplicit());\n";
2871+
OS << " Record.push_back(A->isPackExpansion());\n";
28692872

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

0 commit comments

Comments
 (0)