[cfe-dev] Obtaining file name for functions from included files

Felix Schmitt felix.schmitt at zih.tu-dresden.de
Wed Jun 20 03:42:14 PDT 2012


Jacob Carlborg <doob at ...> writes:

> 
> I'm using the following functions from the C bindings:
> 
> * clang_getCursorLocation
> * clang_getSpellingLocation
> * clang_getFileName
> 
> May you could have a look at the implementation of 
those functions if no 
> one else has a quicker solution.
> 

This helped, thx. I'am now using the following code:

SourceLocation loc = srcMgr.getFileLoc(decl->getLocation());
std::pair<FileID, unsigned> loc_info = 
  srcMgr.getDecomposedLoc(loc);
FileID file_id = loc_info.first;

const FileEntry* file_entry = 
  srcMgr.getFileEntryForID(file_id);

Regards,
Felix





More information about the cfe-dev mailing list