diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 8b2d3782d351d611eb285e5dc244820d00befdf6..7b8d4cf934c5d86e791fb1305bf4225e1534fe4e 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 716f79ac33e2c8b89bc7c62f1cb46be1ced3432b..97a27591cf7b608cae97dcdda1630e8163d581de 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<FileEntry *>(file1); + FileEntry *FEnt2 = static_cast<FileEntry *>(file2); + return FEnt1->getUniqueID() == FEnt2->getUniqueID(); +} + } // end: extern "C" //===----------------------------------------------------------------------===// diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports index ad0d585c85074040f50082c0c6f5c562a33415e7..5a029f7e4f939b52ce6f09e18b06805d298b6303 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