Skip to content

Commit ffc2864

Browse files
committed
[ClangImporter] Use new LocalDeclID
There were a number of upstream LLVM changes to `DeclID` in order to separate "local" and "global" IDs: llvm/llvm-project@07b1177 llvm/llvm-project@b8e3b2a llvm/llvm-project@b467c6b llvm/llvm-project#89873 llvm/llvm-project@d86cc73 llvm/llvm-project@8af8602 ... and probably more. This likely needs further cleaning up to not use `DeclID` at all.
1 parent 9c6f5cb commit ffc2864

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

lib/ClangImporter/SwiftLookupTable.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -833,12 +833,12 @@ ArrayRef<clang::ObjCCategoryDecl *> SwiftLookupTable::categories() {
833833

834834
// Map categories known to the reader.
835835
for (auto declID : Reader->categories()) {
836-
auto category =
837-
cast_or_null<clang::ObjCCategoryDecl>(
838-
Reader->getASTReader().GetLocalDecl(Reader->getModuleFile(), declID));
836+
auto localID = clang::LocalDeclID::get(Reader->getASTReader(),
837+
Reader->getModuleFile(), declID);
838+
auto category = cast_or_null<clang::ObjCCategoryDecl>(
839+
Reader->getASTReader().GetLocalDecl(Reader->getModuleFile(), localID));
839840
if (category)
840841
Categories.push_back(category);
841-
842842
}
843843

844844
return Categories;
@@ -930,8 +930,8 @@ static void printStoredContext(SwiftLookupTable::StoredContext context,
930930
}
931931
}
932932

933-
static uint32_t getEncodedDeclID(uint64_t entry) {
934-
assert(SwiftLookupTable::isSerializationIDEntry(entry));
933+
static uint64_t getEncodedDeclID(uint64_t entry) {
934+
assert(SwiftLookupTable::isSerializationIDEntry(entry));
935935
assert(SwiftLookupTable::isDeclEntry(entry));
936936
return entry >> 2;
937937
}
@@ -1190,7 +1190,7 @@ namespace {
11901190
uint64_t id;
11911191
auto mappedEntry = Table.mapStored(entry, isModule);
11921192
if (auto *decl = mappedEntry.dyn_cast<clang::NamedDecl *>()) {
1193-
id = (Writer.getDeclID(decl) << 2) | 0x02;
1193+
id = (Writer.getDeclID(decl).getRawValue() << 2) | 0x02;
11941194
} else if (auto *macro = mappedEntry.dyn_cast<clang::MacroInfo *>()) {
11951195
id = static_cast<uint64_t>(Writer.getMacroID(macro)) << 32;
11961196
id |= 0x02 | 0x01;
@@ -1272,7 +1272,7 @@ namespace {
12721272
uint64_t id;
12731273
auto mappedEntry = Table.mapStored(entry, isModule);
12741274
if (auto *decl = mappedEntry.dyn_cast<clang::NamedDecl *>()) {
1275-
id = (Writer.getDeclID(decl) << 2) | 0x02;
1275+
id = (Writer.getDeclID(decl).getRawValue() << 2) | 0x02;
12761276
} else if (auto *macro = mappedEntry.dyn_cast<clang::MacroInfo *>()) {
12771277
id = static_cast<uint64_t>(Writer.getMacroID(macro)) << 32;
12781278
id |= 0x02 | 0x01;
@@ -1332,7 +1332,7 @@ void SwiftLookupTableWriter::writeExtensionContents(
13321332
if (!table.Categories.empty()) {
13331333
SmallVector<clang::serialization::DeclID, 4> categoryIDs;
13341334
for (auto category : table.Categories) {
1335-
categoryIDs.push_back(Writer.getDeclID(category));
1335+
categoryIDs.push_back(Writer.getDeclID(category).getRawValue());
13361336
}
13371337

13381338
StringRef blob(reinterpret_cast<const char *>(categoryIDs.data()),
@@ -1555,10 +1555,11 @@ clang::NamedDecl *SwiftLookupTable::mapStoredDecl(uint64_t &entry) {
15551555

15561556
// Otherwise, resolve the declaration.
15571557
assert(Reader && "Cannot resolve the declaration without a reader");
1558-
uint32_t declID = getEncodedDeclID(entry);
1558+
auto declID = getEncodedDeclID(entry);
1559+
auto localID = clang::LocalDeclID::get(Reader->getASTReader(),
1560+
Reader->getModuleFile(), declID);
15591561
auto decl = cast_or_null<clang::NamedDecl>(
1560-
Reader->getASTReader().GetLocalDecl(Reader->getModuleFile(),
1561-
declID));
1562+
Reader->getASTReader().GetLocalDecl(Reader->getModuleFile(), localID));
15621563

15631564
// Update the entry now that we've resolved the declaration.
15641565
entry = encodeEntry(decl);

0 commit comments

Comments
 (0)