summaryrefslogtreecommitdiffstats
path: root/include/clang/Serialization
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2014-08-16 04:54:18 +0000
committerBen Langmuir <blangmuir@apple.com>2014-08-16 04:54:18 +0000
commit76ef35d0566fba54e706b3bc17b6b09fc866b312 (patch)
tree18436f0d5aea996dc29aa8e5804acf8176ac389e /include/clang/Serialization
parenta11b69ce5d063c174b1b40c0900517e92e166f73 (diff)
When loading a module with no local entities, still bump the size of the
tables that correspond to ContinuousRangeMaps, since the keys to those maps need to be unique, or we may map to the wrong offset. This fixes a crash + malformed AST file seen when loading some modules that import Cocoa on Darwin, which is a module with no contents except imports of other modules. Unfortunately I have not been able to find a reduced test case that reproduces this problem. Also add an assert that we aren't mapping one key to multiple values in CRM. We ought to be able to say there are no duplicate keys at all, but there are a bunch of 0 -> 0 mappings that are showing up, probably coming from the source location table. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215810 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Serialization')
-rw-r--r--include/clang/Serialization/ContinuousRangeMap.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/clang/Serialization/ContinuousRangeMap.h b/include/clang/Serialization/ContinuousRangeMap.h
index 525e9ba784..5f8ae1fe7b 100644
--- a/include/clang/Serialization/ContinuousRangeMap.h
+++ b/include/clang/Serialization/ContinuousRangeMap.h
@@ -117,6 +117,14 @@ public:
~Builder() {
std::sort(Self.Rep.begin(), Self.Rep.end(), Compare());
+ std::unique(Self.Rep.begin(), Self.Rep.end(),
+ [](const_reference A, const_reference B) {
+ // FIXME: we should not allow any duplicate keys, but there are a lot of
+ // duplicate 0 -> 0 mappings to remove first.
+ assert((A == B || A.first != B.first) &&
+ "ContinuousRangeMap::Builder given non-unique keys");
+ return A == B;
+ });
}
void insert(const value_type &Val) {