summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/SourceManager.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Harden Lexer::GetBeginningOfToken() against bogus source locations andDouglas Gregor2011-01-311-2/+11
| | | | | | the disappearance/alteration of files. llvm-svn: 124616
* Handle locations coming from macro instantiations properly in ↵Argyrios Kyrtzidis2010-12-241-0/+7
| | | | | | | | SourceManager::isBeforeInTranslationUnit(). Fixes rdar://8790245 and http://llvm.org/PR8821. llvm-svn: 122536
* Merge System into Support.Michael J. Spencer2010-11-291-1/+1
| | | | llvm-svn: 120297
* reduce indentation and use early outs, to make it easier to readChris Lattner2010-11-231-72/+79
| | | | | | this code. no functionality change. llvm-svn: 120011
* now the FileManager has a FileSystemOpts ivar, stop threadingChris Lattner2010-11-231-6/+3
| | | | | | | | | 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
* Partially revert Doug's PCH validation patch (r98585).Chris Lattner2010-11-231-14/+4
| | | | | | | | | | | | | | | | | | | | | | This patch completely defeated the "passing in a prestat'd size to MemoryBuffer" optimization, leading to an extra fstat call for every buffer opened, in order to find out if the datestamp and size of the file on disk matches what is in the stat cache. I fully admit that I don't completely understand what is going on here: why punish code when a stat cache isn't in use? what is the point of a stat cache if you have to turn around and stat stuff to validate it? To resolve both these issues, just drop the modtime check and check the file size, which is the important thing anyway. This should also resolve PR6812, because presumably windows is stable when it comes to file sizes. If the modtime is actually important, we should get it and keep it on the first stat. This eliminates 833 fstat syscalls when processing Cocoa.h, speeding up system time on -Eonly Cocoa.h from 0.041 to 0.038s. llvm-svn: 120001
* Refactoring of Diagnostic class.Argyrios Kyrtzidis2010-11-181-3/+12
| | | | | | | | | | | -Move the stuff of Diagnostic related to creating/querying diagnostic IDs into a new DiagnosticIDs class. -DiagnosticIDs can be shared among multiple Diagnostics for multiple translation units. -The rest of the state in Diagnostic object is considered related and tied to one translation unit. -Have Diagnostic point to the SourceManager that is related with. Diagnostic can now accept just a SourceLocation instead of a FullSourceLoc. -Reflect the changes to various interfaces. llvm-svn: 119730
* Fix a typo in the UTF-8 BOM (PR8645). Use a StringSwitch while at it.Benjamin Kramer2010-11-181-24/+15
| | | | llvm-svn: 119698
* Implement -working-directory.Argyrios Kyrtzidis2010-11-031-3/+4
| | | | | | | | | | | | | | | | | | | 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
* Teach SourceManager::getPresumedLoc() how to fail gracefully if ↵Douglas Gregor2010-11-021-2/+8
| | | | | | getLineNumber/getColumnNumber fail llvm-svn: 117990
* getOrCreateContentCache never returns null, so overrideFileContentsDan Gohman2010-10-261-4/+2
| | | | | | doesn't need its return value. llvm-svn: 117393
* Update remaining attribute macros to new style.Chandler Carruth2010-10-231-1/+1
| | | | llvm-svn: 117204
* Fix handling of the 'Invalid' argument in SourceManager's methods (patch by ↵Zhanyong Wan2010-10-051-5/+14
| | | | | | Dean Sturtevant, reviewed by chandlerc and Sebastian Redl). llvm-svn: 115638
* Fix a typo.Dan Gohman2010-08-261-1/+1
| | | | llvm-svn: 112219
* More PCH -> AST renaming.Sebastian Redl2010-08-181-1/+1
| | | | llvm-svn: 111472
* Add a test case for tentative definitions in chained PCH. Fix a bug that ↵Sebastian Redl2010-07-281-1/+4
| | | | | | completely messed up source locations and thus caused a crash whenever a diagnostic was emitted in chained PCH files. llvm-svn: 109660
* Introduce basic support for loading a precompiled preamble whileDouglas Gregor2010-07-261-11/+14
| | | | | | | | | | | | | | | | | | | | | | | reparsing an ASTUnit. When saving a preamble, create a buffer larger than the actual file we're working with but fill everything from the end of the preamble to the end of the file with spaces (so the lexer will quickly skip them). When we load the file, create a buffer of the same size, filling it with the file and then spaces. Then, instruct the lexer to start lexing after the preamble, therefore continuing the parse from the spot where the preamble left off. It's now possible to perform a simple preamble build + parse (+ reparse) with ASTUnit. However, one has to disable a bunch of checking in the PCH reader to do so. That part isn't committed; it will likely be handled with some other kind of flag (e.g., -fno-validate-pch). As part of this, fix some issues with null termination of the memory buffers created for the preamble; we were trying to explicitly NULL-terminate them, even though they were also getting implicitly NULL terminated, leading to excess warnings about NULL characters in source files. llvm-svn: 109445
* clean up isBeforeInTranslationUnit by factoring out some commonChris Lattner2010-05-071-24/+34
| | | | | | | code into a MoveUpIncludeHierarchy helper, and use the helper to fix a case involving macros which regressed from my recent patch. llvm-svn: 103288
* reimplement the guts of SourceManager::isBeforeInTranslationUnitChris Lattner2010-05-071-53/+56
| | | | | | | | | | | to be algorithmically faster and avoid an std::map. This routine basically boils down to finding the nearest common ancestor in a tree, and we (implicitly) have information about nesting depth, use it! This wraps up rdar://7948633 - SourceManager::isBeforeInTranslationUnit has poor performance llvm-svn: 103239
* start using the caching now that it appears to work!Chris Lattner2010-05-071-16/+4
| | | | llvm-svn: 103236
* reimplement the caching in the SourceManager::isBeforeInTranslationUnit()Chris Lattner2010-05-071-20/+31
| | | | | | | | method to be correct. Right now it correctly computes the cache, then goes ahead and computes the result the hard way, then asserts that they match. Next I'll actually turn it on. llvm-svn: 103231
* Workaround a really serious caching bug in ↵Ted Kremenek2010-05-061-0/+5
| | | | | | | | | | SourceManager::isBeforeInTranslationUnit() where the method will sometimes return different results for the same input SourceLocations. I haven't unraveled this method completely yet, so this truly is a workaround until a better fix comes along. llvm-svn: 103143
* change FullSourceLoc to have a *const* SourceManager&, eliminatingChris Lattner2010-04-201-4/+1
| | | | | | a const_cast. llvm-svn: 101940
* push some source location information down through the compiler,Chris Lattner2010-04-201-20/+32
| | | | | | | | into ContentCache::getBuffer. This allows it to produce diagnostics on the broken #include line instead of without a location. llvm-svn: 101939
* enhance sourcemgr to detect various UTF BOM's and emit a fatal errorChris Lattner2010-04-201-0/+35
| | | | | | | | | about it instead of producing tons of garbage from the lexer. It would be even better for sourcemgr to dynamically transcode (e.g. from UTF16 -> UTF8). llvm-svn: 101924
* Disable diag::err_file_modified on Win32 completely, until someone cares to fixDaniel Dunbar2010-04-101-10/+12
| | | | | | | it. PR6812. - This is another attempt at silencing annoying buildbot failures. llvm-svn: 100914
* On Windows, disable the modification-time check for files used inDouglas Gregor2010-04-091-5/+11
| | | | | | | | precompiled headers and/or when reading the contents of the file into memory. These checks seem to be causing spurious regression-test failures on Windows. llvm-svn: 100866
* Introduce the notion of a single "delayed" diagnostic into theDouglas Gregor2010-03-221-3/+14
| | | | | | | | | | | | Diagnostic subsystem, which is used in the rare case where we find a serious problem (i.e., an inconsistency in the file system) while we're busy formatting another diagnostic. In this case, the delayed diagnostic will be emitted after we're done with the other diagnostic. This is only to be used for fatal conditions detected at very inconvenient times, where we can neither stop the current diagnostic in flight nor can we suppress the second error. llvm-svn: 99175
* Keep track of the size/modification time of each file source-locationDouglas Gregor2010-03-211-2/+1
| | | | | | | entry in a precompiled header, so that we can detect modified files even when we miss in the stat cache. llvm-svn: 99149
* Fix a longstanding (but previously unknown) bug in the lazyDouglas Gregor2010-03-191-1/+1
| | | | | | | | | | | | | deserialization of precompiled headers, where the deserialization of the source location entry for a buffer (e.g., macro instantiation scratch space) would overwrite a one-element FileID cache in the source manager. When tickled at the wrong time, we would return the wrong decomposed source location and eventually cause c-index-test to crash. Found by dumb luck. It's amazing this hasn't shown up before. llvm-svn: 98940
* Check the inode in addition to size and modification time to determineDouglas Gregor2010-03-171-3/+5
| | | | | | whether a file has changed since it was originally read. llvm-svn: 98726
* Use a simple diagnostic (file modified) when we detect that a file hasDouglas Gregor2010-03-171-10/+4
| | | | | | | changed, rather than trying to point out how it changed. The "why" doesn't matter. llvm-svn: 98725
* Teach SourceManager's content cache to keep track of whether itsDouglas Gregor2010-03-161-21/+24
| | | | | | | | | buffer was invalid when it was created, and use that bit to always set the "Invalid" flag according to whether the buffer is invalid. This ensures that all accesses to an invalid buffer are marked invalid, improving recovery. llvm-svn: 98690
* Audit all getBuffer() callers (for both the FullSourceLoc andDouglas Gregor2010-03-161-7/+6
| | | | | | | SourceManager versions), updating those callers that need to recover gracefully from failure. llvm-svn: 98665
* Let SourceManager::getBufferData return StringRef instead of a pair of two ↵Benjamin Kramer2010-03-161-5/+3
| | | | | | const char*. llvm-svn: 98630
* Introduce optional "Invalid" parameters to routines that invoke theDouglas Gregor2010-03-161-25/+57
| | | | | | | | | | | | | SourceManager's getBuffer() and, therefore, could fail, along with Preprocessor::getSpelling(). Use the Invalid parameters in the literal parsers (string, floating point, integral, character) to make them robust against errors that stem from, e.g., PCH files that are not consistent with the underlying file system. I still need to audit every use caller to all of these routines, to determine which ones need specific handling of error conditions. llvm-svn: 98608
* Use SourceManager's Diagnostic object for all file-reading errors,Douglas Gregor2010-03-161-90/+33
| | | | | | simplifying the SourceManager interfaces somewhat. llvm-svn: 98598
* Give SourceManager a Diagnostic object with which to report errors,Douglas Gregor2010-03-161-13/+12
| | | | | | and start simplifying the interfaces in SourceManager that can fail. llvm-svn: 98594
* Add some <cstdio> includes to unbreak the buildbotsDouglas Gregor2010-03-151-0/+1
| | | | llvm-svn: 98591
* Introduce a new BufferResult class to act as the return type ofDouglas Gregor2010-03-151-11/+104
| | | | | | | | | | | | | | SourceManager's getBuffer() (and similar) operations. This abstract can be used to force callers to cope with errors in getBuffer(), such as missing files and changed files. Fix a bunch of callers to use the new interface. Add some very basic checks for file consistency (file size, modification time) into ContentCache::getBuffer(), although these checks don't help much until we've updated the main callers (e.g., SourceManager::getSpelling()). llvm-svn: 98585
* Fix -Wsign-compare warning reported by clang++.Ted Kremenek2010-03-101-1/+2
| | | | llvm-svn: 98170
* Robustify SourceManager::getLocation(), so that it returns anDouglas Gregor2010-02-271-14/+18
| | | | | | | | | end-of-line source location when given a column number beyond the length of the line, or an end-of-file source location when given a line number beyond the length of the file. Previously, we would return an invalid location. llvm-svn: 97299
* fix a bug in SourceManager::getInstantiationLocSlowCase, whereChris Lattner2010-02-121-3/+7
| | | | | | | | | | | we'd add an offset from the spelling location space to the instantiation location, which doesn't make sense and would lead up to the text diagnostics crashing when presented with non-sensical locations. This fixes rdar://7597492, a crash on 255.vortex. llvm-svn: 96004
* Add a pretty horrible hack to prevent clang from crashing with inconsistent PCHDaniel Dunbar2009-12-061-2/+18
| | | | | | | | | | | | | files. - The issue is that PCH uses a stat cache, which may reference files which have been deleted or moved. In such cases ContentCache::getBuffer was returning 0 but most clients are incapable of dealing with this (i.e., they don't). For the time being, resolve this issue by just making up some invalid file contents and. Eventually we should detect that we are in an inconsistent situation and error out with a nice message that the PCH is out of date. llvm-svn: 90699
* Minor cleanup to the code-completion-point logic suggested by Chris.Douglas Gregor2009-12-031-2/+1
| | | | llvm-svn: 90459
* Extend the source manager with the ability to override the contents ofDouglas Gregor2009-12-021-78/+28
| | | | | | | | | | files with the contents of an arbitrary memory buffer. Use this new functionality to drastically clean up the way in which we handle file truncation for code-completion: all of the truncation/completion logic is now encapsulated in the preprocessor where it belongs (<rdar://problem/7434737>). llvm-svn: 90300
* Eliminate the unnecessary FirstFID cache variable from the source manager's ↵Douglas Gregor2009-12-021-6/+27
| | | | | | ContentCache llvm-svn: 90294
* In SourceManager::isBeforeInTranslationUnit, if we are trying to compare two ↵Daniel Dunbar2009-12-011-24/+14
| | | | | | | | | | source locations with no common ancestor in the include stack, determine order by assuming memory buffers preceed files, and then that FileIDs are created in order. The later assumption is patently false, but this was already broken -- this situation is conceptually impossible, my feeling is we should fix SourceManager and friends to make it impossible in practice as well. However, we need to fix PR5662 and perhaps some other things involving memory buffers first. In the short term I'm pretty sure this is reliable. Chris, Argiris, is this going to break anything that wasn't already broken? llvm-svn: 90280
* pass the reason for failure up from MemoryBuffer and report itChris Lattner2009-12-011-2/+2
| | | | | | | | | | | | in diagnostics when we fail to open a file. This allows us to report things like: $ clang test.c -I. test.c:2:10: fatal error: error opening file './foo.h': Permission denied #include "foo.h" ^ llvm-svn: 90276
* Move DISABLE_INLINE to the front of the decl so MSVC can parse it. Patch by ↵Benjamin Kramer2009-11-141-2/+2
| | | | | | Amine Khaldi! llvm-svn: 88797
OpenPOWER on IntegriCloud