diff options
author | Craig Topper <craig.topper@gmail.com> | 2015-05-14 05:54:02 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2015-05-14 05:54:02 +0000 |
commit | b1846a352ecd482f02629375d82fea09e2225c0f (patch) | |
tree | e2b6f75a08cc929cd2751a251191ff1b7c6ef2b7 /llvm/lib/TableGen/Record.cpp | |
parent | 42467f25e472dee979b82f6dda815915a00f2e78 (diff) | |
download | bcm5719-llvm-b1846a352ecd482f02629375d82fea09e2225c0f.tar.gz bcm5719-llvm-b1846a352ecd482f02629375d82fea09e2225c0f.zip |
[TableGen] Remove an unnecessary outer 'if' around 3 separate inner ifs. No functional change intended.
The outer if had 3 separate conditions ORed together and then the inner ifs detected which of the three conditions it was by using only a portion of the specific condition. Just put the whole condition in each inner if and remove the outer if.
llvm-svn: 237343
Diffstat (limited to 'llvm/lib/TableGen/Record.cpp')
-rw-r--r-- | llvm/lib/TableGen/Record.cpp | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index a9229175b7a..7229b8c30a3 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -1096,35 +1096,31 @@ Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const { VarInit *RHSv = dyn_cast<VarInit>(RHS); StringInit *RHSs = dyn_cast<StringInit>(RHS); - if ((LHSd && MHSd && RHSd) || - (LHSv && MHSv && RHSv) || - (LHSs && MHSs && RHSs)) { - if (RHSd) { - Record *Val = RHSd->getDef(); - if (LHSd->getAsString() == RHSd->getAsString()) - Val = MHSd->getDef(); - return DefInit::get(Val); - } - if (RHSv) { - std::string Val = RHSv->getName(); - if (LHSv->getAsString() == RHSv->getAsString()) - Val = MHSv->getName(); - return VarInit::get(Val, getType()); - } - if (RHSs) { - std::string Val = RHSs->getValue(); - - std::string::size_type found; - std::string::size_type idx = 0; - do { - found = Val.find(LHSs->getValue(), idx); - if (found != std::string::npos) - Val.replace(found, LHSs->getValue().size(), MHSs->getValue()); - idx = found + MHSs->getValue().size(); - } while (found != std::string::npos); - - return StringInit::get(Val); - } + if (LHSd && MHSd && RHSd) { + Record *Val = RHSd->getDef(); + if (LHSd->getAsString() == RHSd->getAsString()) + Val = MHSd->getDef(); + return DefInit::get(Val); + } + if (LHSv && MHSv && RHSv) { + std::string Val = RHSv->getName(); + if (LHSv->getAsString() == RHSv->getAsString()) + Val = MHSv->getName(); + return VarInit::get(Val, getType()); + } + if (LHSs && MHSs && RHSs) { + std::string Val = RHSs->getValue(); + + std::string::size_type found; + std::string::size_type idx = 0; + do { + found = Val.find(LHSs->getValue(), idx); + if (found != std::string::npos) + Val.replace(found, LHSs->getValue().size(), MHSs->getValue()); + idx = found + MHSs->getValue().size(); + } while (found != std::string::npos); + + return StringInit::get(Val); } break; } |