211 changes: 99 additions & 112 deletions clang/lib/Serialization/ASTReaderDecl.cpp

Large diffs are not rendered by default.

77 changes: 40 additions & 37 deletions clang/lib/Serialization/ASTWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3043,7 +3043,7 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
RecordData Inits;
for (Decl *D : Context->getModuleInitializers(Mod))
if (wasDeclEmitted(D))
Inits.push_back(GetDeclRef(D));
AddDeclRef(D, Inits);
if (!Inits.empty())
Stream.EmitRecord(SUBMODULE_INITIALIZERS, Inits);

Expand Down Expand Up @@ -3226,7 +3226,7 @@ uint64_t ASTWriter::WriteDeclContextLexicalBlock(ASTContext &Context,
continue;

KindDeclPairs.push_back(D->getKind());
KindDeclPairs.push_back(GetDeclRef(D));
KindDeclPairs.push_back(GetDeclRef(D).get());
}

++NumLexicalDeclContexts;
Expand Down Expand Up @@ -3261,7 +3261,7 @@ void ASTWriter::WriteTypeDeclOffsets() {
unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
{
RecordData::value_type Record[] = {DECL_OFFSET, DeclOffsets.size(),
FirstDeclID - NUM_PREDEF_DECL_IDS};
FirstDeclID.get() - NUM_PREDEF_DECL_IDS};
Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record, bytes(DeclOffsets));
}
}
Expand All @@ -3282,7 +3282,7 @@ void ASTWriter::WriteFileDeclIDsMap() {
Info.FirstDeclIndex = FileGroupedDeclIDs.size();
llvm::stable_sort(Info.DeclIDs);
for (auto &LocDeclEntry : Info.DeclIDs)
FileGroupedDeclIDs.push_back(LocDeclEntry.second);
FileGroupedDeclIDs.push_back(LocDeclEntry.second.get());
}

