[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
Viktoriia Bakalova via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 14 04:46:19 PST 2025
================
@@ -3134,6 +3139,17 @@ Attr *ASTRecordReader::readAttr() {
// Kind is stored as a 1-based integer because 0 is used to indicate a null
// Attr pointer.
auto Kind = static_cast<attr::Kind>(V - 1);
+ if (Kind == attr::PreferredName && D != nullptr) {
+ if (D != nullptr) {
----------------
VitaNuo wrote:
> D is never null here, this if seems to be redundant.
This is actually not true. This is a trick that allows to send deserialization on two different paths when (1) deserializing the decl in the main deserialization round vs. (2) deserializing the pending attribute.
In (1) Decl is not null, and the attribute is deferred (and the Decl stored in the pending attributes structure), whereas in (2) the deserialization of the attribute has been initiated by processing the pending attributes, and we don't want to send it on a circle by deferring it again, so we set the Decl to `nullptr` in this call `readOrDeferAttrImpl`.
https://github.com/llvm/llvm-project/pull/122726
More information about the cfe-commits
mailing list