[clang-tools-extra] [clang-doc] Improve performance by adding a short circuit (PR #96809)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 10 23:35:05 PDT 2024
PeterChou1 wrote:
I did some more investigating and ran this patch against several different projects like llvm itself, and other well know libraries like zlib. The only functional difference I found was differences in the USR generated and generation order in the table genned files
The one exceptions to this is we accidently overlooked anonymous typedef like
```
typedef struct {} Foo;
```
This causes the recursiveASTVisitor to visit the declaration once as a typedef and another time as a record. Originally we had the following [code](https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-doc/Serialize.cpp#L777) which guards against emitting duplicate code when visiting an anonmymous typedef.
This patch breaks from the previous behaviour since once we have visit the anonymous typedef we add the typedef to the memoization list but the guard prevents it from getting serialized. And next time we visit it as a record the USR is already in the list which causes clang-doc to skip it again, leaving nothing to be emitted.
To prevent this I added a check for if a decl is an anonymous typedef and cause it to always process the decl regardless or not if its in the memoization list
https://github.com/llvm/llvm-project/pull/96809
More information about the cfe-commits
mailing list