Page MenuHomeFreeBSD

D51041.diff
No OneTemporary

D51041.diff

diff --git a/contrib/llvm-project/clang/include/clang/Frontend/MultiplexConsumer.h b/contrib/llvm-project/clang/include/clang/Frontend/MultiplexConsumer.h
--- a/contrib/llvm-project/clang/include/clang/Frontend/MultiplexConsumer.h
+++ b/contrib/llvm-project/clang/include/clang/Frontend/MultiplexConsumer.h
@@ -36,6 +36,7 @@
void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
void TypeRead(serialization::TypeIdx Idx, QualType T) override;
void DeclRead(GlobalDeclID ID, const Decl *D) override;
+ void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) override;
void SelectorRead(serialization::SelectorID iD, Selector Sel) override;
void MacroDefinitionRead(serialization::PreprocessedEntityID,
MacroDefinitionRecord *MD) override;
diff --git a/contrib/llvm-project/clang/include/clang/Serialization/ASTDeserializationListener.h b/contrib/llvm-project/clang/include/clang/Serialization/ASTDeserializationListener.h
--- a/contrib/llvm-project/clang/include/clang/Serialization/ASTDeserializationListener.h
+++ b/contrib/llvm-project/clang/include/clang/Serialization/ASTDeserializationListener.h
@@ -45,6 +45,8 @@
virtual void TypeRead(serialization::TypeIdx Idx, QualType T) { }
/// A decl was deserialized from the AST file.
virtual void DeclRead(GlobalDeclID ID, const Decl *D) {}
+ /// A predefined decl was built during the serialization.
+ virtual void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) {}
/// A selector was read from the AST file.
virtual void SelectorRead(serialization::SelectorID iD, Selector Sel) {}
/// A macro definition was read from the AST file.
diff --git a/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h b/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h
--- a/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h
+++ b/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h
@@ -1541,6 +1541,9 @@
std::pair<ModuleFile *, unsigned>
translateTypeIDToIndex(serialization::TypeID ID) const;
+ /// Get a predefined Decl from ASTContext.
+ Decl *getPredefinedDecl(PredefinedDeclIDs ID);
+
public:
/// Load the AST file and validate its contents against the given
/// Preprocessor.
diff --git a/contrib/llvm-project/clang/include/clang/Serialization/ASTWriter.h b/contrib/llvm-project/clang/include/clang/Serialization/ASTWriter.h
--- a/contrib/llvm-project/clang/include/clang/Serialization/ASTWriter.h
+++ b/contrib/llvm-project/clang/include/clang/Serialization/ASTWriter.h
@@ -869,6 +869,7 @@
void IdentifierRead(serialization::IdentifierID ID, IdentifierInfo *II) override;
void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
void TypeRead(serialization::TypeIdx Idx, QualType T) override;
+ void PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) override;
void SelectorRead(serialization::SelectorID ID, Selector Sel) override;
void MacroDefinitionRead(serialization::PreprocessedEntityID ID,
MacroDefinitionRecord *MD) override;
diff --git a/contrib/llvm-project/clang/lib/Frontend/MultiplexConsumer.cpp b/contrib/llvm-project/clang/lib/Frontend/MultiplexConsumer.cpp
--- a/contrib/llvm-project/clang/lib/Frontend/MultiplexConsumer.cpp
+++ b/contrib/llvm-project/clang/lib/Frontend/MultiplexConsumer.cpp
@@ -58,6 +58,11 @@
Listeners[i]->DeclRead(ID, D);
}
+void MultiplexASTDeserializationListener::PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) {
+ for (size_t i = 0, e = Listeners.size(); i != e; ++i)
+ Listeners[i]->PredefinedDeclBuilt(ID, D);
+}
+
void MultiplexASTDeserializationListener::SelectorRead(
serialization::SelectorID ID, Selector Sel) {
for (size_t i = 0, e = Listeners.size(); i != e; ++i)
diff --git a/contrib/llvm-project/clang/lib/Serialization/ASTReader.cpp b/contrib/llvm-project/clang/lib/Serialization/ASTReader.cpp
--- a/contrib/llvm-project/clang/lib/Serialization/ASTReader.cpp
+++ b/contrib/llvm-project/clang/lib/Serialization/ASTReader.cpp
@@ -7741,7 +7741,10 @@
return Loc;
}
-static Decl *getPredefinedDecl(ASTContext &Context, PredefinedDeclIDs ID) {
+Decl *ASTReader::getPredefinedDecl(PredefinedDeclIDs ID) {
+ assert(ContextObj && "reading predefined decl without AST context");
+ ASTContext &Context = *ContextObj;
+ Decl *NewLoaded = nullptr;
switch (ID) {
case PREDEF_DECL_NULL_ID:
return nullptr;
@@ -7750,54 +7753,106 @@
return Context.getTranslationUnitDecl();
case PREDEF_DECL_OBJC_ID_ID:
- return Context.getObjCIdDecl();
+ if (Context.ObjCIdDecl)
+ return Context.ObjCIdDecl;
+ NewLoaded = Context.getObjCIdDecl();
+ break;
case PREDEF_DECL_OBJC_SEL_ID:
- return Context.getObjCSelDecl();
+ if (Context.ObjCSelDecl)
+ return Context.ObjCSelDecl;
+ NewLoaded = Context.getObjCSelDecl();
+ break;
case PREDEF_DECL_OBJC_CLASS_ID:
- return Context.getObjCClassDecl();
+ if (Context.ObjCClassDecl)
+ return Context.ObjCClassDecl;
+ NewLoaded = Context.getObjCClassDecl();
+ break;
case PREDEF_DECL_OBJC_PROTOCOL_ID:
- return Context.getObjCProtocolDecl();
+ if (Context.ObjCProtocolClassDecl)
+ return Context.ObjCProtocolClassDecl;
+ NewLoaded = Context.getObjCProtocolDecl();
+ break;
case PREDEF_DECL_INT_128_ID:
- return Context.getInt128Decl();
+ if (Context.Int128Decl)
+ return Context.Int128Decl;
+ NewLoaded = Context.getInt128Decl();
+ break;
case PREDEF_DECL_UNSIGNED_INT_128_ID:
- return Context.getUInt128Decl();
+ if (Context.UInt128Decl)
+ return Context.UInt128Decl;
+ NewLoaded = Context.getUInt128Decl();
+ break;
case PREDEF_DECL_OBJC_INSTANCETYPE_ID:
- return Context.getObjCInstanceTypeDecl();
+ if (Context.ObjCInstanceTypeDecl)
+ return Context.ObjCInstanceTypeDecl;
+ NewLoaded = Context.getObjCInstanceTypeDecl();
+ break;
case PREDEF_DECL_BUILTIN_VA_LIST_ID:
- return Context.getBuiltinVaListDecl();
+ if (Context.BuiltinVaListDecl)
+ return Context.BuiltinVaListDecl;
+ NewLoaded = Context.getBuiltinVaListDecl();
+ break;
case PREDEF_DECL_VA_LIST_TAG:
- return Context.getVaListTagDecl();
+ if (Context.VaListTagDecl)
+ return Context.VaListTagDecl;
+ NewLoaded = Context.getVaListTagDecl();
+ break;
case PREDEF_DECL_BUILTIN_MS_VA_LIST_ID:
- return Context.getBuiltinMSVaListDecl();
+ if (Context.BuiltinMSVaListDecl)
+ return Context.BuiltinMSVaListDecl;
+ NewLoaded = Context.getBuiltinMSVaListDecl();
+ break;
case PREDEF_DECL_BUILTIN_MS_GUID_ID:
+ // ASTContext::getMSGuidTagDecl won't create MSGuidTagDecl conditionally.
return Context.getMSGuidTagDecl();
case PREDEF_DECL_EXTERN_C_CONTEXT_ID:
- return Context.getExternCContextDecl();
+ if (Context.ExternCContext)
+ return Context.ExternCContext;
+ NewLoaded = Context.getExternCContextDecl();
+ break;
case PREDEF_DECL_MAKE_INTEGER_SEQ_ID:
- return Context.getMakeIntegerSeqDecl();
+ if (Context.MakeIntegerSeqDecl)
+ return Context.MakeIntegerSeqDecl;
+ NewLoaded = Context.getMakeIntegerSeqDecl();
+ break;
case PREDEF_DECL_CF_CONSTANT_STRING_ID:
- return Context.getCFConstantStringDecl();
+ if (Context.CFConstantStringTypeDecl)
+ return Context.CFConstantStringTypeDecl;
+ NewLoaded = Context.getCFConstantStringDecl();
+ break;
case PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID:
- return Context.getCFConstantStringTagDecl();
+ if (Context.CFConstantStringTagDecl)
+ return Context.CFConstantStringTagDecl;
+ NewLoaded = Context.getCFConstantStringTagDecl();
+ break;
case PREDEF_DECL_TYPE_PACK_ELEMENT_ID:
- return Context.getTypePackElementDecl();
+ if (Context.TypePackElementDecl)
+ return Context.TypePackElementDecl;
+ NewLoaded = Context.getTypePackElementDecl();
+ break;
}
- llvm_unreachable("PredefinedDeclIDs unknown enum value");
+
+ assert(NewLoaded && "Failed to load predefined decl?");
+
+ if (DeserializationListener)
+ DeserializationListener->PredefinedDeclBuilt(ID, NewLoaded);
+
+ return NewLoaded;
}
unsigned ASTReader::translateGlobalDeclIDToIndex(GlobalDeclID GlobalID) const {
@@ -7814,7 +7869,7 @@
assert(ContextObj && "reading decl with no AST context");
if (ID < NUM_PREDEF_DECL_IDS) {
- Decl *D = getPredefinedDecl(*ContextObj, (PredefinedDeclIDs)ID);
+ Decl *D = getPredefinedDecl((PredefinedDeclIDs)ID);
if (D) {
// Track that we have merged the declaration with ID \p ID into the
// pre-existing predefined declaration \p D.
diff --git a/contrib/llvm-project/clang/lib/Serialization/ASTWriter.cpp b/contrib/llvm-project/clang/lib/Serialization/ASTWriter.cpp
--- a/contrib/llvm-project/clang/lib/Serialization/ASTWriter.cpp
+++ b/contrib/llvm-project/clang/lib/Serialization/ASTWriter.cpp
@@ -6757,6 +6757,12 @@
StoredIdx = Idx;
}
+void ASTWriter::PredefinedDeclBuilt(PredefinedDeclIDs ID, const Decl *D) {
+ assert(D->isCanonicalDecl() && "predefined decl is not canonical");
+ DeclIDs[D] = LocalDeclID(ID);
+ PredefinedDecls.insert(D);
+}
+
void ASTWriter::SelectorRead(SelectorID ID, Selector S) {
// Always keep the highest ID. See \p TypeRead() for more information.
SelectorID &StoredID = SelectorIDs[S];

File Metadata

Mime Type
text/plain
Expires
Tue, Feb 10, 2:26 AM (11 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28610917
Default Alt Text
D51041.diff (9 KB)

Event Timeline