From: Argyrios Kyrtzidis Date: Tue, 15 Oct 2013 17:37:55 +0000 (+0000) Subject: [libclang] For an unscoped enum include the enumerators in the top-level code-complet... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e96a7b4d99e8737b1dc8a3bd07038f885bc4263b;p=clang [libclang] For an unscoped enum include the enumerators in the top-level code-completion hash since they enter the top-level namespace. rdar://14703327 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192720 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index e2641ccec4..610c20d9fb 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -877,6 +877,18 @@ void AddTopLevelDeclarationToHash(Decl *D, unsigned &Hash) { return; if (NamedDecl *ND = dyn_cast(D)) { + if (EnumDecl *EnumD = dyn_cast(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()) {