auto Abbrev = std::make_shared<BitCodeAbbrev>();
Expand Down Expand Up @@ -3420,11 +3420,11 @@ class ASTMethodPoolTrait {
for (const ObjCMethodList *Method = &Methods.Instance; Method;
Method = Method->getNext())
if (ShouldWriteMethodListNode(Method))
LE.write<DeclID>(Writer.getDeclID(Method->getMethod()));
LE.write<DeclID>((DeclID)Writer.getDeclID(Method->getMethod()));
for (const ObjCMethodList *Method = &Methods.Factory; Method;
Method = Method->getNext())
if (ShouldWriteMethodListNode(Method))
LE.write<DeclID>(Writer.getDeclID(Method->getMethod()));
LE.write<DeclID>((DeclID)Writer.getDeclID(Method->getMethod()));

assert(Out.tell() - Start == DataLen && "Data length is wrong");
}
Expand Down Expand Up @@ -3743,8 +3743,8 @@ class ASTIdentifierTableTrait {
// Only emit declarations that aren't from a chained PCH, though.
SmallVector<NamedDecl *, 16> Decls(IdResolver.decls(II));
for (NamedDecl *D : llvm::reverse(Decls))
LE.write<DeclID>(
Writer.getDeclID(getDeclForLocalLookup(PP.getLangOpts(), D)));
LE.write<DeclID>((DeclID)Writer.getDeclID(
getDeclForLocalLookup(PP.getLangOpts(), D)));
}
}
};
Expand Down Expand Up @@ -3860,7 +3860,7 @@ namespace {
// Trait used for the on-disk hash table used in the method pool.
class ASTDeclContextNameLookupTrait {
ASTWriter &Writer;
llvm::SmallVector<DeclID, 64> DeclIDs;
llvm::SmallVector<LocalDeclID, 64> DeclIDs;

public:
using key_type = DeclarationNameKey;
Expand Down Expand Up @@ -3893,8 +3893,10 @@ class ASTDeclContextNameLookupTrait {

data_type ImportData(const reader::ASTDeclContextNameLookupTrait::data_type &FromReader) {
unsigned Start = DeclIDs.size();
DeclIDs.insert(DeclIDs.end(), DeclIDIterator(FromReader.begin()),
DeclIDIterator(FromReader.end()));
DeclIDs.insert(
DeclIDs.end(),
DeclIDIterator<GlobalDeclID, LocalDeclID>(FromReader.begin()),
DeclIDIterator<GlobalDeclID, LocalDeclID>(FromReader.end()));
return std::make_pair(Start, DeclIDs.size());
}

Expand Down Expand Up @@ -3983,7 +3985,7 @@ class ASTDeclContextNameLookupTrait {
endian::Writer LE(Out, llvm::endianness::little);
uint64_t Start = Out.tell(); (void)Start;
for (unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
LE.write<DeclID>(DeclIDs[I]);
LE.write<DeclID>((DeclID)DeclIDs[I]);
assert(Out.tell() - Start == DataLen && "Data length is wrong");
}
};
Expand Down Expand Up @@ -4317,7 +4319,8 @@ void ASTWriter::WriteDeclContextVisibleUpdate(const DeclContext *DC) {
DC = cast<DeclContext>(Chain->getKeyDeclaration(cast<Decl>(DC)));

// Write the lookup table
RecordData::value_type Record[] = {UPDATE_VISIBLE, getDeclID(cast<Decl>(DC))};
RecordData::value_type Record[] = {UPDATE_VISIBLE,
getDeclID(cast<Decl>(DC)).get()};
Stream.EmitRecordWithBlob(UpdateVisibleAbbrev, Record, LookupTable);
}

Expand Down Expand Up @@ -4371,7 +4374,7 @@ void ASTWriter::WriteObjCCategories() {
Cat = Class->known_categories_begin(),
CatEnd = Class->known_categories_end();
Cat != CatEnd; ++Cat, ++Size) {
assert(getDeclID(*Cat) != 0 && "Bogus category");
assert(getDeclID(*Cat).isValid() && "Bogus category");
AddDeclRef(*Cat, Categories);
}

Expand Down Expand Up @@ -5089,7 +5092,7 @@ void ASTWriter::WriteSpecialDeclRecords(Sema &SemaRef) {
if (!D || !wasDeclEmitted(D))
SemaDeclRefs.push_back(0);
else
SemaDeclRefs.push_back(getDeclID(D));
AddDeclRef(D, SemaDeclRefs);
};

AddEmittedDeclRefOrZero(SemaRef.getStdNamespace());
Expand All @@ -5100,10 +5103,10 @@ void ASTWriter::WriteSpecialDeclRecords(Sema &SemaRef) {
Stream.EmitRecord(SEMA_DECL_REFS, SemaDeclRefs);

// Write the record containing decls to be checked for deferred diags.
SmallVector<DeclID, 64> DeclsToCheckForDeferredDiags;
RecordData DeclsToCheckForDeferredDiags;
for (auto *D : SemaRef.DeclsToCheckForDeferredDiags)
if (wasDeclEmitted(D))
DeclsToCheckForDeferredDiags.push_back(getDeclID(D));
AddDeclRef(D, DeclsToCheckForDeferredDiags);
if (!DeclsToCheckForDeferredDiags.empty())
Stream.EmitRecord(DECLS_TO_CHECK_FOR_DEFERRED_DIAGS,
DeclsToCheckForDeferredDiags);
Expand Down Expand Up @@ -5473,7 +5476,7 @@ void ASTWriter::WriteDeclAndTypes(ASTContext &Context) {
if (VisibleOffset)
VisibleOffset -= DeclTypesBlockStartOffset;

DelayedNamespaceRecord.push_back(getDeclID(NS));
AddDeclRef(NS, DelayedNamespaceRecord);
DelayedNamespaceRecord.push_back(LexicalOffset);
DelayedNamespaceRecord.push_back(VisibleOffset);
}
Expand Down Expand Up @@ -5507,7 +5510,7 @@ void ASTWriter::WriteDeclAndTypes(ASTContext &Context) {
continue;

NewGlobalKindDeclPairs.push_back(D->getKind());
NewGlobalKindDeclPairs.push_back(GetDeclRef(D));
NewGlobalKindDeclPairs.push_back(GetDeclRef(D).get());
}

auto Abv = std::make_shared<llvm::BitCodeAbbrev>();
Expand Down Expand Up @@ -5568,7 +5571,7 @@ void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION:
case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE:
assert(Update.getDecl() && "no decl to add?");
Record.push_back(GetDeclRef(Update.getDecl()));
Record.AddDeclRef(Update.getDecl());
break;

case UPD_CXX_ADDED_FUNCTION_DEFINITION:
Expand Down Expand Up @@ -5709,7 +5712,7 @@ void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
}
}

OffsetsRecord.push_back(GetDeclRef(D));
AddDeclRef(D, OffsetsRecord);
OffsetsRecord.push_back(Record.Emit(DECL_UPDATES));
}
}
Expand Down Expand Up @@ -5974,18 +5977,18 @@ void ASTWriter::AddEmittedDeclRef(const Decl *D, RecordDataImpl &Record) {
if (!wasDeclEmitted(D))
return;

Record.push_back(GetDeclRef(D));
Record.push_back(GetDeclRef(D).get());
}

