[cfe-commits] r104208 - in /cfe/trunk: include/clang-c/Index.h tools/libclang/CIndex.cpp tools/libclang/libclang.darwin.exports tools/libclang/libclang.exports
Ted Kremenek
kremenek at apple.com
Wed May 19 19:59:19 PDT 2010
Author: kremenek
Date: Wed May 19 21:59:19 2010
New Revision: 104208
URL: http://llvm.org/viewvc/llvm-project?rev=104208&view=rev
Log:
Add libclang function 'clang_isFromMainFile()' (which just wraps SourceManager::isFromMainFile()).
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/libclang.darwin.exports
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=104208&r1=104207&r2=104208&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed May 19 21:59:19 2010
@@ -343,6 +343,12 @@
CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
/**
+ * \brief Determine if the source location occurs within the main file
+ * of the translation unit (as opposed to an included header).
+ */
+CINDEX_LINKAGE unsigned clang_isFromMainFile(CXSourceLocation loc);
+
+/**
* @}
*/
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=104208&r1=104207&r2=104208&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed May 19 21:59:19 2010
@@ -1479,6 +1479,13 @@
return Result;
}
+unsigned clang_isFromMainFile(CXSourceLocation loc) {
+ SourceLocation Loc = SourceLocation::getFromRawEncoding(loc.int_data);
+ const SourceManager &SM =
+ *static_cast<const SourceManager*>(loc.ptr_data[0]);
+ return SM.isFromMainFile(Loc) ? 1 : 0;
+}
+
} // end: extern "C"
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/tools/libclang/libclang.darwin.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.darwin.exports?rev=104208&r1=104207&r2=104208&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.darwin.exports (original)
+++ cfe/trunk/tools/libclang/libclang.darwin.exports Wed May 19 21:59:19 2010
@@ -77,6 +77,7 @@
_clang_isCursorDefinition
_clang_isDeclaration
_clang_isExpression
+_clang_isFromMainFile
_clang_isInvalid
_clang_isPreprocessing
_clang_isReference
Modified: cfe/trunk/tools/libclang/libclang.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=104208&r1=104207&r2=104208&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Wed May 19 21:59:19 2010
@@ -77,6 +77,7 @@
clang_isCursorDefinition
clang_isDeclaration
clang_isExpression
+clang_isFromMainFile
clang_isInvalid
clang_isPreprocessing
clang_isReference
More information about the cfe-commits
mailing list