[clang] [clang-repl] fix error recovery while parsing completely fails (PR #127087)
Anutosh Bhat via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 17 20:11:02 PST 2025
anutosh491 wrote:
There are quite some made by @kr-2003 and me here.
1) We realize even without this fix, stuff worked perfectly on our Macos ARM devices. So looks like a Ubuntu issue anyways

2) Obviously the try-catch block works when wrapped inside a class/function (not a top level decl)
3) If we build clang-repl with different configs, it works
i) `-DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_ENABLE_PROJECTS=clang -DLLVM_USE_SPLIT_DWARF=ON -DLLVM_USE_LINKER=lld`
With this
```
(base) abhinav at jarvis-2223:~/Desktop/Coding/llvm-project/build/bin$ ./clang-repl --version
LLVM (http://llvm.org/):
LLVM version 20.1.0-rc1
Optimized build.
(base) abhinav at jarvis-2223:~/Desktop/Coding/llvm-project/build/bin$ ./clang-repl
clang-repl> #include <iostream>
clang-repl> try { throw 1; } catch { std::cout << "Caught Exception" << std::endl; }
In file included from <<< inputs >>>:1:
input_line_2:1:23: error: expected '('
1 | try { throw 1; } catch { std::cout << "Caught Exception" << std::endl; }
| ^
| (
error: Parsing failed.
clang-repl>
```
ii) With the following it fails.
```
-DLLVM_ENABLE_PROJECTS=clang \
-DLLVM_TARGETS_TO_BUILD="host;NVPTX" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_ENABLE_FORMAT=OFF \
-DCLANG_ENABLE_BOOTSTRAP=OFF \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_LIBXML2=OFF \
```
Abhinav, could you also past the diff between how using two different configs affects the build ?
Maybe that might point us to the root cause behind all of this.
https://github.com/llvm/llvm-project/pull/127087
More information about the cfe-commits
mailing list