summaryrefslogtreecommitdiff
path: root/lib/Basic/SourceManager.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98690 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98665 91177308-0d34-0410-b5e6-96231b3b80d8
* Let SourceManager::getBufferData return StringRef instead of a pair of two ↵Benjamin Kramer2010-03-161-5/+3
| | | | | | const char*. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98630 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98608 91177308-0d34-0410-b5e6-96231b3b80d8
* Use SourceManager's Diagnostic object for all file-reading errors,Douglas Gregor2010-03-161-90/+33
| | | | | | | | simplifying the SourceManager interfaces somewhat. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98598 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98594 91177308-0d34-0410-b5e6-96231b3b80d8
* Add some <cstdio> includes to unbreak the buildbotsDouglas Gregor2010-03-151-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98591 91177308-0d34-0410-b5e6-96231b3b80d8
* 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()). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98585 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix -Wsign-compare warning reported by clang++.Ted Kremenek2010-03-101-1/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98170 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97299 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96004 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90699 91177308-0d34-0410-b5e6-96231b3b80d8
* Minor cleanup to the code-completion-point logic suggested by Chris.Douglas Gregor2009-12-031-2/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90459 91177308-0d34-0410-b5e6-96231b3b80d8
* 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>). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90300 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate the unnecessary FirstFID cache variable from the source manager's ↵Douglas Gregor2009-12-021-6/+27
| | | | | | ContentCache git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90294 91177308-0d34-0410-b5e6-96231b3b80d8
* 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? git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90280 91177308-0d34-0410-b5e6-96231b3b80d8
* 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" ^ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90276 91177308-0d34-0410-b5e6-96231b3b80d8
* Move DISABLE_INLINE to the front of the decl so MSVC can parse it. Patch by ↵Benjamin Kramer2009-11-141-2/+2
| | | | | | Amine Khaldi! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88797 91177308-0d34-0410-b5e6-96231b3b80d8
* pr5371 likely has nothing to do with this.Chris Lattner2009-11-031-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85862 91177308-0d34-0410-b5e6-96231b3b80d8
* Add note to FIXME about PR5371.Edward O'Callaghan2009-11-021-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85825 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace the -code-completion-dump option with Douglas Gregor2009-09-221-2/+79
| | | | | | | | | | | | -code-completion-at=filename:line:column which performs code completion at the specified location by truncating the file at that position and enabling code completion. This approach makes it possible to run multiple tests from a single test file, and gives a more natural command-line interface. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82571 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-100/+100
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81346 91177308-0d34-0410-b5e6-96231b3b80d8
* API changes to match llvm ToT.Chris Lattner2009-08-231-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79868 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace cerr with errs().Benjamin Kramer2009-08-231-11/+9
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79854 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix column checking for SourceManager::getLocation().Argyrios Kyrtzidis2009-06-251-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74194 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix warning when building w/o asserts.Daniel Dunbar2009-06-231-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74020 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce SourceManager::ísBeforeInTranslationUnit() which can compare 2 ↵Argyrios Kyrtzidis2009-06-231-0/+100
| | | | | | source locations and determine which one comes before the other, relative to the translation unit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74014 91177308-0d34-0410-b5e6-96231b3b80d8
* In SourceManager::createFileID missed setting ContentCache's FirstFID in ↵Argyrios Kyrtzidis2009-06-231-1/+4
| | | | | | another place. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73931 91177308-0d34-0410-b5e6-96231b3b80d8
* Slight modification to column checking inside SourceManager::getLocation().Argyrios Kyrtzidis2009-06-201-6/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73826 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce SourceManager::getLocation() to get a source location out of a ↵Argyrios Kyrtzidis2009-06-201-1/+41
| | | | | | "file:line:column" triplet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73823 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove dead code: 'NewEntry' is not used.Zhongxing Xu2009-06-071-3/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73027 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid potential out-of-bounds access in SourceManager::getLineNumber.Daniel Dunbar2009-05-181-1/+13
| | | | | | | - Chris, please see added FIXMEs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72019 91177308-0d34-0410-b5e6-96231b3b80d8
* Be more careful in our teardown of the PCHReader after deciding toDouglas Gregor2009-04-271-0/+16
| | | | | | | | ignore a PCH file. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70251 91177308-0d34-0410-b5e6-96231b3b80d8
* Load most of the source manager's information lazily from the PCHDouglas Gregor2009-04-271-4/+52
| | | | | | | | | | | | | | | | | | | | | file. In particular, only eagerly load source location entries for files and for the predefines buffer. Other buffers and macro-instantiation source location entries are loaded lazily. With the Cocoa-prefixed "Hello, World", we only load 815/26555 source location entities. This halves the amount of user time we spend in this "Hello, World" program with -fsyntax-only (down to .007s). This optimization is part 1 of 2 for the source manager. This eliminates most of the user time in loading a PCH file. We still spend too much time initialize File structures (especially in the calls to stat), so we need to either make the loading of source location entries for files lazy or import the stat cache from the PTH implementation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70196 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove the serialization code that predates precompiledDouglas Gregor2009-04-221-133/+1
| | | | | | | | headers. Future approaches to (de-)serializing ASTs will be based on the PCH infrastructure. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69828 91177308-0d34-0410-b5e6-96231b3b80d8
* Include the SourceManager's line table in the PCH file. We can nowDouglas Gregor2009-04-131-0/+11
| | | | | | | | properly cope with #line directives in PCH files. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68963 91177308-0d34-0410-b5e6-96231b3b80d8
* Factor the internals of SourceManager (specially, LineTableInfo) into a ↵Douglas Gregor2009-04-131-96/+1
| | | | | | separate Internals header. No functionality change git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68960 91177308-0d34-0410-b5e6-96231b3b80d8
* Resynchronize Decl/VarDecl serialization code with the structuresDouglas Gregor2009-04-021-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68346 91177308-0d34-0410-b5e6-96231b3b80d8
* Clear all the linetable state in clear(), fixing problemsChris Lattner2009-03-111-0/+1
| | | | | | | | with "clang t.i s.i" where the .i files contain line markers. rdar://6667812 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66619 91177308-0d34-0410-b5e6-96231b3b80d8
* add an accessor.Chris Lattner2009-02-171-0/+9
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64760 91177308-0d34-0410-b5e6-96231b3b80d8
* add an accessor.Chris Lattner2009-02-171-0/+12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64758 91177308-0d34-0410-b5e6-96231b3b80d8
* add a new SourceManager::getInstantiationRange helper method.Chris Lattner2009-02-151-0/+18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64606 91177308-0d34-0410-b5e6-96231b3b80d8
* track "just a little more" location information for macro instantiations.Chris Lattner2009-02-151-7/+18
| | | | | | | | | | | | | Now instead of just tracking the expansion history, also track the full range of the macro that got replaced. For object-like macros, this doesn't change anything. For _Pragma and function-like macros, this means we track the locations of the ')'. This is required for PR3579 because apparently GCC uses the line of the ')' of a function-like macro as the location to expand __LINE__ to. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64601 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the build on win32.Cedric Venet2009-02-141-0/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64556 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement handling of file entry/exit notifications from GNUChris Lattner2009-02-041-7/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | line markers, including maintenance of the virtual include stack. For something like this: # 42 "bar.c" 1 # 142 "bar2.c" 1 #warning zappa # 92 "bar.c" 2 #warning gonzo # 102 "foo.c" 2 #warning bonkta we now produce these three warnings: #1: In file included from foo.c:3: In file included from bar.c:42: bar2.c:143:2: warning: #warning zappa #warning zappa ^ #2: In file included from foo.c:3: bar.c:92:2: warning: #warning gonzo #warning gonzo ^ #3: foo.c:102:2: warning: #warning bonkta #warning bonkta ^ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63722 91177308-0d34-0410-b5e6-96231b3b80d8
* make getFileCharacteristic linetable aware. line markers that Chris Lattner2009-02-041-0/+32
| | | | | | | | play around with the 'is system header' bit now function correctly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63720 91177308-0d34-0410-b5e6-96231b3b80d8
* propagate linemarker flags down into the the line table, currentlyChris Lattner2009-02-041-6/+87
| | | | | | | ignoring include stack push/pop info though. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63719 91177308-0d34-0410-b5e6-96231b3b80d8
* replace gimpy linear search with svelte binary search ;-)Chris Lattner2009-02-041-7/+17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63717 91177308-0d34-0410-b5e6-96231b3b80d8
* make my atrocious linear search at least search in the order that isChris Lattner2009-02-041-5/+4
| | | | | | | more likely to hit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63714 91177308-0d34-0410-b5e6-96231b3b80d8
* add commentChris Lattner2009-02-041-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63712 91177308-0d34-0410-b5e6-96231b3b80d8