]> granicus.if.org Git - clang/commitdiff
Add libclang function 'clang_isFromMainFile()' (which just wraps SourceManager::isFro...
authorTed Kremenek <kremenek@apple.com>
Thu, 20 May 2010 02:59:19 +0000 (02:59 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 20 May 2010 02:59:19 +0000 (02:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104208 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 663737a0f36b3b04f022a5200e82ee194c5ba975..5fd5cbd1f0a4e21e1ebe8eccba47eba7203565b9 100644 (file)
@@ -342,6 +342,12 @@ CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
  */
 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);
+
 /**
  * @}
  */
index 945d05bf23e0e74353199fe5648ca4a8180a6255..d0773565a9539637ec9ee1264f9ae20a7f760fb3 100644 (file)
@@ -1479,6 +1479,13 @@ CXSourceLocation clang_getRangeEnd(CXSourceRange range) {
   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"
 
 //===----------------------------------------------------------------------===//
index 4b61bd34cbd392c8dbb7936cacc8276be0245ec4..59888f173b004138e18d4fea467e8e4ce777b356 100644 (file)
@@ -77,6 +77,7 @@ _clang_getTypeKindSpelling
 _clang_isCursorDefinition
 _clang_isDeclaration
 _clang_isExpression
+_clang_isFromMainFile
 _clang_isInvalid
 _clang_isPreprocessing
 _clang_isReference
index 744ba71436084e240b3fcf511a332c2828deb070..12062470f22de66431429f91e7defe03f6963b3c 100644 (file)
@@ -77,6 +77,7 @@ clang_getTypeKindSpelling
 clang_isCursorDefinition
 clang_isDeclaration
 clang_isExpression
+clang_isFromMainFile
 clang_isInvalid
 clang_isPreprocessing
 clang_isReference