Add libclang function 'clang_isFromMainFile()' (which just wraps SourceManager::isFromMainFile()).

llvm-svn: 104208
This commit is contained in:
Ted Kremenek 2010-05-20 02:59:19 +00:00
parent fe60c14263
commit 76a434840a
4 changed files with 15 additions and 0 deletions

View 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);
/**
* @}
*/

View 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"
//===----------------------------------------------------------------------===//

View File

@ -77,6 +77,7 @@ _clang_getTypeKindSpelling
_clang_isCursorDefinition
_clang_isDeclaration
_clang_isExpression
_clang_isFromMainFile
_clang_isInvalid
_clang_isPreprocessing
_clang_isReference

View File

@ -77,6 +77,7 @@ clang_getTypeKindSpelling
clang_isCursorDefinition
clang_isDeclaration
clang_isExpression
clang_isFromMainFile
clang_isInvalid
clang_isPreprocessing
clang_isReference