[llvm] r236088 - [TableGen] Fold a couple dyn_casts into the ifs that check their results. NFC
David Blaikie
dblaikie at gmail.com
Wed Apr 29 07:41:14 PDT 2015
On Wed, Apr 29, 2015 at 12:13 AM, Craig Topper <craig.topper at gmail.com>
wrote:
> Author: ctopper
> Date: Wed Apr 29 02:13:12 2015
> New Revision: 236088
>
> URL: http://llvm.org/viewvc/llvm-project?rev=236088&view=rev
> Log:
> [TableGen] Fold a couple dyn_casts into the ifs that check their results.
> NFC
>
> Modified:
> llvm/trunk/lib/TableGen/Record.cpp
>
> Modified: llvm/trunk/lib/TableGen/Record.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=236088&r1=236087&r2=236088&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/TableGen/Record.cpp (original)
> +++ llvm/trunk/lib/TableGen/Record.cpp Wed Apr 29 02:13:12 2015
> @@ -1007,21 +1007,18 @@ static Init *ForeachHelper(Init *LHS, In
> static Init *EvaluateOperation(OpInit *RHSo, Init *LHS, Init *Arg,
> RecTy *Type, Record *CurRec,
> MultiClass *CurMultiClass) {
> - std::vector<Init *> NewOperands;
> -
> - TypedInit *TArg = dyn_cast<TypedInit>(Arg);
> -
> // If this is a dag, recurse
> - if (TArg && TArg->getType()->getAsString() == "dag") {
> - Init *Result = ForeachHelper(LHS, Arg, RHSo, Type,
> - CurRec, CurMultiClass);
> - return Result;
> + if (TypedInit *TArg = dyn_cast<TypedInit>(Arg)) {
> + if (TArg->getType()->getAsString() == "dag") {
> + Init *Result = ForeachHelper(LHS, Arg, RHSo, Type,
> + CurRec, CurMultiClass);
> + return Result;
>
Drop the variable & return the result of the ForeachHelper directly - then
you can drop the braces too?
> + }
> }
>
> + std::vector<Init *> NewOperands;
> for (int i = 0; i < RHSo->getNumOperands(); ++i) {
> - OpInit *RHSoo = dyn_cast<OpInit>(RHSo->getOperand(i));
> -
> - if (RHSoo) {
> + if (OpInit *RHSoo = dyn_cast<OpInit>(RHSo->getOperand(i))) {
> Init *Result = EvaluateOperation(RHSoo, LHS, Arg,
> Type, CurRec, CurMultiClass);
> if (Result) {
>
is this 'if' another candidate for rolling the variable into the condition?
(optionally, use auto, especially in the dyn_cast cases - since the type
name is already mentioned on the RHS)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150429/479fa207/attachment.html>
More information about the llvm-commits
mailing list