[clang] [clang][ast]: Add DynamicAllocLValue and TypeInfoLValue support to APValue::dump(). (PR #135178)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 11 08:17:00 PDT 2025
YLChenZ wrote:
> Would be good to print more information about them.
@tbaederr It seems to only dump their type, like this:
```cpp
case APValue::LValue: {
(void)Context;
OS << "LValue Base=";
APValue::LValueBase B = Value.getLValueBase();
...
} else if (B.is<TypeInfoLValue>()) {
OS << "TypeInfoLValue";
const auto BTI = B.get<TypeInfoLValue>();
BTI.print(OS, PrintPolicy);
} else if (B.is<DynamicAllocLValue>()) {
OS << "DynamicAllocLValue";
auto BDA = B.getDynamicAllocType();
dumpType(BDA);
}
```
```cpp
//test.cpp
#include <typeinfo>
constexpr const std::type_info* val = &typeid(int);
```
```
lambda at ubuntu22:~/test$ clang++ -std=c++20 -Xclang -ast-dump -fsyntax-only test.cpp
LValue Base=TypeInfoLValue typeid(int), Null=0, Offset=0, HasPath=1, PathLength=0, Path=()
```
```cpp
//DAtest.cpp
constexpr int *m = new int(42);
```
```
lambda at ubuntu22:~/test$ clang++ -std=c++20 -Xclang -ast-dump -fsyntax-only DAtest.cpp
LValue Base=DynamicAllocLValue 'int', Null=0, Offset=0, HasPath=1, PathLength=0, Path=()
```
https://github.com/llvm/llvm-project/pull/135178
More information about the cfe-commits
mailing list