]> granicus.if.org Git - clang/commitdiff
Add clang_Location_isFromMainFile() to libclang.
authorStefanus Du Toit <stefanus.du.toit@intel.com>
Thu, 8 Aug 2013 17:48:14 +0000 (17:48 +0000)
committerStefanus Du Toit <stefanus.du.toit@intel.com>
Thu, 8 Aug 2013 17:48:14 +0000 (17:48 +0000)
Also bump the minor version number and update libclang.exports.

Reviewed by: Dmitri Gribenko, Doug Gregor

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187994 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 1adaa4861582dd3d15ce68f7961b580246f268d4..51b1a8c2eef84b2079fa9522e64c65b7da1cb56e 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 19
+#define CINDEX_VERSION_MINOR 20
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
       ((major) * 10000)                       \
@@ -413,6 +413,12 @@ CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
  */
 CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
 
+/**
+ * \brief Returns non-zero if the given source location is in the main file of
+ * the corresponding translation unit.
+ */
+CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
+
 /**
  * \brief Retrieve a NULL (invalid) source range.
  */
index b7c7622c66b213dc5d14c29f3a23a00fe96695df..71e425d1f7f38bd7bbd6a167350a7c64e1e5e5e7 100644 (file)
@@ -209,6 +209,17 @@ int clang_Location_isInSystemHeader(CXSourceLocation location) {
   return SM.isInSystemHeader(Loc);
 }
 
+int clang_Location_isFromMainFile(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.isFromMainFile(Loc);
+}
+
 void clang_getExpansionLocation(CXSourceLocation location,
                                 CXFile *file,
                                 unsigned *line,
index 037f26fcc0d779a6aa4c48c950b18a779cbc7796..92b060a1692f59f3d42812170dd8721759dd61e5 100644 (file)
@@ -255,6 +255,7 @@ clang_isVirtualBase
 clang_isVolatileQualifiedType
 clang_loadDiagnostics
 clang_Location_isInSystemHeader
+clang_Location_isFromMainFile
 clang_parseTranslationUnit
 clang_remap_dispose
 clang_remap_getFilenames