From: Argyrios Kyrtzidis Date: Sat, 16 Aug 2014 00:26:19 +0000 (+0000) Subject: [libclang] Introduce clang_File_isEqual for comparing CXFile handles. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2fd1ed46072e6728baefa928c139e7ea556e65f8;p=clang [libclang] Introduce clang_File_isEqual for comparing CXFile handles. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215796 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 8b2d3782d3..7b8d4cf934 100644 --- a/include/clang-c/Index.h +++ b/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 27 +#define CINDEX_VERSION_MINOR 28 #define CINDEX_VERSION_ENCODE(major, minor) ( \ ((major) * 10000) \ @@ -335,6 +335,12 @@ clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file); CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu, const char *file_name); +/** + * \brief Returns non-zero if the \c file1 and \c file2 point to the same file, + * or they are both NULL. + */ +CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2); + /** * @} */ diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 716f79ac33..97a27591cf 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -3283,6 +3283,18 @@ int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID) { return 0; } +int clang_File_isEqual(CXFile file1, CXFile file2) { + if (file1 == file2) + return true; + + if (!file1 || !file2) + return false; + + FileEntry *FEnt1 = static_cast(file1); + FileEntry *FEnt2 = static_cast(file2); + return FEnt1->getUniqueID() == FEnt2->getUniqueID(); +} + } // end: extern "C" //===----------------------------------------------------------------------===// diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports index ad0d585c85..5a029f7e4f 100644 --- a/tools/libclang/libclang.exports +++ b/tools/libclang/libclang.exports @@ -25,6 +25,7 @@ clang_Cursor_isNull clang_Cursor_isObjCOptional clang_Cursor_isVariadic clang_Cursor_getModule +clang_File_isEqual clang_Module_getASTFile clang_Module_getParent clang_Module_getName