[Lldb-commits] [PATCH] D31880: Fix libc++ vector<bool> data formatter (bug #32553)

Tamas Berghammer via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 10 11:07:57 PDT 2017


tberghammer added a comment.

The previous version of the data formatter was triggering for std::vector<std::allocator<bool>> as well. Jason, do you know why was it the case? Do we need that functionality because of a broken compiler version or can it be removed?

Note: I added a few comments about the data formatter itself but feel free to ignore them if you want to keep this change small.



================
Comment at: source/Plugins/Language/CPlusPlus/LibCxxVector.cpp:52-53
+  LibcxxVectorBoolSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+  ~LibcxxVectorBoolSyntheticFrontEnd() override = default;
+
----------------
Not needed


================
Comment at: source/Plugins/Language/CPlusPlus/LibCxxVector.cpp:201-228
+  switch (bit_index) {
+  case 0:
+    mask = 1;
+    break;
+  case 1:
+    mask = 2;
+    break;
----------------
This switch seems silly. You can just replace it with "mask = (1 << bit_index)"


================
Comment at: source/Plugins/Language/CPlusPlus/LibCxxVector.cpp:233-234
+  if (bit_set && buffer_sp && buffer_sp->GetBytes())
+    *(buffer_sp->GetBytes()) =
+        1; // regardless of endianness, anything non-zero is true
+  StreamString name;
----------------
I think the formatting here makes the code pretty hard to read


================
Comment at: source/Plugins/Language/CPlusPlus/LibCxxVector.cpp:301-304
+  TypeImpl type = valobj_sp->GetTypeImpl();
+  if (!type.IsValid())
+    return nullptr;
+  CompilerType compiler_type = type.GetCompilerType(false);
----------------
Is there a reason you are not using ValueObject::GetCompilerType()?


https://reviews.llvm.org/D31880





More information about the lldb-commits mailing list