[llvm-dev] clang_indexTranslationUnit and macro expansions

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] clang_indexTranslationUnit and macro expansions

Manas via cfe-dev

Hi!


First of all, thank you for all the work on LLVM. I've been playing with libclang for a while and it's been an enjoyable experience.


I'm using libclang to build cross-references for a C++ codebase. I use the `clang_indexTranslationUnit` API, which works very well, but unfortunately

reports declarations and references that are coming from macro expansions.


Now, declarations and references from macro expansions don't really have locations in source code, so I'd love to ignore them.


My questions are:

- Is there a way to detect declarations and references from macro expansions?

- If not, shall I switch to `clang_visitChildren` API instead?

- Alternatively, would it be a good idea for me to try contributing a new `CXIndexOpt_IgnoreMacroExpansions` option to the API?


Thanks,

Andrey

P.S. I tried writing to [hidden email], but was advised to write here instead. Please let me know if this is not the best list for this type of question.


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] clang_indexTranslationUnit and macro expansions

Manas via cfe-dev
Follow-up question: is it even recommended to use Indexing API? (`clang_indexTranslationUnit` and friends)
Other projects I looked into (e.g. rtags: https://github.com/Andersbakken/rtags) don't use it and rely solely on low-level AST traversal
with `clang_visitChildren`.




On Wed, Sep 30, 2020 at 8:15 AM Andrey Lushnikov <[hidden email]> wrote:

Hi!


First of all, thank you for all the work on LLVM. I've been playing with libclang for a while and it's been an enjoyable experience.


I'm using libclang to build cross-references for a C++ codebase. I use the `clang_indexTranslationUnit` API, which works very well, but unfortunately

reports declarations and references that are coming from macro expansions.


Now, declarations and references from macro expansions don't really have locations in source code, so I'd love to ignore them.


My questions are:

- Is there a way to detect declarations and references from macro expansions?

- If not, shall I switch to `clang_visitChildren` API instead?

- Alternatively, would it be a good idea for me to try contributing a new `CXIndexOpt_IgnoreMacroExpansions` option to the API?


Thanks,

Andrey

P.S. I tried writing to [hidden email], but was advised to write here instead. Please let me know if this is not the best list for this type of question.


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev