From: Erik Pilkington Date: Tue, 25 Sep 2018 22:53:06 +0000 (+0000) Subject: [Sema] Use a more civilized hash map to implement -Wduplicate-enum. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=70014ee171d0d5d977edeb37aa63f5bbedb67efa;p=clang [Sema] Use a more civilized hash map to implement -Wduplicate-enum. DenseMap used LONG_MAX as a tombstone, so it asserts when you try to insert it! rdar://44774672 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343042 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 763f6ac4d6..d02b971230 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -16402,7 +16402,7 @@ static void CheckForDuplicateEnumValues(Sema &S, ArrayRef Elements, typedef SmallVector, 3> DuplicatesVector; typedef llvm::PointerUnion DeclOrVector; - typedef llvm::DenseMap ValueToVectorMap; + typedef std::unordered_map ValueToVectorMap; // Use int64_t as a key to avoid needing special handling for DenseMap keys. auto EnumConstantToKey = [](const EnumConstantDecl *D) { diff --git a/test/Sema/warn-duplicate-enum.c b/test/Sema/warn-duplicate-enum.c index 84fdeb4f8f..4536d0aced 100644 --- a/test/Sema/warn-duplicate-enum.c +++ b/test/Sema/warn-duplicate-enum.c @@ -1,5 +1,5 @@ // RUN: %clang_cc1 %s -fsyntax-only -verify -Wduplicate-enum -// RUN: %clang_cc1 %s -x c++ -fsyntax-only -verify -Wduplicate-enum +// RUN: %clang_cc1 %s -x c++ -DCPP -fsyntax-only -verify -Wduplicate-enum enum A { A1 = 0, // expected-note {{element 'A1' also has value 0}} A2 = -1, @@ -99,3 +99,11 @@ enum enum1 { enum enum2 { VALUE // expected-error{{redefinition of enumerator 'VALUE'}} }; + +// rdar://44774672 +#ifdef CPP +enum BigEnumerators : long { + e1, + e2 = 9223372036854775807L, +}; +#endif