[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!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179384 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CXSourceLocation.cpp b/tools/libclang/CXSourceLocation.cpp
index bc8d575..b7c7622 100644
--- a/tools/libclang/CXSourceLocation.cpp
+++ b/tools/libclang/CXSourceLocation.cpp
@@ -198,6 +198,17 @@
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,