================ @@ -3159,13 +3164,36 @@ Attr *ASTRecordReader::readAttr() { return New; } -/// Reads attributes from the current stream position. -void ASTRecordReader::readAttributes(AttrVec &Attrs) { +/// Reads attributes from the current stream position, advancing Idx. +/// For some attributes (where type depends on itself recursively), defer +/// reading the attribute until the type has been read. +void ASTRecordReader::readAttributes(AttrVec &Attrs, Decl *D) { for (unsigned I = 0, E = readInt(); I != E; ++I) - if (auto *A = readAttr()) + if (auto *A = readOrDeferAttrFor(D)) Attrs.push_back(A); } + +/// Reads one attribute from the current stream position, advancing Idx. +/// For some attributes (where type depends on itself recursively), defer +/// reading the attribute until the type has been read. +Attr *ASTRecordReader::readOrDeferAttrFor(Decl *D) { + AttrReader Record(*this); + unsigned SkipCount = Record.readInt(); + if (!SkipCount) + return readAttr(); ---------------- ChuanqiXu9 wrote:
Now it assumes that `readAttr()` should be called after the skip bit. Then the caller has more responsibility. I feel it better to skip it in `readAttr` and not read here. e.g., ```suggestion unsigned SkipCount = Record.peekInt(); if (!SkipCount) return readAttr(); ``` 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