summaryrefslogtreecommitdiff
path: root/lib/Basic/SourceManager.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* add the difference in the line marker phys line number and theChris Lattner2009-02-041-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | query point to the returned presumed location. We now produce: foo.h:92:2: warning: #warning blarg! #warning blarg! ^ foo.h:93:2: warning: #warning blarg! #warning blarg! ^ foo.h:94:2: warning: #warning blarg! #warning blarg! ^ for: #line 92 "foo.h" #warning blarg! #warning blarg! #warning blarg! blarg indeed! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63710 91177308-0d34-0410-b5e6-96231b3b80d8
* add really really trivial #line support, where #line now makes every Chris Lattner2009-02-041-8/+54
| | | | | | | | | | | | | | | | | | | | | | location below it report as coming from the #line location. For example, with: #line 92 "foo.h" #warning blarg! #warning blarg! we now emit: foo.h:92:2: warning: #warning blarg! #warning blarg! ^ foo.h:92:2: warning: #warning blarg! #warning blarg! ^ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63709 91177308-0d34-0410-b5e6-96231b3b80d8
* lower the interface to getLineNumber like we did forChris Lattner2009-02-041-16/+23
| | | | | | | | | getColumnNumber. This fixes a FIXME in SourceManager::getPresumedLoc because we now just decompose the sloc once. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63701 91177308-0d34-0410-b5e6-96231b3b80d8
* make SM::getColumnNumber take a predecomposed FileID/offset, whichChris Lattner2009-02-041-15/+19
| | | | | | | | | makes it clear to clients that they have to pick an instantiation or spelling location before calling it and allows optimization based on that. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63698 91177308-0d34-0410-b5e6-96231b3b80d8
* build per-fid linetable entries.Chris Lattner2009-02-041-12/+39
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63694 91177308-0d34-0410-b5e6-96231b3b80d8
* more plumbing for #line propagation. Use happy bit #3 Chris Lattner2009-02-031-1/+21
| | | | | | | out of FileInfo :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63672 91177308-0d34-0410-b5e6-96231b3b80d8
* stub out basic #line handling calls.Chris Lattner2009-02-031-0/+9
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63667 91177308-0d34-0410-b5e6-96231b3b80d8
* reclaim my precious bit in FileInfo by ensuring that ContentCache objectsChris Lattner2009-02-031-7/+12
| | | | | | | are 8-byte aligned. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63630 91177308-0d34-0410-b5e6-96231b3b80d8
* switch SourceManager from using an std::map and std::list of Chris Lattner2009-02-031-27/+42
| | | | | | | | | | ContentCache objects to using a densemap and list, and allocating the ContentCache objects from a bump pointer. This does not speed up or slow down things substantially, but gives us control over their alignment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63628 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce a new PresumedLoc class to represent the concept of a locationChris Lattner2009-01-271-8/+21
| | | | | | | | | | | | | | | | | | | | | as reported to the user and as manipulated by #line. This is what __FILE__, __INCLUDE_LEVEL__, diagnostics and other things should follow (but not dependency generation!). This patch also includes several cleanups along the way: - SourceLocation now has a dump method, and several other places that did similar things now use it. - I cleaned up some code in AnalysisConsumer, but it should probably be simplified further now that NamedDecl is better. - TextDiagnosticPrinter is now simplified and cleaned up a bit. This patch is a prerequisite for #line, but does not actually provide any #line functionality. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63098 91177308-0d34-0410-b5e6-96231b3b80d8
* make -print-stats print stats about the amount of the SLoc Chris Lattner2009-01-271-2/+3
| | | | | | | | | | | | | | | | | | address space we used up. Some interesting data: For c99-intconst-1.c: 6912762 SLocEntry's allocated, 25592386B of Sloc address space used. For cocoa.h: 26469 SLocEntry's allocated, 10278752B of Sloc address space used. For carbon.h: 27364 SLocEntry's allocated, 12398141B of Sloc address space used. Clearly 2G of sloc address space should be enough for anyone?! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63093 91177308-0d34-0410-b5e6-96231b3b80d8
* now that everything properly handles multiply instantiatedChris Lattner2009-01-261-8/+0
| | | | | | | | source locations, allow creation of them. We can now say that a token was instantiated here, then here, then here. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63034 91177308-0d34-0410-b5e6-96231b3b80d8
* make getInstantiationLoc and getSpellingLoc handle multiply instantiatedChris Lattner2009-01-261-0/+21
| | | | | | | locations, and move the slow case out of line. No perf change on cocoa.h git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63033 91177308-0d34-0410-b5e6-96231b3b80d8
* fix a negated conditional in getDecomposedInstantiationLocSlowCase,Chris Lattner2009-01-261-7/+13
| | | | | | | | which I think is rdar://6527005, and make getDecomposedSpellingLocSlowCase handle nested spelling locations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63030 91177308-0d34-0410-b5e6-96231b3b80d8
* start plumbing together the line table information. So far we justChris Lattner2009-01-261-0/+76
| | | | | | | unique the Filenames in #line directives, assigning them UIDs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63010 91177308-0d34-0410-b5e6-96231b3b80d8
* Lazily paging in file contents is a big win for PTH, strip out the oldChris Lattner2009-01-261-20/+2
| | | | | | | testing code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63006 91177308-0d34-0410-b5e6-96231b3b80d8
* Check in the long promised SourceLocation rewrite. This lays theChris Lattner2009-01-261-149/+226
| | | | | | | | | | | | ground work for implementing #line, and fixes the "out of macro ID's" problem. There is nothing particularly tricky about the code, other than the very performance sensitive SourceManager::getFileID() method. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62978 91177308-0d34-0410-b5e6-96231b3b80d8
* remove the public SourceManager::getContentCacheForLoc method.Chris Lattner2009-01-191-1/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62497 91177308-0d34-0410-b5e6-96231b3b80d8
* SourceManager::getBufferData(SourceLocation) is dead, delete it.Chris Lattner2009-01-191-8/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62495 91177308-0d34-0410-b5e6-96231b3b80d8
* some minor cleanups to SourceManager, and eliminate the Chris Lattner2009-01-191-1/+1
| | | | | | | SourceManager::getBuffer(SourceLocation) method. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62494 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename SourceLocation::getFileID to getChunkID, because it returnsChris Lattner2009-01-171-6/+6
| | | | | | | | | the chunk ID not the file ID. This exposes problems in TextDiagnosticPrinter where it should have been using the canonical file ID but wasn't. Fix these along the way. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62427 91177308-0d34-0410-b5e6-96231b3b80d8
* this massive patch introduces a simple new abstraction: it makesChris Lattner2009-01-171-26/+35
| | | | | | | | | | | | | | | | | "FileID" a concept that is now enforced by the compiler's type checker instead of yet-another-random-unsigned floating around. This is an important distinction from the "FileID" currently tracked by SourceLocation. *That* FileID may refer to the start of a file or to a chunk within it. The new FileID *only* refers to the file (and its #include stack and eventually #line data), it cannot refer to a chunk. FileID is a completely opaque datatype to all clients, only SourceManager is allowed to poke and prod it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62407 91177308-0d34-0410-b5e6-96231b3b80d8
* make "ContentCache::Buffer" mutable to avoid a const_cast.Chris Lattner2009-01-171-3/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62403 91177308-0d34-0410-b5e6-96231b3b80d8
* more SourceLocation lexicon change: instead of referring to theChris Lattner2009-01-161-2/+2
| | | | | | | "logical" location, refer to the "instantiation" location. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62316 91177308-0d34-0410-b5e6-96231b3b80d8
* rename "virtual location" of a macro to "instantiation location".Chris Lattner2009-01-161-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62315 91177308-0d34-0410-b5e6-96231b3b80d8
* Change some terminology in SourceLocation: instead of referring to Chris Lattner2009-01-161-16/+16
| | | | | | | | the "physical" location of tokens, refer to the "spelling" location. This is more concrete and useful, tokens aren't really physical objects! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62309 91177308-0d34-0410-b5e6-96231b3b80d8
* SourceManager: Implement "lazy" creation of MemBuffers for source files.Ted Kremenek2009-01-061-5/+22
| | | | | | | | | | | | | | | | | | | | | | | | | - Big Idea: Source files are now mmaped when ContentCache::getBuffer() is first called. While this doesn't change the functionality when lexing regular source files, it can result in source files not being paged in when using PTH. - Performance change: - No observable difference (-fsyntax-only/-Eonly) on Cocoa.h when doing regular source lexing. - No observable time difference (-fsyntax-only/-Eonly) on Cocoa.h when using PTH. We do observe, however, a reduction of 279K in memory mapped source code (3% reduction). The majority of pages from Cocoa.h (and friends) are still being pulled in, however, because any literal will cause Preprocessor::getSpelling() to be called (causing the source for the file to get pulled in). The next possible optimization is to cache literal strings in the PTH file to avoid the need for the original header sources entirely. - Right now there is a preprocessor directive to toggle between "lazy" and "eager" creation of MemBuffers. This is not permanent, and is there in the short term to just test additional optimizations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61827 91177308-0d34-0410-b5e6-96231b3b80d8
* Misc changes to SourceManager::ContentCache:Ted Kremenek2009-01-061-8/+36
| | | | | | | | | | | | | | | - 'Buffer' is now private and must be accessed via 'getBuffer()'. This paves the way for lazily mapping in source files on demand. - Added 'getSize()' (which gets the size of the content without necessarily accessing the MemBuffer) and 'getSizeBytesMapped()'. - Modifed SourceManager to use these new methods. This reduces the number of places that actually access the MemBuffer object for a file to those that actually look at the character data. These changes result in no performance change for -fsyntax-only on Cocoa.h. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61782 91177308-0d34-0410-b5e6-96231b3b80d8
* SourceManager::getLineNumber is logically const except for caching.Chris Lattner2008-11-181-1/+1
| | | | | | | Use mutable to make it so. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59498 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename Characteristic_t to CharacteristicKindChris Lattner2008-10-271-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58224 91177308-0d34-0410-b5e6-96231b3b80d8
* whitespace and comment changes, to fix grammar and 80 col violationsNico Weber2008-09-291-4/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56776 91177308-0d34-0410-b5e6-96231b3b80d8
* clean up a bunch of fixme's I added, by moving Chris Lattner2008-09-261-3/+3
| | | | | | | DirectoryLookup::DirType into SourceManager.h git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56692 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the rest of rdar://6243860 hopefully. This requires changing FileIDInfoChris Lattner2008-09-261-3/+3
| | | | | | | | | | | | to whether the fileid is a 'extern c system header' in addition to whether it is a system header, most of this is spreading plumbing around. Once we have that, PPLexerChange bases its "file enter/exit" notifications to PPCallbacks to base the system header state on FileIDInfo instead of HeaderSearch. Finally, in Preprocessor::HandleIncludeDirective, mirror logic in GCC: the system headerness of a file being entered can be set due to the #includer or the #includee. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56688 91177308-0d34-0410-b5e6-96231b3b80d8
* * Remove isInSystemHeader() from DiagClient, move it to SourceManagerNico Weber2008-08-101-3/+5
| | | | | | | | | | | | | | | | | | | * Move FormatError() from TextDiagnostic up to DiagClient, remove now empty class TextDiagnostic * Make DiagClient optional for Diagnostic This fixes the following problems: * -html-diags (and probably others) does now output the same set of warnings as console clang does * nothing crashes if one forgets to call setHeaderSearch() on TextDiagnostic * some code duplication is removed git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54620 91177308-0d34-0410-b5e6-96231b3b80d8
* Update to match simplified llvm MemoryBuffer interfaces for files.Chris Lattner2008-04-011-2/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49042 91177308-0d34-0410-b5e6-96231b3b80d8
* prune dead #includesChris Lattner2008-04-011-2/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49033 91177308-0d34-0410-b5e6-96231b3b80d8
* MemoryBuffer::getFile got smarter, obviating the need for readfilefast.Chris Lattner2008-04-011-60/+3
| | | | | | | | The new MemoryBuffer doesn't "leak" file descriptors and handles the small file case efficiently. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49032 91177308-0d34-0410-b5e6-96231b3b80d8
* Hack ReadFileFast() to raise the threshold of memory mapped files (from ↵Steve Naroff2008-03-311-1/+1
| | | | | | | | | | | 4->12 pages). This is a temporary solution to avoid running out of file descriptors (which defaults to 256). Need to benchmark to understand the speed benefit. If the benefit is small, the simple solution is to avoid memory mapping files. If the benefit is significant, more thought is necessary. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48991 91177308-0d34-0410-b5e6-96231b3b80d8
* Make a major restructuring of the clang tree: introduce a top-levelChris Lattner2008-03-151-0/+574
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48402 91177308-0d34-0410-b5e6-96231b3b80d8