Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions clang/lib/Interpreter/InterpreterValuePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,8 @@ class InterfaceKindVisitor
}

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

// For lvalue struct, we treat it as a reference.
if (DesugaredTy->isRecordType() && E->isLValue()) {
if (DesugaredTy->isRecordType() && E->IgnoreImpCasts()->isLValue()) {
DesugaredTy = Ctx.getLValueReferenceType(DesugaredTy);
Ty = Ctx.getLValueReferenceType(Ty);
}
Expand Down
16 changes: 9 additions & 7 deletions clang/test/Interpreter/pretty-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ int * null_ptr = (int*)0; null_ptr
union U { int I; float F; } u; u.I = 12; u.I
// CHECK-NEXT: (int) 12

// TODO: _Bool, _Complex, _Atomic, and _BitInt
// struct S1{} s1; s1
// TODO-CHECK-NEXT: (S1 &) @0x{{[0-9a-f]+}}
struct S1{} s1; s1
// CHECK-NEXT: (S1 &) @0x{{[0-9a-f]+}}

struct S2 {int d;} E = {22}; E
// CHECK-NEXT: (S2 &) @0x{{[0-9a-f]+}}

// struct S2 {int d;} E = {22}; E
// TODO-CHECK-NEXT: (struct S2 &) @0x{{[0-9a-f]+}}
// E.d
// TODO-CHECK-NEXT: (int) 22
E.d
// CHECK-NEXT: (int) 22

// TODO: _Bool, _Complex, _Atomic, and _BitInt

// -----------------------------------------------------------------------------
// Tentative definition handling (C99 6.9.2)
Expand Down