void ASTWriter::AddDeclRef(const Decl *D, RecordDataImpl &Record) {
Record.push_back(GetDeclRef(D));
Record.push_back(GetDeclRef(D).get());
}

DeclID ASTWriter::GetDeclRef(const Decl *D) {
LocalDeclID ASTWriter::GetDeclRef(const Decl *D) {
assert(WritingAST && "Cannot request a declaration ID before AST writing");

if (!D) {
return 0;
return LocalDeclID();
}

// If the DeclUpdate from the GMF gets touched, emit it.
Expand All @@ -5999,14 +6002,14 @@ DeclID ASTWriter::GetDeclRef(const Decl *D) {
// If D comes from an AST file, its declaration ID is already known and
// fixed.
if (D->isFromASTFile())
return D->getGlobalID();
return LocalDeclID(D->getGlobalID());

assert(!(reinterpret_cast<uintptr_t>(D) & 0x01) && "Invalid decl pointer");
DeclID &ID = DeclIDs[D];
if (ID == 0) {
LocalDeclID &ID = DeclIDs[D];
if (ID.isInvalid()) {
if (DoneWritingDeclsAndTypes) {
assert(0 && "New decl seen after serializing all the decls to emit!");
return 0;
return LocalDeclID();
}

// We haven't seen this declaration before. Give it a new ID and
Expand All @@ -6018,14 +6021,14 @@ DeclID ASTWriter::GetDeclRef(const Decl *D) {
return ID;
}

DeclID ASTWriter::getDeclID(const Decl *D) {
LocalDeclID ASTWriter::getDeclID(const Decl *D) {
if (!D)
return 0;
return LocalDeclID();

// If D comes from an AST file, its declaration ID is already known and
// fixed.
if (D->isFromASTFile())
return D->getGlobalID();
return LocalDeclID(D->getGlobalID());

assert(DeclIDs.contains(D) && "Declaration not emitted!");
return DeclIDs[D];
Expand All @@ -6046,8 +6049,8 @@ bool ASTWriter::wasDeclEmitted(const Decl *D) const {
return Emitted;
}

void ASTWriter::associateDeclWithFile(const Decl *D, DeclID ID) {
assert(ID);
void ASTWriter::associateDeclWithFile(const Decl *D, LocalDeclID ID) {
assert(ID.isValid());
assert(D);

SourceLocation Loc = D->getLocation();
Expand Down Expand Up @@ -6079,7 +6082,7 @@ void ASTWriter::associateDeclWithFile(const Decl *D, DeclID ID) {
if (!Info)
Info = std::make_unique<DeclIDInFileInfo>();

std::pair<unsigned, DeclID> LocDecl(Offset, ID);
std::pair<unsigned, LocalDeclID> LocDecl(Offset, ID);
LocDeclIDsTy &Decls = Info->DeclIDs;
Decls.push_back(LocDecl);
}
Expand Down Expand Up @@ -6349,7 +6352,7 @@ void ASTRecordWriter::AddCXXDefinitionData(const CXXRecordDecl *D) {
Writer->Context->getLangOpts().ModulesDebugInfo && !D->isDependentType();
Record->push_back(ModulesDebugInfo);
if (ModulesDebugInfo)
Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(D));
Writer->AddDeclRef(D, Writer->ModularCodegenDecls);

// IsLambda bit is already saved.

Expand Down Expand Up @@ -6453,7 +6456,7 @@ void ASTWriter::ReaderInitialized(ASTReader *Reader) {

// Note, this will get called multiple times, once one the reader starts up
// and again each time it's done reading a PCH or module.
FirstDeclID = NUM_PREDEF_DECL_IDS + Chain->getTotalNumDecls();
FirstDeclID = LocalDeclID(NUM_PREDEF_DECL_IDS + Chain->getTotalNumDecls());
FirstTypeID = NUM_PREDEF_TYPE_IDS + Chain->getTotalNumTypes();
FirstIdentID = NUM_PREDEF_IDENT_IDS + Chain->getTotalNumIdentifiers();
FirstMacroID = NUM_PREDEF_MACRO_IDS + Chain->getTotalNumMacros();
Expand Down
22 changes: 12 additions & 10 deletions clang/lib/Serialization/ASTWriterDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ namespace clang {
assert(!Common->LazySpecializations);
}

ArrayRef<DeclID> LazySpecializations;
ArrayRef<GlobalDeclID> LazySpecializations;
if (auto *LS = Common->LazySpecializations)
LazySpecializations = llvm::ArrayRef(LS + 1, LS[0]);
LazySpecializations = llvm::ArrayRef(LS + 1, LS[0].get());

// Add a slot to the record for the number of specializations.
unsigned I = Record.size();
Expand All @@ -243,7 +243,9 @@ namespace clang {
assert(D->isCanonicalDecl() && "non-canonical decl in set");
AddFirstDeclFromEachModule(D, /*IncludeLocal*/true);
}
Record.append(LazySpecializations.begin(), LazySpecializations.end());
Record.append(
DeclIDIterator<GlobalDeclID, DeclID>(LazySpecializations.begin()),
DeclIDIterator<GlobalDeclID, DeclID>(LazySpecializations.end()));

// Update the size entry we added earlier.
Record[I] = Record.size() - I - 1;
Expand Down Expand Up @@ -1166,7 +1168,7 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
Record.push_back(VarDeclBits);

if (ModulesCodegen)
Writer.ModularCodegenDecls.push_back(Writer.GetDeclRef(D));
Writer.AddDeclRef(D, Writer.ModularCodegenDecls);

if (D->hasAttr<BlocksAttr>()) {
BlockVarCopyInit Init = Writer.Context->getBlockVarCopyInit(D);
Expand Down Expand Up @@ -2786,10 +2788,10 @@ void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
"serializing");

// Determine the ID for this declaration.
DeclID ID;
LocalDeclID ID;
assert(!D->isFromASTFile() && "should not be emitting imported decl");
DeclID &IDR = DeclIDs[D];
if (IDR == 0)
LocalDeclID &IDR = DeclIDs[D];
if (IDR.isInvalid())
IDR = NextDeclID++;

ID = IDR;
Expand All @@ -2807,7 +2809,7 @@ void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {

// Record the offset for this declaration
SourceLocation Loc = D->getLocation();
unsigned Index = ID - FirstDeclID;
unsigned Index = ID.get() - FirstDeclID.get();
if (DeclOffsets.size() == Index)
DeclOffsets.emplace_back(getAdjustedLocation(Loc), Offset,
DeclTypesBlockStartOffset);
Expand All @@ -2827,7 +2829,7 @@ void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
// Note declarations that should be deserialized eagerly so that we can add
// them to a record in the AST file later.
if (isRequiredDecl(D, Context, WritingModule))
EagerlyDeserializedDecls.push_back(ID);
AddDeclRef(D, EagerlyDeserializedDecls);
}

void ASTRecordWriter::AddFunctionDefinition(const FunctionDecl *FD) {
Expand Down Expand Up @@ -2863,7 +2865,7 @@ void ASTRecordWriter::AddFunctionDefinition(const FunctionDecl *FD) {
}
Record->push_back(ModulesCodegen);
if (ModulesCodegen)
Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(FD));
Writer->AddDeclRef(FD, Writer->ModularCodegenDecls);
if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
Record->push_back(CD->getNumCtorInitializers());
if (CD->getNumCtorInitializers())
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ExternalASTSourceWrapper : public clang::ExternalSemaSource {

~ExternalASTSourceWrapper() override;

clang::Decl *GetExternalDecl(uint32_t ID) override {
clang::Decl *GetExternalDecl(clang::GlobalDeclID ID) override {
return m_Source->GetExternalDecl(ID);
}

Expand Down Expand Up @@ -266,7 +266,7 @@ class SemaSourceWithPriorities : public clang::ExternalSemaSource {
// ExternalASTSource.
//===--------------------------------------------------------------------===//

clang::Decl *GetExternalDecl(uint32_t ID) override {
clang::Decl *GetExternalDecl(clang::GlobalDeclID ID) override {
for (size_t i = 0; i < Sources.size(); ++i)
if (clang::Decl *Result = Sources[i]->GetExternalDecl(ID))
return Result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ClangASTSource : public clang::ExternalASTSource,
~ClangASTSource() override;

/// Interface stubs.
clang::Decl *GetExternalDecl(uint32_t) override { return nullptr; }
clang::Decl *GetExternalDecl(clang::GlobalDeclID) override { return nullptr; }
clang::Stmt *GetExternalDeclStmt(uint64_t) override { return nullptr; }
clang::Selector GetExternalSelector(uint32_t) override {
return clang::Selector();
Expand Down
66 changes: 38 additions & 28 deletions lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ CompilerType TypeSystemClang::CreateRecordType(
// complete definition just in case.

bool has_name = !name.empty();
CXXRecordDecl *decl = CXXRecordDecl::CreateDeserialized(ast, 0);
CXXRecordDecl *decl = CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
decl->setTagKind(static_cast<TagDecl::TagKind>(kind));
decl->setDeclContext(decl_ctx);
if (has_name)
Expand Down Expand Up @@ -1402,7 +1402,7 @@ clang::FunctionTemplateDecl *TypeSystemClang::CreateFunctionTemplateDecl(
TemplateParameterList *template_param_list = CreateTemplateParameterList(
ast, template_param_infos, template_param_decls);
FunctionTemplateDecl *func_tmpl_decl =
FunctionTemplateDecl::CreateDeserialized(ast, 0);
FunctionTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
func_tmpl_decl->setDeclContext(decl_ctx);
func_tmpl_decl->setLocation(func_decl->getLocation());
func_tmpl_decl->setDeclName(func_decl->getDeclName());
Expand Down Expand Up @@ -1564,7 +1564,8 @@ ClassTemplateDecl *TypeSystemClang::CreateClassTemplateDecl(
TemplateParameterList *template_param_list = CreateTemplateParameterList(
ast, template_param_infos, template_param_decls);

CXXRecordDecl *template_cxx_decl = CXXRecordDecl::CreateDeserialized(ast, 0);
CXXRecordDecl *template_cxx_decl =
CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
template_cxx_decl->setTagKind(static_cast<TagDecl::TagKind>(kind));
// What decl context do we use here? TU? The actual decl context?
template_cxx_decl->setDeclContext(decl_ctx);
Expand All @@ -1581,7 +1582,8 @@ ClassTemplateDecl *TypeSystemClang::CreateClassTemplateDecl(
// template_cxx_decl->startDefinition();
// template_cxx_decl->completeDefinition();

class_template_decl = ClassTemplateDecl::CreateDeserialized(ast, 0);
class_template_decl =
ClassTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
// What decl context do we use here? TU? The actual decl context?
class_template_decl->setDeclContext(decl_ctx);
class_template_decl->setDeclName(decl_name);
Expand Down Expand Up @@ -1642,7 +1644,7 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl(
ast, template_param_infos.GetParameterPackArgs());
}
ClassTemplateSpecializationDecl *class_template_specialization_decl =
ClassTemplateSpecializationDecl::CreateDeserialized(ast, 0);
ClassTemplateSpecializationDecl::CreateDeserialized(ast, GlobalDeclID());
class_template_specialization_decl->setTagKind(
static_cast<TagDecl::TagKind>(kind));
class_template_specialization_decl->setDeclContext(decl_ctx);
Expand Down Expand Up @@ -1792,7 +1794,8 @@ CompilerType TypeSystemClang::CreateObjCClass(
if (!decl_ctx)
decl_ctx = ast.getTranslationUnitDecl();

ObjCInterfaceDecl *decl = ObjCInterfaceDecl::CreateDeserialized(ast, 0);
ObjCInterfaceDecl *decl =
ObjCInterfaceDecl::CreateDeserialized(ast, GlobalDeclID());
decl->setDeclContext(decl_ctx);
decl->setDeclName(&ast.Idents.get(name));
/*isForwardDecl,*/
Expand Down Expand Up @@ -1900,7 +1903,7 @@ TypeSystemClang::CreateBlockDeclaration(clang::DeclContext *ctx,
OptionalClangModuleID owning_module) {
if (ctx) {
clang::BlockDecl *decl =
clang::BlockDecl::CreateDeserialized(getASTContext(), 0);
clang::BlockDecl::CreateDeserialized(getASTContext(), GlobalDeclID());
decl->setDeclContext(ctx);
ctx->addDecl(decl);
SetOwningModule(decl, owning_module);
Expand Down Expand Up @@ -1969,7 +1972,7 @@ clang::VarDecl *TypeSystemClang::CreateVariableDeclaration(
const char *name, clang::QualType type) {
if (decl_context) {
clang::VarDecl *var_decl =
clang::VarDecl::CreateDeserialized(getASTContext(), 0);
clang::VarDecl::CreateDeserialized(getASTContext(), GlobalDeclID());
var_decl->setDeclContext(decl_context);
if (name && name[0])
var_decl->setDeclName(&getASTContext().Idents.getOwn(name));
Expand Down Expand Up @@ -2129,7 +2132,7 @@ FunctionDecl *TypeSystemClang::CreateFunctionDeclaration(

clang::DeclarationName declarationName =
GetDeclarationName(name, function_clang_type);
func_decl = FunctionDecl::CreateDeserialized(ast, 0);
func_decl = FunctionDecl::CreateDeserialized(ast, GlobalDeclID());
func_decl->setDeclContext(decl_ctx);
func_decl->setDeclName(declarationName);
func_decl->setType(ClangUtil::GetQualType(function_clang_type));
Expand Down Expand Up @@ -2190,7 +2193,7 @@ ParmVarDecl *TypeSystemClang::CreateParameterDeclaration(
const char *name, const CompilerType &param_type, int storage,
bool add_decl) {
ASTContext &ast = getASTContext();
auto *decl = ParmVarDecl::CreateDeserialized(ast, 0);
auto *decl = ParmVarDecl::CreateDeserialized(ast, GlobalDeclID());
decl->setDeclContext(decl_ctx);
if (name && name[0])
decl->setDeclName(&ast.Idents.get(name));
Expand Down Expand Up @@ -2295,7 +2298,7 @@ CompilerType TypeSystemClang::CreateEnumerationType(

// TODO: ask about these...
// const bool IsFixed = false;
EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, 0);
EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, GlobalDeclID());
enum_decl->setDeclContext(decl_ctx);
if (!name.empty())
enum_decl->setDeclName(&ast.Idents.get(name));
Expand Down Expand Up @@ -4534,7 +4537,7 @@ CompilerType TypeSystemClang::CreateTypedef(
decl_ctx = getASTContext().getTranslationUnitDecl();

clang::TypedefDecl *decl =
clang::TypedefDecl::CreateDeserialized(clang_ast, 0);
clang::TypedefDecl::CreateDeserialized(clang_ast, GlobalDeclID());
decl->setDeclContext(decl_ctx);
decl->setDeclName(&clang_ast.Idents.get(typedef_name));
decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
Expand Down Expand Up @@ -7291,7 +7294,7 @@ clang::FieldDecl *TypeSystemClang::AddFieldToRecordType(

clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
if (record_decl) {
field = clang::FieldDecl::CreateDeserialized(clang_ast, 0);
field = clang::FieldDecl::CreateDeserialized(clang_ast, GlobalDeclID());
field->setDeclContext(record_decl);
field->setDeclName(ident);
field->setType(ClangUtil::GetQualType(field_clang_type));
Expand Down Expand Up @@ -7338,7 +7341,8 @@ clang::FieldDecl *TypeSystemClang::AddFieldToRecordType(

field_clang_type.GetCompleteType();

auto *ivar = clang::ObjCIvarDecl::CreateDeserialized(clang_ast, 0);
auto *ivar =
clang::ObjCIvarDecl::CreateDeserialized(clang_ast, GlobalDeclID());
ivar->setDeclContext(class_interface_decl);
ivar->setDeclName(ident);
ivar->setType(ClangUtil::GetQualType(field_clang_type));
Expand Down Expand Up @@ -7504,7 +7508,8 @@ clang::VarDecl *TypeSystemClang::AddVariableToRecordType(
if (!name.empty())
ident = &ast->getASTContext().Idents.get(name);

var_decl = clang::VarDecl::CreateDeserialized(ast->getASTContext(), 0);
var_decl =
clang::VarDecl::CreateDeserialized(ast->getASTContext(), GlobalDeclID());
var_decl->setDeclContext(record_decl);
var_decl->setDeclName(ident);
var_decl->setType(ClangUtil::GetQualType(var_type));
Expand Down Expand Up @@ -7605,8 +7610,8 @@ clang::CXXMethodDecl *TypeSystemClang::AddMethodToCXXRecordType(
: clang::ExplicitSpecKind::ResolvedFalse);

if (name.starts_with("~")) {
cxx_dtor_decl =
clang::CXXDestructorDecl::CreateDeserialized(getASTContext(), 0);
cxx_dtor_decl = clang::CXXDestructorDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
cxx_dtor_decl->setDeclContext(cxx_record_decl);
cxx_dtor_decl->setDeclName(
getASTContext().DeclarationNames.getCXXDestructorName(
Expand All @@ -7618,7 +7623,7 @@ clang::CXXMethodDecl *TypeSystemClang::AddMethodToCXXRecordType(
cxx_method_decl = cxx_dtor_decl;
} else if (decl_name == cxx_record_decl->getDeclName()) {
cxx_ctor_decl = clang::CXXConstructorDecl::CreateDeserialized(
getASTContext(), 0, 0);
getASTContext(), GlobalDeclID(), 0);
cxx_ctor_decl->setDeclContext(cxx_record_decl);
cxx_ctor_decl->setDeclName(
getASTContext().DeclarationNames.getCXXConstructorName(
Expand All @@ -7644,8 +7649,8 @@ clang::CXXMethodDecl *TypeSystemClang::AddMethodToCXXRecordType(
if (!TypeSystemClang::CheckOverloadedOperatorKindParameterCount(
is_method, op_kind, num_params))
return nullptr;
cxx_method_decl =
clang::CXXMethodDecl::CreateDeserialized(getASTContext(), 0);
cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
cxx_method_decl->setDeclContext(cxx_record_decl);
cxx_method_decl->setDeclName(
getASTContext().DeclarationNames.getCXXOperatorName(op_kind));
Expand All @@ -7656,7 +7661,8 @@ clang::CXXMethodDecl *TypeSystemClang::AddMethodToCXXRecordType(
} else if (num_params == 0) {
// Conversion operators don't take params...
auto *cxx_conversion_decl =
clang::CXXConversionDecl::CreateDeserialized(getASTContext(), 0);
clang::CXXConversionDecl::CreateDeserialized(getASTContext(),
GlobalDeclID());
cxx_conversion_decl->setDeclContext(cxx_record_decl);
cxx_conversion_decl->setDeclName(
getASTContext().DeclarationNames.getCXXConversionFunctionName(
Expand All @@ -7671,8 +7677,8 @@ clang::CXXMethodDecl *TypeSystemClang::AddMethodToCXXRecordType(
}

if (cxx_method_decl == nullptr) {
cxx_method_decl =
clang::CXXMethodDecl::CreateDeserialized(getASTContext(), 0);
cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
cxx_method_decl->setDeclContext(cxx_record_decl);
cxx_method_decl->setDeclName(decl_name);
cxx_method_decl->setType(method_qual_type);
Expand Down Expand Up @@ -7855,7 +7861,7 @@ bool TypeSystemClang::AddObjCClassProperty(
ClangUtil::GetQualType(property_clang_type));

clang::ObjCPropertyDecl *property_decl =
clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, 0);
clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, GlobalDeclID());
property_decl->setDeclContext(class_interface_decl);
property_decl->setDeclName(&clang_ast.Idents.get(property_name));
property_decl->setType(ivar_decl
Expand Down Expand Up @@ -7944,7 +7950,8 @@ bool TypeSystemClang::AddObjCClassProperty(
clang::ObjCImplementationControl::None;
const bool HasRelatedResultType = false;

getter = clang::ObjCMethodDecl::CreateDeserialized(clang_ast, 0);
getter =
clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
getter->setDeclName(getter_sel);
getter->setReturnType(ClangUtil::GetQualType(property_clang_type_to_access));
getter->setDeclContext(class_interface_decl);
Expand Down Expand Up @@ -7986,7 +7993,8 @@ bool TypeSystemClang::AddObjCClassProperty(
clang::ObjCImplementationControl::None;
const bool HasRelatedResultType = false;

setter = clang::ObjCMethodDecl::CreateDeserialized(clang_ast, 0);
setter =
clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
setter->setDeclName(setter_sel);
setter->setReturnType(result_type);
setter->setDeclContext(class_interface_decl);
Expand Down Expand Up @@ -8114,7 +8122,8 @@ clang::ObjCMethodDecl *TypeSystemClang::AddMethodToObjCObjectType(
return nullptr; // some debug information is corrupt. We are not going to
// deal with it.

auto *objc_method_decl = clang::ObjCMethodDecl::CreateDeserialized(ast, 0);
auto *objc_method_decl =
clang::ObjCMethodDecl::CreateDeserialized(ast, GlobalDeclID());
objc_method_decl->setDeclName(method_selector);
objc_method_decl->setReturnType(method_function_prototype->getReturnType());
objc_method_decl->setDeclContext(
Expand Down Expand Up @@ -8360,7 +8369,8 @@ clang::EnumConstantDecl *TypeSystemClang::AddEnumerationValueToEnumerationType(
return nullptr;

clang::EnumConstantDecl *enumerator_decl =
clang::EnumConstantDecl::CreateDeserialized(getASTContext(), 0);
clang::EnumConstantDecl::CreateDeserialized(getASTContext(),
GlobalDeclID());
enumerator_decl->setDeclContext(enutype->getDecl());
if (name && name[0])
enumerator_decl->setDeclName(&getASTContext().Idents.get(name));
Expand Down