]> granicus.if.org Git - clang/commitdiff
[libclang] Introduce clang_Location_isInSystemHeader to check if a location resides...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 12 Apr 2013 17:06:51 +0000 (17:06 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 12 Apr 2013 17:06:51 +0000 (17:06 +0000)
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

include/clang-c/Index.h
tools/libclang/CXSourceLocation.cpp
tools/libclang/libclang.exports

index 42641df110e081be5c88fdc9fe1c0e6e152ec1ac..3da42ab6b548991e71d6b2223b0ad317284f8f19 100644 (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.
  */
index bc8d5751903c92b0ecc9218e654f56a9fd182c4a..b7c7622c66b213dc5d14c29f3a23a00fe96695df 100644 (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,
index 1f179f13bd8f06680c652d0e6d7e0c5e15f4c2f2..16932a51008c2768d9736df318482d938757ee11 100644 (file)
@@ -248,6 +248,7 @@ clang_isUnexposed
 clang_isVirtualBase
 clang_isVolatileQualifiedType
 clang_loadDiagnostics
+clang_Location_isInSystemHeader
 clang_parseTranslationUnit
 clang_remap_dispose
 clang_remap_getFilenames