[cfe-commits] r173559 - [libclang] Introduce clang_getFileUniqueID which returns a struct
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Jan 25 20:52:52 PST 2013
Author: akirtzidis
Date: Fri Jan 25 22:52:52 2013
New Revision: 173559
URL: http://llvm.org/viewvc/llvm-project?rev=173559&view=rev
Log:
[libclang] Introduce clang_getFileUniqueID which returns a struct
for a CXFile containing device/inode/modification time.
Intended to be useful as a key associated with a unique file across
an indexing session.
rdar://13091837
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/libclang.exports
Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=173559&r1=173558&r2=173559&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Fri Jan 25 22:52:52 2013
@@ -32,7 +32,7 @@
* compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
*/
#define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 10
+#define CINDEX_VERSION_MINOR 11
#define CINDEX_VERSION_ENCODE(major, minor) ( \
((major) * 10000) \
@@ -297,6 +297,24 @@ CINDEX_LINKAGE CXString clang_getFileNam
CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
/**
+ * \brief Uniquely identifies a CXFile, that refers to the same underlying file,
+ * across an indexing session.
+ */
+typedef struct {
+ unsigned long long data[3];
+} CXFileUniqueID;
+
+/**
+ * \brief Retrieve the unique ID for the given \c file.
+ *
+ * \param file the file to get the ID for.
+ * \param outID stores the returned CXFileUniqueID.
+ * \returns If there was a failure getting the unique ID, returns non-zero,
+ * otherwise returns 0.
+*/
+CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
+
+/**
* \brief Determine whether the given header is guarded against
* multiple inclusions, either with the conventional
* \#ifndef/\#define/\#endif macro guards or with \#pragma once.
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=173559&r1=173558&r2=173559&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Jan 25 22:52:52 2013
@@ -2960,6 +2960,21 @@ unsigned clang_isFileMultipleIncludeGuar
.isFileMultipleIncludeGuarded(FEnt);
}
+int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID) {
+ if (!file || !outID)
+ return 1;
+
+#ifdef LLVM_ON_WIN32
+ return 1; // inodes not supported on windows.
+#else
+ FileEntry *FEnt = static_cast<FileEntry *>(file);
+ outID->data[0] = FEnt->getDevice();
+ outID->data[1] = FEnt->getInode();
+ outID->data[2] = FEnt->getModificationTime();
+ return 0;
+#endif
+}
+
} // end: extern "C"
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/tools/libclang/libclang.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=173559&r1=173558&r2=173559&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Fri Jan 25 22:52:52 2013
@@ -166,6 +166,7 @@ clang_getFile
clang_getFileLocation
clang_getFileName
clang_getFileTime
+clang_getFileUniqueID
clang_getFunctionTypeCallingConv
clang_getIBOutletCollectionType
clang_getIncludedFile
More information about the cfe-commits
mailing list