diff options
author | Nicolai Haehnle <nhaehnle@gmail.com> | 2018-03-19 14:14:04 +0000 |
---|---|---|
committer | Nicolai Haehnle <nhaehnle@gmail.com> | 2018-03-19 14:14:04 +0000 |
commit | 335c70f55ed2101ef7e7411a33b6af7eb2a4384b (patch) | |
tree | e3f738c7c3198fa902d22553db13733ac7be1c6e /llvm/lib/TableGen/TGParser.cpp | |
parent | a43af64fa2f6c475fd4c63a1e9924e09124a0018 (diff) | |
download | llvm-335c70f55ed2101ef7e7411a33b6af7eb2a4384b.zip llvm-335c70f55ed2101ef7e7411a33b6af7eb2a4384b.tar.gz llvm-335c70f55ed2101ef7e7411a33b6af7eb2a4384b.tar.bz2 |
TableGen: Only fold when some operand made resolve progress
Summary:
Make sure that we always fold immediately, so there's no point in
attempting to re-fold when nothing changes.
Change-Id: I069e1989455b6f2ca8606152f6adc1a5e817f1c8
Reviewers: arsenm, craig.topper, tra, MartinO
Subscribers: wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D44198
llvm-svn: 327847
Diffstat (limited to 'llvm/lib/TableGen/TGParser.cpp')
-rw-r--r-- | llvm/lib/TableGen/TGParser.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index 5f19d55..0c92cf7 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -1961,7 +1961,14 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType, IDParseMode Mode) { } if (LHS->getType() != StringRecTy::get()) { - LHS = UnOpInit::get(UnOpInit::CAST, LHS, StringRecTy::get()); + LHS = dyn_cast<TypedInit>( + UnOpInit::get(UnOpInit::CAST, LHS, StringRecTy::get()) + ->Fold(CurRec)); + if (!LHS) { + Error(PasteLoc, Twine("can't cast '") + LHS->getAsString() + + "' to string"); + return nullptr; + } } TypedInit *RHS = nullptr; @@ -1988,7 +1995,14 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType, IDParseMode Mode) { } if (RHS->getType() != StringRecTy::get()) { - RHS = UnOpInit::get(UnOpInit::CAST, RHS, StringRecTy::get()); + RHS = dyn_cast<TypedInit>( + UnOpInit::get(UnOpInit::CAST, RHS, StringRecTy::get()) + ->Fold(CurRec)); + if (!RHS) { + Error(PasteLoc, Twine("can't cast '") + RHS->getAsString() + + "' to string"); + return nullptr; + } } break; |