[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 14 01:46:41 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) {
----------------
ilya-biryukov wrote:

D is never null here, this if seems to be redundant.

Also, should we `assert` that `D != nullptr` when we deserialize `PreferredName`?
If we start deferring more attributes at some point, an assertion like this might not hold up, but it gives a good sanity check for preferred name specifically, because it should always be attached to some declaration.

https://github.com/llvm/llvm-project/pull/122726


More information about the cfe-commits mailing list