diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index e2641ccec4a7..610c20d9fb14 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/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()) {