summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Lex/HeaderMapTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Lex: Return "" when HeaderMap::lookupFilename failsDuncan P. N. Exon Smith2016-02-231-4/+38
| | | | | | | | | | | | Change getString() to return Optional<StringRef>, and change lookupFilename() to return an empty string if either one of the prefix and suffix can't be found. This is a more robust follow-up to r261461, but it's still not entirely satisfactory. Ideally we'd report that the header map is corrupt; perhaps something for a follow-up. llvm-svn: 261596
* Lex: Check for 0 buckets on header map constructionDuncan P. N. Exon Smith2016-02-221-0/+9
| | | | | | | | 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
* Lex: Never overflow the file in HeaderMap::lookupFilename()Duncan P. N. Exon Smith2016-02-211-0/+42
| | | | | | | | | | | | | | | | If a header map file is corrupt, the strings in the string table may not be null-terminated. The logic here previously relied on `MemoryBuffer` always being null-terminated, but this isn't actually guaranteed by the class AFAICT. Moreover, we're seeing a lot of crash traces at calls to `strlen()` inside of `lookupFilename()`, so something is going wrong there. Instead, use `strnlen()` to get the length, and check for corruption. Also remove code paths that could call `StringRef(nullptr)`. r261459 made these rather obvious (although they'd been there all along). llvm-svn: 261461
* Lex: Add a test for HeaderMap::lookupFileName()Duncan P. N. Exon Smith2016-02-201-0/+62
| | | | | | | | Add a simple test for `HeaderMap::lookupFileName()`. I'm planning to add better error checking in a moment, and I'll add more tests like this then. llvm-svn: 261455
* Lex: Check whether the header map buffer has space for the bucketsDuncan P. N. Exon Smith2016-02-201-0/+8
| | | | | | | | | | | | | 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
* Lex: Check buckets on header map constructionDuncan P. N. Exon Smith2016-02-201-0/+9
| | | | | | | | If the number of buckets is not a power of two, immediately recognize the header map as corrupt, rather than waiting for the first lookup. I converted the later check to an assert. llvm-svn: 261448
* Lex: Add some unit tests for corrupt header mapsDuncan P. N. Exon Smith2016-02-201-0/+94
Split the implementation of `HeaderMap` into `HeaderMapImpl` so that we can write unit tests that don't depend on the `FileManager`, and then write a few tests that cover the types of corrupt header maps already detected. This also moves type and constant definitions from HeaderMap.cpp to HeaderMapTypes.h so that the test can access them. llvm-svn: 261446
OpenPOWER on IntegriCloud