================
@@ -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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to