Skip to content

Commit 7f5e7ff

Browse files
committed
Fix struct value printing for clang-repl in C mode
1 parent dda95d9 commit 7f5e7ff

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

clang/lib/Interpreter/InterpreterValuePrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ class InterfaceKindVisitor
411411
}
412412

413413
InterfaceKind VisitReferenceType(const ReferenceType *Ty) {
414-
ExprResult AddrOfE = S.CreateBuiltinUnaryOp(SourceLocation(), UO_AddrOf, E);
414+
ExprResult AddrOfE = S.CreateBuiltinUnaryOp(SourceLocation(), UO_AddrOf, E->IgnoreImpCasts());
415415
assert(!AddrOfE.isInvalid() && "Can not create unary expression");
416416
Args.push_back(AddrOfE.get());
417417
return InterfaceKind::NoAlloc;
@@ -537,7 +537,7 @@ llvm::Expected<Expr *> Interpreter::convertExprToValue(Expr *E) {
537537
QualType DesugaredTy = Ty.getDesugaredType(Ctx);
538538

539539
// For lvalue struct, we treat it as a reference.
540-
if (DesugaredTy->isRecordType() && E->isLValue()) {
540+
if (DesugaredTy->isRecordType() && E->IgnoreImpCasts()->isLValue()) {
541541
DesugaredTy = Ctx.getLValueReferenceType(DesugaredTy);
542542
Ty = Ctx.getLValueReferenceType(Ty);
543543
}

clang/test/Interpreter/pretty-print.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,16 @@ int * null_ptr = (int*)0; null_ptr
7878
union U { int I; float F; } u; u.I = 12; u.I
7979
// CHECK-NEXT: (int) 12
8080

81-
// TODO: _Bool, _Complex, _Atomic, and _BitInt
82-
// struct S1{} s1; s1
83-
// TODO-CHECK-NEXT: (S1 &) @0x{{[0-9a-f]+}}
81+
struct S1{} s1; s1
82+
// CHECK-NEXT: (S1 &) @0x{{[0-9a-f]+}}
83+
84+
struct S2 {int d;} E = {22}; E
85+
// CHECK-NEXT: (struct S2 &) @0x{{[0-9a-f]+}}
8486

85-
// struct S2 {int d;} E = {22}; E
86-
// TODO-CHECK-NEXT: (struct S2 &) @0x{{[0-9a-f]+}}
87-
// E.d
88-
// TODO-CHECK-NEXT: (int) 22
87+
E.d
88+
// CHECK-NEXT: (int) 22
89+
90+
// TODO: _Bool, _Complex, _Atomic, and _BitInt
8991

9092
// -----------------------------------------------------------------------------
9193
// Tentative definition handling (C99 6.9.2)

0 commit comments

Comments
 (0)