aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Serialization/ContinuousRangeMap.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-08-02 10:56:51 +0000
committerDouglas Gregor <dgregor@apple.com>2011-08-02 10:56:51 +0000
commitf33740efdb2d836a96ba97ca3004d46404401439 (patch)
treec7ce78949afe38027240701b6bca39441c7cf994 /include/clang/Serialization/ContinuousRangeMap.h
parent39997fc2b8d300a85ead0a7d687964c6e63a8110 (diff)
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
Diffstat (limited to 'include/clang/Serialization/ContinuousRangeMap.h')
-rw-r--r--include/clang/Serialization/ContinuousRangeMap.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/clang/Serialization/ContinuousRangeMap.h b/include/clang/Serialization/ContinuousRangeMap.h
index b1b7b6ede8..820086e820 100644
--- a/include/clang/Serialization/ContinuousRangeMap.h
+++ b/include/clang/Serialization/ContinuousRangeMap.h
@@ -89,6 +89,30 @@ public:
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;
};
}