forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TableGen] Do not exit in template argument check (llvm#121636)
The signature of `CheckTemplateArgValues` implements error handling via the `bool` return type, yet always returned false. The single possible error case instead used `PrintFatalError,` which exits the program afterward. This behavior is undesirable: It prevents any further errors from being printed and makes TableGen less usable as a library as it crashes the entire process (e.g. `tblgen-lsp-server`). This PR therefore fixes the issue by using `Error` instead and returning true if an error occurred. All callers already perform proper error handling. As `llvm-tblgen` exits on error, a test was also added to the LSP to ensure it exits normally despite the error.
- Loading branch information
Showing
4 changed files
with
56 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// RUN: tblgen-lsp-server -lit-test < %s | FileCheck -strict-whitespace %s | ||
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"tablegen","capabilities":{},"trace":"off"}} | ||
// ----- | ||
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{ | ||
"uri":"test:///foo.td", | ||
"languageId":"tablegen", | ||
"version":1, | ||
"text":"class Foo<int i>;\ndef : Foo<\"\">;" | ||
}}} | ||
// CHECK: "method": "textDocument/publishDiagnostics", | ||
// CHECK: "message": "Value specified for template argument 'Foo:i' is of type string; expected type int: \"\"", | ||
// ----- | ||
{"jsonrpc":"2.0","id":3,"method":"shutdown"} | ||
// ----- | ||
{"jsonrpc":"2.0","method":"exit"} |