File tree Expand file tree Collapse file tree 4 files changed +28
-6
lines changed Expand file tree Collapse file tree 4 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -189,6 +189,7 @@ class LocalDeclID : public DeclIDBase {
189
189
// Every Decl ID is a local decl ID to the module being writing in ASTWriter.
190
190
friend class ASTWriter ;
191
191
friend class GlobalDeclID ;
192
+ friend struct llvm ::DenseMapInfo<clang::LocalDeclID>;
192
193
193
194
public:
194
195
LocalDeclID () : Base() {}
@@ -267,6 +268,27 @@ template <> struct DenseMapInfo<clang::GlobalDeclID> {
267
268
}
268
269
};
269
270
271
+ template <> struct DenseMapInfo <clang::LocalDeclID> {
272
+ using LocalDeclID = clang::LocalDeclID;
273
+ using DeclID = LocalDeclID::DeclID;
274
+
275
+ static LocalDeclID getEmptyKey () {
276
+ return LocalDeclID (DenseMapInfo<DeclID>::getEmptyKey ());
277
+ }
278
+
279
+ static LocalDeclID getTombstoneKey () {
280
+ return LocalDeclID (DenseMapInfo<DeclID>::getTombstoneKey ());
281
+ }
282
+
283
+ static unsigned getHashValue (const LocalDeclID &Key) {
284
+ return DenseMapInfo<DeclID>::getHashValue (Key.getRawValue ());
285
+ }
286
+
287
+ static bool isEqual (const LocalDeclID &L, const LocalDeclID &R) {
288
+ return L == R;
289
+ }
290
+ };
291
+
270
292
} // namespace llvm
271
293
272
294
#endif
Original file line number Diff line number Diff line change @@ -233,13 +233,13 @@ class ASTWriter : public ASTDeserializationListener,
233
233
// / instead of comparing the result of `getDeclID()` or `GetDeclRef()`.
234
234
llvm::SmallPtrSet<const Decl *, 32 > PredefinedDecls;
235
235
236
- // / Mapping from FunctionDecl to the list of lambda IDs inside the function.
236
+ // / Mapping from FunctionDecl ID to the list of lambda IDs inside the
237
+ // / function.
237
238
// /
238
239
// / These lambdas have to be loaded right after the function they belong to.
239
240
// / In order to have canonical declaration for lambda class from the same
240
241
// / module as enclosing function during deserialization.
241
- llvm::DenseMap<const Decl *, SmallVector<LocalDeclID, 4 >>
242
- FunctionToLambdasMap;
242
+ llvm::DenseMap<LocalDeclID, SmallVector<LocalDeclID, 4 >> FunctionToLambdasMap;
243
243
244
244
// / Offset of each declaration in the bitstream, indexed by
245
245
// / the declaration's ID.
Original file line number Diff line number Diff line change @@ -5713,8 +5713,7 @@ void ASTWriter::WriteDeclAndTypes(ASTContext &Context) {
5713
5713
// efficent becuase it allows lazy deserialization.
5714
5714
RecordData FunctionToLambdasMapRecord;
5715
5715
for (const auto &Pair : FunctionToLambdasMap) {
5716
- FunctionToLambdasMapRecord.push_back (
5717
- GetDeclRef (Pair.first ).getRawValue ());
5716
+ FunctionToLambdasMapRecord.push_back (Pair.first .getRawValue ());
5718
5717
FunctionToLambdasMapRecord.push_back (Pair.second .size ());
5719
5718
for (const auto &Lambda : Pair.second )
5720
5719
FunctionToLambdasMapRecord.push_back (Lambda.getRawValue ());
Original file line number Diff line number Diff line change @@ -1524,7 +1524,8 @@ void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
1524
1524
// For lambdas inside canonical FunctionDecl remember the mapping.
1525
1525
if (auto FD = llvm::dyn_cast_or_null<FunctionDecl>(D->getDeclContext ());
1526
1526
FD && FD->isCanonicalDecl ()) {
1527
- Writer.FunctionToLambdasMap [FD].push_back (Writer.GetDeclRef (D));
1527
+ Writer.FunctionToLambdasMap [Writer.GetDeclRef (FD)].push_back (
1528
+ Writer.GetDeclRef (D));
1528
1529
}
1529
1530
} else {
1530
1531
Record.push_back (CXXRecNotTemplate);
You can’t perform that action at this time.
0 commit comments