[PATCH] D58895: [TableGen] Allow lists to be concatenated through '#'

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 5 02:20:32 PST 2019


nhaehnle accepted this revision.
nhaehnle added a comment.
This revision is now accepted and ready to land.

Awesome :)
LGTM



================
Comment at: lib/TableGen/TGParser.cpp:2124
-      // Create a !strconcat() operation, first casting each operand to
-      // a string if necessary.
-
----------------
hfinkel wrote:
> Does this change any current behavior? (i.e., if you try this now, does it cast each list to a string, or does it give an error, or something else?
```
$ llvm-tblgen
def A {
  list<int> x = [4] # [5];
}
^D
<stdin>:2:17: error: Value 'x' of type 'list<int>' is incompatible with initializer '!strconcat(!cast<string>([4]), !cast<string>([5]))' of type 'string'
  list<int> x = [4] # [5];
```
The error isn't exactly user-friendly. If you try to make x a string it doesn't work either:
```
$ llvm-tblgen
def A {
  string x = [4] # [5];
}
^D
<stdin>:2:15: error: Type mismatch for list, expected list type, got string
  string x = [4] # [5];
              ^
<stdin>:2:15: error: expected ';' after declaration
  string x = [4] # [5];
```
Those errors seem even more confusing and I'm not sure where they're from, but the underlying point is that you cannot cast a list to a string:
```
$ llvm-tblgen
def A {
  string x = !cast<string>([4]);
}
^D
<stdin>:1:1: error: Initializer of 'x' in 'A' could not be fully resolved: !cast<string>([4])
def A {
^
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58895/new/

https://reviews.llvm.org/D58895





More information about the llvm-commits mailing list