[PATCH] D122662: [Clang][CodeGen] Add constant array support for __builtin_dump_sturct, and beautify dump format
Wang Yihan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 29 08:44:55 PDT 2022
yihanaa created this revision.
yihanaa added reviewers: erichkeane, aaron.ballman.
yihanaa added projects: LLVM, clang.
Herald added a project: All.
yihanaa requested review of this revision.
Herald added a subscriber: cfe-commits.
1. Add constant array support for __builtin_dump_sturct, the style like lldb
struct:
struct S {
int x;
int y : 4;
int : 0;
int b[2][2];
float f;
struct T {
int i;
} t;
struct {
int i;
} foo;
struct Bar {
int x;
const char *B;
} bar[2];
};
output:
struct S {
int x = 100
int y : 4 = 1
int : 0
int[2][2] b = [
[0] = [
[0] = 1
[1] = 2
]
[1] = [
[0] = 3
[1] = 4
]
]
float f = 0.000000
struct T {
int i = 2022
}
struct S::(unnamed) {
int i = 4096
}
struct Bar[2] bar = [
[0] = {
int x = 1024
const char * B = This is struct Bar[0]
}
[1] = {
int x = 2048
const char * B = This is struct Bar[1]
}
]
}
2. beautify dump format, add indent.
for example:
struct:
struct A {
int a;
struct B {
int b;
struct C {
struct D {
int d;
union E {
int x;
int y;
} e;
} d;
int c;
} c;
} b;
};
Before:
struct A {
int a = 0
struct B {
int b = 0
struct C {
struct D {
int d = 0
union E {
int x = 0
int y = 0
}
}
int c = 0
}
}
}
After:
struct A {
int a = 0
struct B {
int b = 0
struct C {
struct D {
int d = 0
union E {
int x = 0
int y = 0
}
}
int c = 0
}
}
}
3. Remove anonymous tag locations, powered by 'PrintingPolicy'
struct:
struct S {
int a;
struct /* Anonymous*/ {
int x;
} b;
int c;
};
Before:
struct S {
int a = 0
struct S::(unnamed at ./builtin_dump_struct.c:20:3) {
int x = 0
}
int c = 0
}
After:
struct S {
int a = 0
struct S::(unnamed) {
int x = 0
}
int c = 0
}
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D122662
Files:
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/dump-struct-builtin.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122662.418887.patch
Type: text/x-patch
Size: 70509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220329/29097183/attachment-0001.bin>
More information about the cfe-commits
mailing list