Paul C. Anagnostopoulos via llvm-dev
2020-Oct-31 18:00 UTC
[llvm-dev] Behavior of TableGen paste operator
I have just discovered a behavior of the TableGen paste operator (#) that I did not expect. I'm wondering if this behavior was intended. In a record name expression, the expression is parsed in "name mode" so that the name of a defvar is treated verbatim. def "foo_" # var { ... Assume var is a defvar. Its value is not used, and the name is foo_var. This allows fragments of record names to be specified without string quotes. My surprise is that the same rule holds when the paste operator is used in a normal expression. def ... string foo = "foo_" # var; The resulting string is "foo_var", not "foo_<value of var>". This happens because normal expression parsing still forces "name mode" when parsing the right-hand-side of a paste operator. So, a # b is not identical to !strconcat(a, b) in a normal expression. Thoughts? @lattner @nhaehnle