[all-commits] [llvm/llvm-project] ce7cca: [clang-repl] Fix struct value printing for clang-r...
Anutosh Bhat via All-commits
all-commits at lists.llvm.org
Wed Oct 29 04:31:57 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ce7cca116d1338d8427cd6795639d35d71e66028
https://github.com/llvm/llvm-project/commit/ce7cca116d1338d8427cd6795639d35d71e66028
Author: Anutosh Bhat <andersonbhat491 at gmail.com>
Date: 2025-10-29 (Wed, 29 Oct 2025)
Changed paths:
M clang/lib/Interpreter/InterpreterValuePrinter.cpp
M clang/test/Interpreter/pretty-print.c
Log Message:
-----------
[clang-repl] Fix struct value printing for clang-repl in C mode (#165538)
I added some logs to see the difference between C++ mode and C mode and
I see this
In C++ mode
```
clang-repl> struct S1{} s1; s1
[convertExprToValue] original Expr: DeclRefExpr | type: struct S1
[convertExprToValue] Ty: struct S1
[convertExprToValue] DesugaredTy: struct S1
[convertExprToValue] Treating lvalue record as reference (enters block 540)
[convertExprToValue] Ty: struct S1 & (after block 540)
[convertExprToValue] DesugaredTy: struct S1 & (after block 540)
[computeInterfaceKind] Expr class: DeclRefExpr | isLValue: 1
(S1 &) @0x10c9ac058
```
in C mode
```
(base) anutosh491 at Anutoshs-MacBook-Air bin % ./clang-repl --Xcc=-xc --Xcc=-std=c23
clang-repl> struct S1{} s1; s1
[convertExprToValue] original Expr: ImplicitCastExpr | type: struct S1
[convertExprToValue] Ty: struct S1
[convertExprToValue] DesugaredTy: struct S1
[convertExprToValue] Ty: struct S1 (after block 540)
[convertExprToValue] DesugaredTy: struct S1 (after block 540)
[computeInterfaceKind] Expr class: ImplicitCastExpr | isLValue: 0
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
s0 clang-repl 0x0000000103cca03c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 88
1 clang-repl 0x0000000103cca61c PrintStackTraceSignalHandler(void*) + 28
2 clang-repl 0x0000000103cc7ee8 llvm::sys::RunSignalHandlers() + 152
3 clang-repl 0x0000000103ccbb54 SignalHandler(int, __siginfo*, void*) + 284
4 libsystem_platform.dylib 0x00000001887f4624 _sigtramp + 56
5 clang-repl 0x00000001079bee18 clang::Sema::CheckArgsForPlaceholders(llvm::MutableArrayRef<clang::Expr*>) + 120
6 clang-repl 0x00000001079bee18 clang::Sema::CheckArgsForPlaceholders(llvm::MutableArrayRef<clang::Expr*>) + 120
7 clang-repl 0x0000000107b823dc clang::Sema::BuildCXXNew(clang::SourceRange, bool, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::SourceRange, clang::QualType, clang::TypeSourceInfo*, std::__1::optional<clang::Expr*>, clang::SourceRange, clang::Expr*) + 5672
8 clang-repl 0x000000010538c560 clang::Interpreter::convertExprToValue(clang::Expr*) + 2580
9 clang-repl 0x0000000105360774 clang::InProcessPrintingASTConsumer::HandleTopLevelDecl(clang::DeclGroupRef) + 252
10 clang-repl 0x000000010536a82c clang::IncrementalParser::ParseOrWrapTopLevelDecl() + 676
11 clang-repl 0x000000010536b554 clang::IncrementalParser::Parse(llvm::StringRef) + 712
12 clang-repl 0x000000010537e6b4 clang::Interpreter::Parse(llvm::StringRef) + 588
13 clang-repl 0x000000010537d73c clang::Interpreter::ParseAndExecute(llvm::StringRef, clang::Value*) + 72
14 clang-repl 0x000000010022db38 main + 3660
15 dyld 0x000000018841ab98 start + 6076
```
So basically C mode wasn't entering block 540 as expressions like `s1`
(where `s1` is a struct variable) are wrapped in an `ImplicitCastExpr`,
which masks the underlying `DeclRefExpr` that is actually an
`lvalue`.This patch unwraps the implicit cast with E->IgnoreImpCasts()
before checking isLValue(), restoring correct detection of lvalue
structs.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list