]> granicus.if.org Git - clang/commitdiff
[libclang] For an unscoped enum include the enumerators in the top-level code-complet...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 15 Oct 2013 17:37:55 +0000 (17:37 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 15 Oct 2013 17:37:55 +0000 (17:37 +0000)
rdar://14703327

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192720 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/ASTUnit.cpp

index e2641ccec4a7970142d0a9ea23dcab9b3e9357e1..610c20d9fb14f3c8bef8a568aa3490f545958cc7 100644 (file)
@@ -877,6 +877,18 @@ void AddTopLevelDeclarationToHash(Decl *D, unsigned &Hash) {
     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()) {