r192720 - [libclang] For an unscoped enum include the enumerators in the top-level code-completion hash since they enter the top-level namespace.

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Oct 15 10:37:55 PDT 2013


Author: akirtzidis
Date: Tue Oct 15 12:37:55 2013
New Revision: 192720

URL: http://llvm.org/viewvc/llvm-project?rev=192720&view=rev
Log:
[libclang] For an unscoped enum include the enumerators in the top-level code-completion hash since they enter the top-level namespace.

rdar://14703327

Modified:
    cfe/trunk/lib/Frontend/ASTUnit.cpp

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=192720&r1=192719&r2=192720&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Tue Oct 15 12:37:55 2013
@@ -877,6 +877,18 @@ void AddTopLevelDeclarationToHash(Decl *
     return;
 
   if (NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
+    if (EnumDecl *EnumD = dyn_cast<EnumDecl>(D)) {
+      // For an unscoped enum include the enumerators in the hash since they
+      // enter the top-level namespace.
+      if (!EnumD->isScoped()) {
+        for (EnumDecl::enumerator_iterator EI = EnumD->enumerator_begin(),
+               EE = EnumD->enumerator_end(); EI != EE; ++EI) {
+          if ((*EI)->getIdentifier())
+            Hash = llvm::HashString((*EI)->getIdentifier()->getName(), Hash);
+        }
+      }
+    }
+
     if (ND->getIdentifier())
       Hash = llvm::HashString(ND->getIdentifier()->getName(), Hash);
     else if (DeclarationName Name = ND->getDeclName()) {





More information about the cfe-commits mailing list