[cfe-dev] determining Decl's source

Craig Silverstein csilvers at google.com
Tue Jul 19 17:03:48 PDT 2011


} Some one in IRC mentioned using SourceManager to check the file it
} is in it

Yes, that's the right approach.

} looks like I would have todo something like
} Decl::getLocation()
} dyn_cast to a FullSourceLoc and use FullSourceLoc::getFileID()
} SourceManager::getFileEntryForID()
} FileEntry::getName()

You don't want to dyn_cast.  You want to create a FullSourceLocation
using a SourceLocation and a SourceManager.

Look at
   http://code.google.com/p/include-what-you-use/source/browse/trunk/iwyu_location_util.h

to see how we do this in include-what-you-use.

craig



More information about the cfe-dev mailing list