[PATCH] Add clang_Location_isFromMainFile() to libclang
Stefanus Du Toit
stefanus.du.toit at intel.com
Wed Aug 7 11:58:31 PDT 2013
Bump the minor version; missed this in the first diff.
Hi doug.gregor,
http://llvm-reviews.chandlerc.com/D1313
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1313?vs=3255&id=3258#toc
Files:
include/clang-c/Index.h
tools/libclang/CXSourceLocation.cpp
Index: include/clang-c/Index.h
===================================================================
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -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 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);
Index: tools/libclang/CXSourceLocation.cpp
===================================================================
--- tools/libclang/CXSourceLocation.cpp
+++ tools/libclang/CXSourceLocation.cpp
@@ -209,6 +209,17 @@
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,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1313.2.patch
Type: text/x-patch
Size: 1613 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130807/f35cbc04/attachment.bin>
More information about the cfe-commits
mailing list