[Lldb-commits] [PATCH] D67520: Add pretty printing of Clang "bitfield" enums

Frederic Riss via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 7 17:21:41 PDT 2019


friss marked 3 inline comments as done.
friss added a comment.

In D67520#1668494 <https://reviews.llvm.org/D67520#1668494>, @jingham wrote:

> (lldb) expr (enum bitfield) whatever
>
> Be nice to see a test of that to make sure that works through the expression parser as well.


This works now and I added a test for it.



================
Comment at: source/Symbol/ClangASTContext.cpp:9529
+  // in `enum {A, B, ALL = A|B }` we visit ALL first.
+  std::stable_sort(
+      values.begin(), values.end(), [](const auto &a, const auto &b) {
----------------
MaskRay wrote:
> You can simply sort by magnitude and iterating the elements from the largest to the smallest.
After reading your comment, I thought we didn't need any sorting at all given the heuristic above guarantees some ordering in the elements we get here.

The error that ensued from replying the stable_sort by a reverse reminded me why I used a stable_sort in the first place. In the added test, `ac` would be printed `C | A` instead of `A | C`. Granted both of them are correct, but for some reason it bothers me a lot that the elements are not printed in declaration order, so I left the code as-is. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67520/new/

https://reviews.llvm.org/D67520





More information about the lldb-commits mailing list