Last active
March 28, 2017 20:56
-
-
Save kwk/9326647 to your computer and use it in GitHub Desktop.
Get filename/path of clang::Decl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static const clang::FileEntry * getFileEntryForDecl(const clang::Decl * decl, clang::SourceManager * sourceManager) | |
| { | |
| if (!decl || !sourceManager) { | |
| return 0; | |
| } | |
| clang::SourceLocation sLoc = decl->getLocation(); | |
| clang::FileID fileID = sourceManager->getFileID(sLoc); | |
| return sourceManager->getFileEntryForID(fileID); | |
| } | |
| static const char * getFileNameForDecl(const clang::Decl * decl, clang::SourceManager * sourceManager) | |
| { | |
| const clang::FileEntry * fileEntry = getFileEntryForDecl(decl, sourceManager); | |
| if (!fileEntry) { | |
| return 0; | |
| } | |
| return fileEntry->getName(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment