diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-02-22 22:24:22 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-02-22 22:24:22 +0000 |
commit | 3a7def09fece8d6a403f5002dd4811704fa2b3c4 (patch) | |
tree | cc766a73bec0223cb7be43ad37b6c9c3a02d332c /clang/unittests/Lex | |
parent | 964b70d559fad083744ea2791def82c564087388 (diff) | |
download | bcm5719-llvm-3a7def09fece8d6a403f5002dd4811704fa2b3c4.tar.gz bcm5719-llvm-3a7def09fece8d6a403f5002dd4811704fa2b3c4.zip |
Lex: Check for 0 buckets on header map construction
Switch to using `isPowerOf2_32()` to check whether the buckets are a
power of two, and as a side benefit reject loading a header map with no
buckets. This is a follow-up to r261448.
llvm-svn: 261585
Diffstat (limited to 'clang/unittests/Lex')
-rw-r--r-- | clang/unittests/Lex/HeaderMapTest.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/unittests/Lex/HeaderMapTest.cpp b/clang/unittests/Lex/HeaderMapTest.cpp index e8921709604..ad0579a236e 100644 --- a/clang/unittests/Lex/HeaderMapTest.cpp +++ b/clang/unittests/Lex/HeaderMapTest.cpp @@ -143,6 +143,15 @@ TEST(HeaderMapTest, checkHeader3Buckets) { ASSERT_FALSE(HeaderMapImpl::checkHeader(*File.getBuffer(), NeedsSwap)); } +TEST(HeaderMapTest, checkHeader0Buckets) { + // Create with 1 bucket to avoid 0-sized arrays. + MapFile<1, 1> File; + File.init(); + File.Header.NumBuckets = 0; + bool NeedsSwap; + ASSERT_FALSE(HeaderMapImpl::checkHeader(*File.getBuffer(), NeedsSwap)); +} + TEST(HeaderMapTest, checkHeaderNotEnoughBuckets) { MapFile<1, 1> File; File.init(); |