[PATCH] D36664: [analyzer] Make StmtDataCollector customizable

Johannes Altmanninger via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 16 01:10:34 PDT 2017

johannes added a comment.

In https://reviews.llvm.org/D36664#841758, @teemperor wrote:

> Very well done, I really like this patch! I added a few remarks mostly about the comments that need some small adjusting.
> I'm wondering what would be a nice way of creating a StmtDataCollector that is faster but only works for single translation units (e.g. it only hashes the pointer values of decls instead of their qualified name)? The use case here would be Stmt::Profile and the CloneDetector which could be set to a single-TU-mode in the CloneChecker. For Stmt::Profile it would ensure we don't degrade performance from the current version, for the CloneChecker we probably get a reasonable performance boost (as the hashing is currently the last remaining bottle neck).
> @arphaman Any suggestions who could review/approve the additions to `AST/`?

So we want at least two different modes

- unstable / hash pointer members
- stable / follow pointer members

We can do this by using two macros with different names. So we can split `DEF_ADD_DATA` in something like `COLLECT_DATA_STABLE` and `COLLECT_DATA_UNSTABLE`
Both would share the collection of POD members, so it makes sense to use a third macro for this.

So the code in StmtDataCollectors.inc assumes that DataCollection.h has been included, and that there is a `addData()` function as well as an `ASTContext &Context` in the current scope.
These things should be documented in DataCollection.h I guess.

Since `StmtDataCollectors.inc` resides in `lib` I have to use relative paths (so the include directive looks different depending on the current file), we have to live with this, right?


More information about the cfe-commits mailing list