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

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -