diff options
| author | Simon Tatham <simon.tatham@arm.com> | 2018-05-02 13:17:26 +0000 |
|---|---|---|
| committer | Simon Tatham <simon.tatham@arm.com> | 2018-05-02 13:17:26 +0000 |
| commit | 6a02604ee4e75cffb36086a69d2c4ba41072fb50 (patch) | |
| tree | 2c83aa556326aa293d7993340049807682e0fa70 /llvm/lib | |
| parent | e222d927074ebfacd0ada324ab85b5823c771a98 (diff) | |
| download | bcm5719-llvm-6a02604ee4e75cffb36086a69d2c4ba41072fb50.tar.gz bcm5719-llvm-6a02604ee4e75cffb36086a69d2c4ba41072fb50.zip | |
[TableGen] Don't quote variable name when printing !foreach.
An input !foreach expression such as !foreach(a, lst, !add(a, 1))
would be re-emitted by llvm-tblgen -print-records with the first
argument in quotes, giving !foreach("a", lst, !add(a, 1)), which isn't
valid TableGen input syntax.
Reviewers: nhaehnle
Reviewed By: nhaehnle
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D46352
llvm-svn: 331351
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/TableGen/Record.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index e81a6f2ae0a..4f1ca04316b 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -1196,14 +1196,16 @@ Init *TernOpInit::resolveReferences(Resolver &R) const { std::string TernOpInit::getAsString() const { std::string Result; + bool UnquotedLHS = false; switch (getOpcode()) { case SUBST: Result = "!subst"; break; - case FOREACH: Result = "!foreach"; break; + case FOREACH: Result = "!foreach"; UnquotedLHS = true; break; case IF: Result = "!if"; break; case DAG: Result = "!dag"; break; } - return Result + "(" + LHS->getAsString() + ", " + MHS->getAsString() + ", " + - RHS->getAsString() + ")"; + return (Result + "(" + + (UnquotedLHS ? LHS->getAsUnquotedString() : LHS->getAsString()) + + ", " + MHS->getAsString() + ", " + RHS->getAsString() + ")"); } static void ProfileFoldOpInit(FoldingSetNodeID &ID, Init *A, Init *B, |

