[llvm] 6fb6bdf - Fix the value_type of defusechain_iterator to match its operator*()

Nicolas Guillemot via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 1 10:41:17 PST 2021


Author: Nicolas Guillemot
Date: 2021-03-01T10:41:10-08:00
New Revision: 6fb6bdff3701b00af4a573604f599093f7555bcf

URL: https://github.com/llvm/llvm-project/commit/6fb6bdff3701b00af4a573604f599093f7555bcf
DIFF: https://github.com/llvm/llvm-project/commit/6fb6bdff3701b00af4a573604f599093f7555bcf.diff

LOG: Fix the value_type of defusechain_iterator to match its operator*()

defusechain_iterator has an operator*() and operator->() that return
references to a MachineOperand, but its "reference" and "pointer"
typedefs are set as if the iterator returns a MachineInstr reference.
This causes compilation errors when defusechain_iterator is used in
generic code that uses the "reference" and "pointer" typedefs.
This patch fixes this by updating the typedefs to use MachineOperand
instead of MachineInstr.

Reviewed By: mkitzan

Differential Revision: https://reviews.llvm.org/D97522

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/MachineRegisterInfo.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/MachineRegisterInfo.h b/llvm/include/llvm/CodeGen/MachineRegisterInfo.h
index 57086b4eebd69..fa4da428597b9 100644
--- a/llvm/include/llvm/CodeGen/MachineRegisterInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineRegisterInfo.h
@@ -968,10 +968,10 @@ class MachineRegisterInfo {
   /// returns defs.  If neither are true then you are silly and it always
   /// returns end().  If SkipDebug is true it skips uses marked Debug
   /// when incrementing.
-  template<bool ReturnUses, bool ReturnDefs, bool SkipDebug,
-           bool ByOperand, bool ByInstr, bool ByBundle>
-  class defusechain_iterator
-    : public std::iterator<std::forward_iterator_tag, MachineInstr, ptr
diff _t> {
+  template <bool ReturnUses, bool ReturnDefs, bool SkipDebug, bool ByOperand,
+            bool ByInstr, bool ByBundle>
+  class defusechain_iterator : public std::iterator<std::forward_iterator_tag,
+                                                    MachineOperand, ptr
diff _t> {
     friend class MachineRegisterInfo;
 
     MachineOperand *Op = nullptr;
@@ -1008,10 +1008,10 @@ class MachineRegisterInfo {
     }
 
   public:
-    using reference = std::iterator<std::forward_iterator_tag,
-                                    MachineInstr, ptr
diff _t>::reference;
-    using pointer = std::iterator<std::forward_iterator_tag,
-                                  MachineInstr, ptr
diff _t>::pointer;
+    using reference = std::iterator<std::forward_iterator_tag, MachineOperand,
+                                    ptr
diff _t>::reference;
+    using pointer = std::iterator<std::forward_iterator_tag, MachineOperand,
+                                  ptr
diff _t>::pointer;
 
     defusechain_iterator() = default;
 


        


More information about the llvm-commits mailing list