From: Andrew Lenharth Date: Tue, 13 Feb 2007 00:37:50 +0000 (+0000) Subject: I love non-deturminism. Returning objects with references to stack objects is a... X-Git-Tag: android-x86-6.0-r1~1003^2~37297 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=f7e804b683d529e938d8144996558ff8d2af5025;p=android-x86%2Fexternal-llvm.git I love non-deturminism. Returning objects with references to stack objects is a bad idea (TM). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34210 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h index 3cf037fa057..ab9e45f312c 100644 --- a/include/llvm/Support/PatternMatch.h +++ b/include/llvm/Support/PatternMatch.h @@ -223,19 +223,22 @@ inline Shr_match m_Shr(const LHS &L, const RHS &R) { template struct BinaryOpClass_match { - OpcType &Opcode; + OpcType *Opcode; LHS_t L; RHS_t R; BinaryOpClass_match(OpcType &Op, const LHS_t &LHS, const RHS_t &RHS) - : Opcode(Op), L(LHS), R(RHS) {} + : Opcode(&Op), L(LHS), R(RHS) {} + BinaryOpClass_match(const LHS_t &LHS, const RHS_t &RHS) + : Opcode(0), L(LHS), R(RHS) {} template bool match(OpTy *V) { if (Class *I = dyn_cast(V)) if (L.match(I->getOperand(0)) && R.match(I->getOperand(1))) { - Opcode = I->getOpcode(); + if (Opcode) + *Opcode = I->getOpcode(); return true; } #if 0 // Doesn't handle constantexprs yet! @@ -257,9 +260,8 @@ m_Shift(Instruction::BinaryOps &Op, const LHS &L, const RHS &R) { template inline BinaryOpClass_match m_Shift(const LHS &L, const RHS &R) { - Instruction::BinaryOps Op; return BinaryOpClass_match(Op, L, R); + BinaryOperator, Instruction::BinaryOps>(L, R); } //===----------------------------------------------------------------------===//