[llvm] 67a2cc8 - Fix a few mismatched iterator types revealed from a libc++ + LLVM_EXPENSIVE_CHECKS build

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 10 10:13:00 PDT 2020


Author: David Blaikie
Date: 2020-04-10T10:12:51-07:00
New Revision: 67a2cc80b647886284d04621cbd194b4109faddd

URL: https://github.com/llvm/llvm-project/commit/67a2cc80b647886284d04621cbd194b4109faddd
DIFF: https://github.com/llvm/llvm-project/commit/67a2cc80b647886284d04621cbd194b4109faddd.diff

LOG: Fix a few mismatched iterator types revealed from a libc++ + LLVM_EXPENSIVE_CHECKS build

These were accidental SCARY iterator uses that weren't guaranteed and in
libc++'s debug checking mode were actually distinct types. Use decltype
to make it easier to keep these things up to date.

Added: 
    

Modified: 
    llvm/include/llvm/IR/Attributes.h
    llvm/include/llvm/Remarks/RemarkLinker.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h
index 9be0d98f310d..2de11ba5171e 100644
--- a/llvm/include/llvm/IR/Attributes.h
+++ b/llvm/include/llvm/IR/Attributes.h
@@ -855,8 +855,8 @@ class AttrBuilder {
 
   // Iterators for target-dependent attributes.
   using td_type = std::pair<std::string, std::string>;
-  using td_iterator = std::map<std::string, std::string>::iterator;
-  using td_const_iterator = std::map<std::string, std::string>::const_iterator;
+  using td_iterator = decltype(TargetDepAttrs)::iterator;
+  using td_const_iterator = decltype(TargetDepAttrs)::const_iterator;
   using td_range = iterator_range<td_iterator>;
   using td_const_range = iterator_range<td_const_iterator>;
 

diff  --git a/llvm/include/llvm/Remarks/RemarkLinker.h b/llvm/include/llvm/Remarks/RemarkLinker.h
index c82c73d8c94f..7a53c30924b8 100644
--- a/llvm/include/llvm/Remarks/RemarkLinker.h
+++ b/llvm/include/llvm/Remarks/RemarkLinker.h
@@ -80,8 +80,7 @@ struct RemarkLinker {
   /// Return a collection of the linked unique remarks to iterate on.
   /// Ex:
   /// for (const Remark &R : RL.remarks() { [...] }
-  using iterator =
-      pointee_iterator<std::set<std::unique_ptr<Remark>>::iterator>;
+  using iterator = pointee_iterator<decltype(Remarks)::const_iterator>;
 
   iterator_range<iterator> remarks() const {
     return {Remarks.begin(), Remarks.end()};


        


More information about the llvm-commits mailing list