[PATCH] D118855: [modules] Add a flag for TagDecl if it was a definition demoted to a declaration.
Volodymyr Sapsai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 14 16:05:08 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfa4a0f1d31e2: [modules] Add a flag for TagDecl if it was a definition demoted to a… (authored by vsapsai).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118855/new/
https://reviews.llvm.org/D118855
Files:
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/lib/AST/Decl.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===================================================================
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -773,7 +773,7 @@
}
if (OldDef) {
Reader.MergedDeclContexts.insert(std::make_pair(ED, OldDef));
- ED->setCompleteDefinition(false);
+ ED->demoteThisDefinitionToDeclaration();
Reader.mergeDefinitionVisibility(OldDef, ED);
if (OldDef->getODRHash() != ED->getODRHash())
Reader.PendingEnumOdrMergeFailures[OldDef].push_back(ED);
@@ -828,7 +828,7 @@
}
if (OldDef) {
Reader.MergedDeclContexts.insert(std::make_pair(RD, OldDef));
- RD->setCompleteDefinition(false);
+ RD->demoteThisDefinitionToDeclaration();
Reader.mergeDefinitionVisibility(OldDef, RD);
} else {
OldDef = RD;
Index: clang/lib/AST/Decl.cpp
===================================================================
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -4301,6 +4301,7 @@
setEmbeddedInDeclarator(false);
setFreeStanding(false);
setCompleteDefinitionRequired(false);
+ TagDeclBits.IsThisDeclarationADemotedDefinition = false;
}
SourceLocation TagDecl::getOuterLocStart() const {
Index: clang/include/clang/AST/DeclBase.h
===================================================================
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -1443,10 +1443,14 @@
/// Has the full definition of this type been required by a use somewhere in
/// the TU.
uint64_t IsCompleteDefinitionRequired : 1;
+
+ /// Whether this tag is a definition which was demoted due to
+ /// a module merge.
+ uint64_t IsThisDeclarationADemotedDefinition : 1;
};
/// Number of non-inherited bits in TagDeclBitfields.
- enum { NumTagDeclBits = 9 };
+ enum { NumTagDeclBits = 10 };
/// Stores the bits used by EnumDecl.
/// If modified NumEnumDeclBit and the accessor
Index: clang/include/clang/AST/Decl.h
===================================================================
--- clang/include/clang/AST/Decl.h
+++ clang/include/clang/AST/Decl.h
@@ -3486,6 +3486,24 @@
/// parameters.
bool isDependentType() const { return isDependentContext(); }
+ /// Whether this declaration was a definition in some module but was forced
+ /// to be a declaration.
+ ///
+ /// Useful for clients checking if a module has a definition of a specific
+ /// symbol and not interested in the final AST with deduplicated definitions.
+ bool isThisDeclarationADemotedDefinition() const {
+ return TagDeclBits.IsThisDeclarationADemotedDefinition;
+ }
+
+ /// Mark a definition as a declaration and maintain information it _was_
+ /// a definition.
+ void demoteThisDefinitionToDeclaration() {
+ assert(isCompleteDefinition() &&
+ "Should demote definitions only, not forward declarations");
+ setCompleteDefinition(false);
+ TagDeclBits.IsThisDeclarationADemotedDefinition = true;
+ }
+
/// Starts the definition of this tag declaration.
///
/// This method should be invoked at the beginning of the definition
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118855.408663.patch
Type: text/x-patch
Size: 3173 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220215/453c56b4/attachment.bin>
More information about the cfe-commits
mailing list