[llvm-commits] CVS: llvm/include/llvm/Support/PatternMatch.h

Andrew Lenharth alenhar2 at cs.uiuc.edu
Mon Feb 12 16:38:06 PST 2007



Changes in directory llvm/include/llvm/Support:

PatternMatch.h updated: 1.18 -> 1.19
---
Log message:

I love non-deturminism.  Returning objects with references to stack objects is a bad idea (TM).

---
Diffs of the changes:  (+7 -5)

 PatternMatch.h |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)


Index: llvm/include/llvm/Support/PatternMatch.h
diff -u llvm/include/llvm/Support/PatternMatch.h:1.18 llvm/include/llvm/Support/PatternMatch.h:1.19
--- llvm/include/llvm/Support/PatternMatch.h:1.18	Thu Feb  1 20:16:21 2007
+++ llvm/include/llvm/Support/PatternMatch.h	Mon Feb 12 18:37:50 2007
@@ -223,19 +223,22 @@
 
 template<typename LHS_t, typename RHS_t, typename Class, typename OpcType>
 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<typename OpTy>
   bool match(OpTy *V) {
     if (Class *I = dyn_cast<Class>(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 @@
 template<typename LHS, typename RHS>
 inline BinaryOpClass_match<LHS, RHS, BinaryOperator, Instruction::BinaryOps>
 m_Shift(const LHS &L, const RHS &R) {
-  Instruction::BinaryOps Op; 
   return BinaryOpClass_match<LHS, RHS, 
-                             BinaryOperator, Instruction::BinaryOps>(Op, L, R);
+                             BinaryOperator, Instruction::BinaryOps>(L, R);
 }
 
 //===----------------------------------------------------------------------===//






More information about the llvm-commits mailing list