r187994 - Add clang_Location_isFromMainFile() to libclang.

Stefanus Du Toit stefanus.du.toit at intel.com
Thu Aug 8 10:48:14 PDT 2013


Author: sdt
Date: Thu Aug  8 12:48:14 2013
New Revision: 187994

URL: http://llvm.org/viewvc/llvm-project?rev=187994&view=rev
Log:
Add clang_Location_isFromMainFile() to libclang.

Also bump the minor version number and update libclang.exports.

Reviewed by: Dmitri Gribenko, Doug Gregor

Modified:
    cfe/trunk/include/clang-c/Index.h
    cfe/trunk/tools/libclang/CXSourceLocation.cpp
    cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=187994&r1=187993&r2=187994&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Thu Aug  8 12:48:14 2013
@@ -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)                       \
@@ -414,6 +414,12 @@ CINDEX_LINKAGE CXSourceLocation clang_ge
 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.
  */
 CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);

Modified: cfe/trunk/tools/libclang/CXSourceLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXSourceLocation.cpp?rev=187994&r1=187993&r2=187994&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXSourceLocation.cpp (original)
+++ cfe/trunk/tools/libclang/CXSourceLocation.cpp Thu Aug  8 12:48:14 2013
@@ -209,6 +209,17 @@ int clang_Location_isInSystemHeader(CXSo
   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,

Modified: cfe/trunk/tools/libclang/libclang.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=187994&r1=187993&r2=187994&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Thu Aug  8 12:48:14 2013
@@ -255,6 +255,7 @@ clang_isVirtualBase
 clang_isVolatileQualifiedType
 clang_loadDiagnostics
 clang_Location_isInSystemHeader
+clang_Location_isFromMainFile
 clang_parseTranslationUnit
 clang_remap_dispose
 clang_remap_getFilenames





More information about the cfe-commits mailing list