aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/HeaderMap.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-10-01Use StringRef for MemoryBuffer identifier API (NFC)Mehdi Amini1-1/+1
llvm-svn: 283043
2016-02-23Lex: Return "" when HeaderMap::lookupFilename failsDuncan P. N. Exon Smith1-13/+24
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
2016-02-22Lex: Check for 0 buckets on header map constructionDuncan P. N. Exon Smith1-5/+5
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
2016-02-21Lex: Never overflow the file in HeaderMap::lookupFilename()Duncan P. N. Exon Smith1-5/+11
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
2016-02-20Lex: Change HeaderMapImpl::getString() to return StringRef, NFCDuncan P. N. Exon Smith1-4/+4
llvm-svn: 261459
2016-02-20Lex: Use dbgs() instead of fprintf() in HeaderMap::dump()Duncan P. N. Exon Smith1-5/+5
This way it's easy to change HeaderMapImpl::getString() to return a StringRef. There's a slight change here, because I used `errs()` instead of `dbgs()`. But `dbgs()` is more appropriate for a dump method. llvm-svn: 261456
2016-02-20Lex: Check whether the header map buffer has space for the bucketsDuncan P. N. Exon Smith1-10/+10
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
2016-02-20Lex: Check buckets on header map constructionDuncan P. N. Exon Smith1-4/+12
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
2016-02-20Lex: Add some unit tests for corrupt header mapsDuncan P. N. Exon Smith1-48/+28
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
2016-01-29Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith ↵Yaron Keren1-1/+1
r259192 post commit comment. llvm-svn: 259232
2014-10-26Make VFS and FileManager match the current MemoryBuffer API.Benjamin Kramer1-4/+3
This eliminates converting back and forth between the 3 formats and gives us a more homogeneous interface. llvm-svn: 220657
2014-08-29unique_ptrify HeaderMap::FileBufferDavid Blaikie1-6/+3
llvm-svn: 216758
2014-05-17[C++11] Use 'nullptr'. Lex edition.Craig Topper1-6/+6
llvm-svn: 209083
2014-03-09[C++11] Replace OwningPtr include with <memory>.Ahmed Charles1-1/+1
llvm-svn: 203389
2014-03-07Replace OwningPtr with std::unique_ptr.Ahmed Charles1-1/+1
This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
2014-03-07Change OwningPtr::take() to OwningPtr::release().Ahmed Charles1-1/+1
This is a precursor to moving to std::unique_ptr. llvm-svn: 203275
2014-02-14If the headermap maps the filename to a framework include ("Foo.h" -> ↵Argyrios Kyrtzidis1-6/+19
"Foo/Foo.h"), continue header lookup using the framework include as filename. This allows us to conveniently treat #import "Foo.h" as an implicit module import if we can resolve "Foo/Foo.h" as such. rdar://16042979 llvm-svn: 201419
2013-05-15Use only explicit bool conversion operatorDavid Blaikie1-1/+1
The most common (non-buggy) case are where such objects are used as return expressions in bool-returning functions or as boolean function arguments. In those cases I've used (& added if necessary) a named function to provide the equivalent (or sometimes negative, depending on convenient wording) test. DiagnosticBuilder kept its implicit conversion operator owing to the prevalent use of it in return statements. One bug was found in ExprConstant.cpp involving a comparison of two PointerUnions (PointerUnion did not previously have an operator==, so instead both operands were converted to bool & then compared). A test is included in test/SemaCXX/constant-expression-cxx1y.cpp for the fix (adding operator== to PointerUnion in LLVM). llvm-svn: 181869
2013-02-09Remove some stray uses of <ctype.h> functions.Jordan Rose1-1/+2
These are causing assertions on some MSVC builds. llvm-svn: 174805
2013-02-08Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.Jordan Rose1-1/+0
Nearly all of these changes are one-to-one replacements; the few that aren't have to do with custom identifier validation. llvm-svn: 174768
2012-09-06Dont cast away const needlessly. Found by gcc48 -Wcast-qual.Roman Divacky1-1/+1
llvm-svn: 163325
2012-02-05Basic: import SmallString<> into clang namespaceDylan Noblesmith1-1/+1
(I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
2012-02-05Basic: import OwningPtr<> into clang namespaceDylan Noblesmith1-1/+1
llvm-svn: 149798
2011-07-23remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner1-2/+2
LLVM.h imports them into the clang namespace. llvm-svn: 135852
2011-04-26To be able to replay compilations we need to accurately remodel howManuel Klimek1-4/+1
includes get resolved, especially when they are found relatively to another include file. We also try to get it working for framework includes, but that part of the code is untested, as I don't have a code base that uses it. llvm-svn: 130246
2011-03-16Add a 'RawPath' parameter to the PPCallbacks interface. This allowsChandler Carruth1-2/+5
clients to observe the exact path through which an #included file was located. This is very useful when trying to record and replay inclusion operations without it beind influenced by the aggressive caching done inside the FileManager to avoid redundant system calls and filesystem operations. The work to compute and return this is only done in the presence of callbacks, so it should have no effect on normal compilation. Patch by Manuel Klimek. llvm-svn: 127742
2010-12-19Add missing standard includes. Patch by Joerg Sonnenberger!Nick Lewycky1-0/+1
llvm-svn: 122194
2010-11-29Merge System into Support.Michael J. Spencer1-1/+1
llvm-svn: 120297
2010-11-23now the FileManager has a FileSystemOpts ivar, stop threadingChris Lattner1-7/+4
FileSystemOpts through a ton of apis, simplifying a lot of code. This also fixes a latent bug in ASTUnit where it would invoke methods on FileManager without creating one in some code paths in cindextext. llvm-svn: 120010
2010-11-21remove old compatibility APIs, use StringRef versions instead.Chris Lattner1-1/+1
llvm-svn: 119935
2010-11-03Implement -working-directory.Argyrios Kyrtzidis1-4/+6
When -working-directory is passed in command line, file paths are resolved relative to the specified directory. This helps both when using libclang (where we can't require the user to actually change the working directory) and to help reproduce test cases when the reproduction work comes along. --FileSystemOptions is introduced which controls how file system operations are performed (currently it just contains the working directory value if set). --FileSystemOptions are passed around to various interfaces that perform file operations. --Opening & reading the content of files should be done only through FileManager. This is useful in general since file operations will be abstracted in the future for the reproduction mechanism. FileSystemOptions is independent of FileManager so that we can have multiple translation units sharing the same FileManager but with different FileSystemOptions. Addresses rdar://8583824. llvm-svn: 118203
2010-01-10Simplify code. No functionality change.Benjamin Kramer1-18/+1
llvm-svn: 93114
2010-01-10stringref'ize a bunch of filename handling logic. MuchChris Lattner1-6/+6
nicer than passing around two const char*'s. llvm-svn: 93094
2009-10-26Update location of DataTypes.h to reflect move in LLVM with r85086.Chandler Carruth1-1/+1
llvm-svn: 85087
2009-09-09Remove tabs, and whitespace cleanups.Mike Stump1-22/+22
llvm-svn: 81346
2009-03-02improve compatibility with GCC 4.4, patch by Michel Salim (PR3697)Chris Lattner1-0/+1
llvm-svn: 65884
2008-10-28Initialize Suffix and Prefix to 0, even with a bad entry. Removes an ↵Ted Kremenek1-1/+4
uninitialized value warning from gcc. llvm-svn: 58305
2008-04-01Update to match simplified llvm MemoryBuffer interfaces for files.Chris Lattner1-2/+1
llvm-svn: 49042
2008-03-15Make a major restructuring of the clang tree: introduce a top-levelChris Lattner1-0/+242
lib dir and move all the libraries into it. This follows the main llvm tree, and allows the libraries to be built in parallel. The top level now enforces that all the libs are built before Driver, but we don't care what order the libs are built in. This speeds up parallel builds, particularly incremental ones. llvm-svn: 48402