[cfe-dev] motivations for approaches to macros in Index/IndexingAction.cpp ?

Jan Korous via cfe-dev cfe-dev at lists.llvm.org
Mon May 20 14:31:19 PDT 2019


Hi James,

The current implementation of this hashing function ignores some cases. We're in the process of upstreaming the whole index-while-building feature to LLVM project and decided to fix this by temporarily using trivial implementation - just hashing the full bitcode representation of index record. Eventually we need a new implementation that is both correct and performant - so far the idea was to explore the possibility of using the existing ODR violation hasher for this purpose.

HTH,

Jan

> On May 20, 2019, at 2:08 PM, James Widman <james.widman at gmail.com> wrote:
> 
> [reposting after accidentally sending to the old cfe address]
> 
> Hi all,
> 
> I've been playing with the indexstore API and was a little surprised
> to find that preprocessor macro definitions are apparently not
> considered when generating the hash of a record
> (https://github.com/apple/swift-clang/blob/stable/lib/Index/IndexRecordHasher.h).
> 
> Was this intentional? And if so, what was the motivation?
> 
> I ask because it seems like things are very nearly set up to
> incorporate macro definitions/references in an IndexStore record (and
> to produce both "symbols" and "occurrences" for macro definitions &
> expansions by default when -index-store-path is given to the Clang
> driver).
> 
> Eric Liu introduced some support for indexing macros
> (https://github.com/apple/swift-clang/commit/8576df59f2fe52ae305fdb91b36cbed8946981a1)
> but it doesn't seem to intersect with IndexStore "records", and I'm
> not sure why...
> 
> I guess the idea was that people would only use this via libclang?
> (But in that case my question becomes, "why wouldn't you want to
> capture this as a regular part of a build?")
> 
> Currently, entities from the AST are captured by IndexASTConsumer, an
> instance of which is set up by
> IndexRecordActionBase::createIndexASTConsumer(), and it seems like
> this is the point where there is an opportunity to call
> clang::Preprocessor::addPPCallbacks() with a class that overrides:
> 
> PPCallbacks::MacroExpands()
> PPCallbacks::MacroDefined()
> 
> ... which would then forward macro definition/expansion events to the
> IndexDataRecorder.
> 
> If anyone who has worked in this area could comment, that would be
> most appreciated!
> 
> --James




More information about the cfe-dev mailing list