Fix sign extension handling in DumpEnumValue
authorFrederic Riss <friss@apple.com>
Tue, 8 Oct 2019 17:59:02 +0000 (17:59 +0000)
committerFrederic Riss <friss@apple.com>
Tue, 8 Oct 2019 17:59:02 +0000 (17:59 +0000)
When an enumerator has an unsigned type and its high bit set, the
code introduced in r374067 would fail to match it due to a sign
extension snafu. This commit fixes this aspec of the code and should
fix the bots.

I think it's not a complete fix though, I'll add more test coverage
and additional tweaks in a follow-up commit.

llvm-svn: 374095

lldb/source/Symbol/ClangASTContext.cpp

index 6b82831..038b1f3 100644 (file)
@@ -9374,6 +9374,7 @@ static bool DumpEnumValue(const clang::QualType &qual_type, Stream *s,
   // flags.
   for (auto enumerator : enum_decl->enumerators()) {
     uint64_t val = enumerator->getInitVal().getSExtValue();
+    val = llvm::SignExtend64(val, 8*byte_size);
     if (llvm::countPopulation(val) != 1 && (val & ~covered_bits) != 0)
       can_be_bitfield = false;
     covered_bits |= val;