]> granicus.if.org Git - clang/commitdiff
[libclang] Introduce clang_File_isEqual for comparing CXFile handles.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 16 Aug 2014 00:26:19 +0000 (00:26 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 16 Aug 2014 00:26:19 +0000 (00:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215796 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 8b2d3782d351d611eb285e5dc244820d00befdf6..7b8d4cf934c5d86e791fb1305bf4225e1534fe4e 100644 (file)
@@ -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);
+
 /**
  * @}
  */
index 716f79ac33e2c8b89bc7c62f1cb46be1ced3432b..97a27591cf7b608cae97dcdda1630e8163d581de 100644 (file)
@@ -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"
 
 //===----------------------------------------------------------------------===//
index ad0d585c85074040f50082c0c6f5c562a33415e7..5a029f7e4f939b52ce6f09e18b06805d298b6303 100644 (file)
@@ -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