Lex: Check whether the header map buffer has space for the buckets
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sat, 20 Feb 2016 21:24:31 +0000 (21:24 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sat, 20 Feb 2016 21:24:31 +0000 (21:24 +0000)
commit8d6a31c023a3eaf0817cf83526f87bd53997ffc0
tree218c2f0ff561183740e5a1fff876d358299aa4c6
parentdfe85305faa3329c7eb2af865c1e214fc0f177b7
Lex: Check whether the header map buffer has space for the buckets

Check up front whether the header map buffer has space for all of its
declared buckets.

There was already a check in `getBucket()`, but it had UB (comparing
pointers that were outside of objects in the error path) and was
insufficient (only checking for a single byte of the relevant bucket).
I fixed the check, moved it to `checkHeader()`, and left a fixed version
behind as an assertion.

llvm-svn: 261449
clang/lib/Lex/HeaderMap.cpp
clang/unittests/Lex/HeaderMapTest.cpp