Skip to content

Commit 77a01be

Browse files
author
git apple-llvm automerger
committed
Merge commit '907d3acefc3b' from llvm.org/main into next
2 parents 8974675 + 907d3ac commit 77a01be

File tree

3 files changed

+145
-143
lines changed

3 files changed

+145
-143
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Non-comprehensive list of changes in this release
117117
- Support bitfields in struct and union.
118118
- Improve the dump format, dump both bitwidth(if its a bitfield) and field value.
119119
- Remove anonymous tag locations.
120+
- Beautify dump format, add indent for nested struct and struct members.
120121

121122
New Compiler Flags
122123
------------------

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,11 +2049,12 @@ static llvm::Value *dumpRecord(CodeGenFunction &CGF, QualType RType,
20492049
ASTContext &Context = CGF.getContext();
20502050
RecordDecl *RD = RType->castAs<RecordType>()->getDecl()->getDefinition();
20512051
std::string Pad = std::string(Lvl * 4, ' ');
2052+
std::string ElementPad = std::string((Lvl + 1) * 4, ' ');
20522053

20532054
PrintingPolicy Policy(Context.getLangOpts());
20542055
Policy.AnonymousTagLocations = false;
2055-
Value *GString =
2056-
CGF.Builder.CreateGlobalStringPtr(RType.getAsString(Policy) + " {\n");
2056+
Value *GString = CGF.Builder.CreateGlobalStringPtr(
2057+
llvm::Twine(Pad).concat(RType.getAsString(Policy)).concat(" {\n").str());
20572058
Value *Res = CGF.Builder.CreateCall(Func, {GString});
20582059

20592060
static llvm::DenseMap<QualType, const char *> Types;
@@ -2081,7 +2082,7 @@ static llvm::Value *dumpRecord(CodeGenFunction &CGF, QualType RType,
20812082
for (const auto *FD : RD->fields()) {
20822083
Value *TmpRes = nullptr;
20832084

2084-
std::string Format = llvm::Twine(Pad)
2085+
std::string Format = llvm::Twine(ElementPad)
20852086
.concat(FD->getType().getAsString())
20862087
.concat(llvm::Twine(' '))
20872088
.concat(FD->getNameAsString())

0 commit comments

Comments
 (0)