[llvm-branch-commits] [cfe-branch] r120663 - in /cfe/branches/Apple/whitney: include/clang-c/Index.h tools/libclang/CIndex.cpp tools/libclang/libclang.darwin.exports tools/libclang/libclang.exports

Daniel Dunbar daniel at zuster.org
Wed Dec 1 18:52:09 PST 2010


Author: ddunbar
Date: Wed Dec  1 20:52:08 2010
New Revision: 120663

URL: http://llvm.org/viewvc/llvm-project?rev=120663&view=rev
Log:
Merge r119876:
--
Author: Douglas Gregor <dgregor at apple.com>
Date:   Sat Nov 20 00:09:34 2010 +0000

    Implement a simple hash function for libclang cursors

Modified:
    cfe/branches/Apple/whitney/include/clang-c/Index.h
    cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
    cfe/branches/Apple/whitney/tools/libclang/libclang.darwin.exports
    cfe/branches/Apple/whitney/tools/libclang/libclang.exports

Modified: cfe/branches/Apple/whitney/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/include/clang-c/Index.h?rev=120663&r1=120662&r2=120663&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/include/clang-c/Index.h (original)
+++ cfe/branches/Apple/whitney/include/clang-c/Index.h Wed Dec  1 20:52:08 2010
@@ -1347,6 +1347,11 @@
 CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
 
 /**
+ * \brief Compute a hash value for the given cursor.
+ */
+CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
+  
+/**
  * \brief Retrieve the kind of the given cursor.
  */
 CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);

Modified: cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp?rev=120663&r1=120662&r2=120663&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp Wed Dec  1 20:52:08 2010
@@ -3137,6 +3137,15 @@
   return X == Y;
 }
 
+unsigned clang_hashCursor(CXCursor C) {
+  unsigned Index = 0;
+  if (clang_isExpression(C.kind) || clang_isStatement(C.kind))
+    Index = 1;
+  
+  return llvm::DenseMapInfo<std::pair<unsigned, void*> >::getHashValue(
+                                        std::make_pair(C.kind, C.data[Index]));
+}
+
 unsigned clang_isInvalid(enum CXCursorKind K) {
   return K >= CXCursor_FirstInvalid && K <= CXCursor_LastInvalid;
 }

Modified: cfe/branches/Apple/whitney/tools/libclang/libclang.darwin.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/tools/libclang/libclang.darwin.exports?rev=120663&r1=120662&r2=120663&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/tools/libclang/libclang.darwin.exports (original)
+++ cfe/branches/Apple/whitney/tools/libclang/libclang.darwin.exports Wed Dec  1 20:52:08 2010
@@ -102,6 +102,7 @@
 _clang_getTranslationUnitSpelling
 _clang_getTypeDeclaration
 _clang_getTypeKindSpelling
+_clang_hashCursor
 _clang_isCursorDefinition
 _clang_isDeclaration
 _clang_isExpression

Modified: cfe/branches/Apple/whitney/tools/libclang/libclang.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/tools/libclang/libclang.exports?rev=120663&r1=120662&r2=120663&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/tools/libclang/libclang.exports (original)
+++ cfe/branches/Apple/whitney/tools/libclang/libclang.exports Wed Dec  1 20:52:08 2010
@@ -102,6 +102,7 @@
 clang_getTranslationUnitSpelling
 clang_getTypeDeclaration
 clang_getTypeKindSpelling
+clang_hashCursor
 clang_isCursorDefinition
 clang_isDeclaration
 clang_isExpression





More information about the llvm-branch-commits mailing list