r179384 - [libclang] Introduce clang_Location_isInSystemHeader to check if a location resides in a system header.
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Apr 12 10:06:51 PDT 2013
Author: akirtzidis
Date: Fri Apr 12 12:06:51 2013
New Revision: 179384
URL: http://llvm.org/viewvc/llvm-project?rev=179384&view=rev
Log:
[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!
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=179384&r1=179383&r2=179384&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Fri Apr 12 12:06:51 2013
@@ -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) \
@@ -409,6 +409,11 @@ CINDEX_LINKAGE CXSourceLocation clang_ge
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.
*/
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=179384&r1=179383&r2=179384&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXSourceLocation.cpp (original)
+++ cfe/trunk/tools/libclang/CXSourceLocation.cpp Fri Apr 12 12:06:51 2013
@@ -198,6 +198,17 @@ static void createNullLocation(CXString
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,
Modified: cfe/trunk/tools/libclang/libclang.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=179384&r1=179383&r2=179384&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Fri Apr 12 12:06:51 2013
@@ -248,6 +248,7 @@ clang_isUnexposed
clang_isVirtualBase
clang_isVolatileQualifiedType
clang_loadDiagnostics
+clang_Location_isInSystemHeader
clang_parseTranslationUnit
clang_remap_dispose
clang_remap_getFilenames
More information about the cfe-commits
mailing list