juliehockett added a comment.
In https://reviews.llvm.org/D41102#1028228, @Athosvk wrote:
> This seems like quite a decent approach! That being said, I don't see the
> pointer yet? I assume you mean that you will be adding this? Additionally, a
> slight disadvantage of doing this generic approach is that you need to do
> bookkeeping on what it is referencing, but I guess there's no helping that
> due to the architecture which makes you rely upon the USR? Personally I'd
> prefer having the explicit types if and where possible. So for now a
> RecordInfo has a vecotr of Reference's to its parents, but we know the
> parents can only be of certain kinds (more than just a RecordType, but you
> get the point); it won't be an enum, namespace or function.
If you take a look at the follow-on patch to this (D43341
<https://reviews.llvm.org/D43341>), you'll see that that is where the pointer
is added in (since it is irrelevant to the mapper portion, as it cannot be
filled out until the information has been reduced). The back references to
children and whatnot are also added there.
> As I mentioned, we did this the other way around, which also has the slight
> advantage that I only had to create and save the USR once per info instance
> (as in, 10 references to a class only add the overhead of 10 pointers, rather
> than each having the USR as well), but our disadvantage was of course that we
> had delayed serialization (although we could arguably do both
> simultaneously). It seems each method has its merits :).
The USRs are kept for serialization purposes -- given the modular nature of the
design, the goal is to be able to write out the bitstream and have it be
consumable with all necessary information. Since we can't write out pointers
(and it would be useless if we did, since they would change as soon as the file
was read in), we maintain the USRs to have a means of re-finding the referenced
That said, I was looking at the Clangd symbol indexing code yesterday, and
noticed that they're hashing the USRs (since they get a little lengthy,
particularly when you have nested and/or overloaded functions). I'm going to
take a look at that today to try to make the USRs more space-efficient here.
cfe-commits mailing list