[lld] [LLD] Fix crash on parsing ':ALIGN' in linker script (PR #146723)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 2 12:56:30 PDT 2025
================
@@ -1229,6 +1229,9 @@ SymbolAssignment *ScriptParser::readSymbolAssignment(StringRef name) {
// This is an operator-precedence parser to parse a linker
// script expression.
Expr ScriptParser::readExpr() {
+ // Do not try to read expression if an error has already been encountered.
+ if (atEOF())
----------------
parth-07 wrote:
Thank you for your inputs @smithp35.
> although I think it may be more idiomatic to use
>
```
if (errCount(ctx))
return 0;
```
I agree that `errCount(ctx)` would work as well, however, I think it is better for code-readability if the behavior of parsing expression is consistent for both the error-case and the actual end-of-file case, and `atEOF()` covers both the cases. Please let me know your thoughts on this.
https://github.com/llvm/llvm-project/pull/146723
More information about the llvm-commits
mailing list