Generalize the module offset map to include mapping information for
all of the kinds of IDs that can be offset. No effectively
functionality change; this is preparation for adding remapping for
IDs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136686 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Serialization/ContinuousRangeMap.h b/include/clang/Serialization/ContinuousRangeMap.h
index b1b7b6e..820086e 100644
--- a/include/clang/Serialization/ContinuousRangeMap.h
+++ b/include/clang/Serialization/ContinuousRangeMap.h
@@ -89,6 +89,30 @@
 
   reference back() { return Rep.back(); }
   const_reference back() const { return Rep.back(); }
+  
+  /// \brief An object that helps properly build a continuous range map
+  /// from a set of values.
+  class Builder {
+    ContinuousRangeMap &Self;
+    SmallVector<std::pair<Int, V>, InitialCapacity> Elements;
+    
+    Builder(const Builder&); // DO NOT IMPLEMENT
+    Builder &operator=(const Builder&); // DO NOT IMPLEMENT
+    
+  public:
+    explicit Builder(ContinuousRangeMap &Self) : Self(Self) { }
+    
+    ~Builder() {
+      std::sort(Elements.begin(), Elements.end(), Compare());
+      for (unsigned I = 0, N = Elements.size(); I != N; ++I)
+        Self.insert(Elements[I]);
+    }
+    
+    void insert(const value_type &Val) {
+      Elements.push_back(Val);
+    }
+  };
+  friend class Builder;
 };
 
 }