[cfe-dev] Quick question: how to check that Decl belongs to included file

Keane, Erich via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 27 08:38:27 PST 2019


If you have access to the SourceManager (ASTContext has a reference to it), you can check whether it is the 'main file': 
https://clang.llvm.org/doxygen/classclang_1_1SourceManager.html

check isInMainFile to make sure it isn't in the original .c/.cpp/.whatever file.  You can also check whether it is in a system header or in the 'builtin' 'file'.

Anything that isn't in the Main or 'builtin' files I would expect to have come in via a module import or #include.

-----Original Message-----
From: cfe-dev <cfe-dev-bounces at lists.llvm.org> On Behalf Of via cfe-dev
Sent: Wednesday, November 27, 2019 8:31 AM
To: Clang Dev <cfe-dev at lists.llvm.org>
Cc: Stepan Dyatkovskiy <stepan at dyatkovskiy.com>
Subject: [cfe-dev] Quick question: how to check that Decl belongs to included file

Hi folks! I'm currently trying to check whether declaration belongs to included file by #include directive.

I'm currently about to call Decl::getLocation() and run through bunch of checks with FileID and MacroID. But perhaps there is exist similar function or method?

Thanks!
-Stepan
_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


More information about the cfe-dev mailing list