c++ - How can I get the name of the file I'm currently visiting with Clang? -


When I'm going, we say, a declaration ( Decl in the Clang library), How can I get the name of this file, where is it written DCL ?

is a class, but I can not find any other class, so that I get this file data

You can ask the Source File Manager for FileEntry from SourceManager.

For example, in a Mater Callback:

  Zero MyMatcher :: run (const MatchFinder :: MatchResult and results) {ASTContext * Context = Result.Context; If (Const Deckl * D = Result. Nodes.GetnodeAS  ("MyDisk")) {Sourmemezer & amp; SrcMgr = Reference- & gt; GetSourceManager (); Const. File Entry * Entry = SrcMgr.getFileEntryForID (SrcMgr.getFileID (D.getcaret Location ()); Const char * FileName = Entry-> Getenem (); }}  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -