VitaNuo wrote:

Thank you for the review @ChuanqiXu9!

> (1) Hardcoding is generally not good. And even if we have to, e.g., (we don't 
> have an automatic mechanism to check if we need to defer an attribute), let's 
> avoid hardcoding in both reader side and writer side. We can make this by 
> adding a new bit in the record of attribute to indicate if we need to delay 
> it or not in the reader side generally.

Added a `DeferDeserialization` bit to `Attr` class that is set to `true` for 
the `preferred_name` and to `false` for all other attributes.
Depending on this field, the skip count field is set on the record (to the 
count of record fields to skip on initial read for the `preferred_name`, and to 
0 otherwise).

> (2) Then I think we can keep the signature of readAttr as is, where it will 
> always skip the check for the delay bit and always try to read it. Then we 
> can add a readOrDeferFor(Decl *D) method as you did. The readOrDeferFor will 
> try to read the deferring bits directly and if it is true, it will record the 
> length skipCount and D to PendingDeferredAttributes . Otherwise, it will call 
> readAttr. I think it is more clear.

Yes this makes sense. It seems like one field (skip count) should be enough. 

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