Depends on: * https://github.com/llvm/llvm-project/pull/173238 (only last commit relevant for review) This patch revives the `llvm::PointerIntPair` LLDB data-formatter. The previous version was commented out because it relied on expression evaluation and was hence slow/brittle. The formatter in this PR doesn't rely on evaluating expressions. Drive-by change: * removes the `llvm::PointerUnion` formatter which was also commented out. A future version of it will look very different than it does now, so there's no point in keeping it because the diff won't be helpful in a review.
31 lines
577 B
C++
31 lines
577 B
C++
#include "llvm/ADT/PointerIntPair.h"
|
|
|
|
int main() {
|
|
float a = 5;
|
|
llvm::PointerIntPair<float *, 1, bool> float_pair(&a, true);
|
|
llvm::PointerIntPair<void *, 1, bool> void_pair(&a, false);
|
|
llvm::PointerIntPair<llvm::PointerIntPair<void *, 1, bool>, 1, bool> nested(
|
|
void_pair, true);
|
|
|
|
struct S {
|
|
int i;
|
|
};
|
|
S s;
|
|
|
|
enum class E : unsigned {
|
|
Case1,
|
|
Case2,
|
|
Case3,
|
|
Case4,
|
|
};
|
|
llvm::PointerIntPair<S *, 2, E> enum_pair(&s, E::Case2);
|
|
|
|
S s2;
|
|
|
|
__builtin_debugtrap();
|
|
|
|
enum_pair.setPointerAndInt(&s2, E::Case3);
|
|
|
|
__builtin_debugtrap();
|
|
}
|