diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:17:04 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:17:04 +0000 |
| commit | b915e9e0fc85ba6f398b3fab0db6a81a8913af94 (patch) | |
| tree | 98b8f811c7aff2547cab8642daf372d6c59502fb /lib/Support/FoldingSet.cpp | |
| parent | 6421cca32f69ac849537a3cff78c352195e99f1b (diff) | |
Notes
Diffstat (limited to 'lib/Support/FoldingSet.cpp')
| -rw-r--r-- | lib/Support/FoldingSet.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Support/FoldingSet.cpp b/lib/Support/FoldingSet.cpp index 52baf865d83ef..c9bca7f4c1ab7 100644 --- a/lib/Support/FoldingSet.cpp +++ b/lib/Support/FoldingSet.cpp @@ -54,8 +54,9 @@ void FoldingSetNodeID::AddPointer(const void *Ptr) { // depend on the host. It doesn't matter, however, because hashing on // pointer values is inherently unstable. Nothing should depend on the // ordering of nodes in the folding set. - Bits.append(reinterpret_cast<unsigned *>(&Ptr), - reinterpret_cast<unsigned *>(&Ptr+1)); + static_assert(sizeof(uintptr_t) <= sizeof(unsigned long long), + "unexpected pointer size"); + AddInteger(reinterpret_cast<uintptr_t>(Ptr)); } void FoldingSetNodeID::AddInteger(signed I) { Bits.push_back(I); @@ -80,8 +81,7 @@ void FoldingSetNodeID::AddInteger(long long I) { } void FoldingSetNodeID::AddInteger(unsigned long long I) { AddInteger(unsigned(I)); - if ((uint64_t)(unsigned)I != I) - Bits.push_back(unsigned(I >> 32)); + AddInteger(unsigned(I >> 32)); } void FoldingSetNodeID::AddString(StringRef String) { @@ -127,8 +127,8 @@ void FoldingSetNodeID::AddString(StringRef String) { // Pos will have overshot size by 4 - #bytes left over. // No need to take endianness into account here - this is always executed. switch (Pos - Size) { - case 1: V = (V << 8) | (unsigned char)String[Size - 3]; // Fall thru. - case 2: V = (V << 8) | (unsigned char)String[Size - 2]; // Fall thru. + case 1: V = (V << 8) | (unsigned char)String[Size - 3]; LLVM_FALLTHROUGH; + case 2: V = (V << 8) | (unsigned char)String[Size - 2]; LLVM_FALLTHROUGH; case 3: V = (V << 8) | (unsigned char)String[Size - 1]; break; default: return; // Nothing left. } |
