[libclang] Introduce clang_Location_isInSystemHeader to check if a location resides in a system header.

This is a modified patch provided from Mikołaj Siedlarek!

llvm-svn: 179384
This commit is contained in:
Argyrios Kyrtzidis 2013-04-12 17:06:51 +00:00
parent ff10ed1706
commit 25f7af1aeb
3 changed files with 18 additions and 1 deletions

View File

@ -32,7 +32,7 @@
* compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
*/
#define CINDEX_VERSION_MAJOR 0
#define CINDEX_VERSION_MINOR 16
#define CINDEX_VERSION_MINOR 17
#define CINDEX_VERSION_ENCODE(major, minor) ( \
((major) * 10000) \
@ -408,6 +408,11 @@ CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
CXFile file,
unsigned offset);
/**
* \brief Returns non-zero if the given source location is in a system header.
*/
CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
/**
* \brief Retrieve a NULL (invalid) source range.
*/

View File

@ -198,6 +198,17 @@ static void createNullLocation(CXString *filename, unsigned *line,
extern "C" {
int clang_Location_isInSystemHeader(CXSourceLocation location) {
const SourceLocation Loc =
SourceLocation::getFromRawEncoding(location.int_data);
if (Loc.isInvalid())
return 0;
const SourceManager &SM =
*static_cast<const SourceManager*>(location.ptr_data[0]);
return SM.isInSystemHeader(Loc);
}
void clang_getExpansionLocation(CXSourceLocation location,
CXFile *file,
unsigned *line,

View File

@ -248,6 +248,7 @@ clang_isUnexposed
clang_isVirtualBase
clang_isVolatileQualifiedType
clang_loadDiagnostics
clang_Location_isInSystemHeader
clang_parseTranslationUnit
clang_remap_dispose
clang_remap_getFilenames