[clang] [clang-repl] adding documentation and information for %commands (PR #150348)
David Spickett via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 29 05:32:43 PDT 2025
https://github.com/DavidSpickett commented:
I had a dark thought that maybe mutli-line input would mess up checking for % commands, but luckily it does not.
```
clang-repl> int a = 1;
clang-repl> int b = 10 \
clang-repl... %undo
In file included from <<< inputs >>>:1:
input_line_2:1:13: error: use of undeclared identifier 'undo'
1 | int b = 10 %undo
| ^~~~
input_line_2:1:17: error: expected ';' after top level declarator
1 | int b = 10 %undo
| ^
| ;
error: Parsing failed.
```
If it was doing as I feared, it would have treated that as a command, but it does not. I think it's seeing the two input lines as one, with an internal newline.
% commands have to start with % **after** leading and trailing whitespace has been removed. This is also why ` %undo` works.
```
clang-repl> %undo
error: Operation failed. No input left to undo
```
https://github.com/llvm/llvm-project/pull/150348
More information about the cfe-commits
mailing list