summaryrefslogtreecommitdiff
path: root/lib/Basic/SourceManager.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Improve the printing of ranges when macros are involved.Richard Trieu2015-09-241-2/+7
| | | | | | | | | | | | | Trace the ranges through the macro backtrace better. This allows better range highlighting through all levels of the macro bracktrace. Also some improvements to backtrace printer for omitting different backtraces. Patch by Zhengkai Wu. Differential Revision: http://reviews.llvm.org/D12379 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248454 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] Add an experimental -cc1 feature to embed the contents of an inputRichard Smith2015-08-141-0/+7
| | | | | | | | | | | | file in the .pcm files. This allows a smaller set of files to be sent to a remote build worker when building with explicit modules (for instance, module map files need not be sent along with the corresponding precompiled modules). This doesn't actually make the embedded files visible to header search, so it's not useful as a packaging format for public header files. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245028 91177308-0d34-0410-b5e6-96231b3b80d8
* Add SourceManager::dump() to dump the current set of SLocEntries.Richard Smith2015-08-131-0/+57
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244852 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] If loading a .pcm file would cause us to run out of source ↵Richard Smith2015-08-121-1/+3
| | | | | | locations, attempt to fail more gracefully. (No test; this requires >= 4GB of preprocessed input...) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244822 91177308-0d34-0410-b5e6-96231b3b80d8
* Prefer uninitialized memory for scratch space.Benjamin Kramer2015-04-061-2/+2
| | | | | | No functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234184 91177308-0d34-0410-b5e6-96231b3b80d8
* Global inline assembler blocks are merged before parsing, so no specificJoerg Sonnenberger2015-03-161-14/+25
| | | | | | | | | | | | | | location data is available. If pragma handling wants to look up the position, it finds the LLVM buffer and wants to compare it with the special built-in buffer, failing badly. Extend to the special handling of the built-in buffer to also check for the inline asm buffer. Expect only a single asm buffer. Sort it between the built-in buffers and the normal file buffers. Fixes the assert part of PR 22576. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232389 91177308-0d34-0410-b5e6-96231b3b80d8
* Standardize on StringMap::insert, removing uses of StringMap::GetOrCreateValue.David Blaikie2014-11-191-11/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222306 91177308-0d34-0410-b5e6-96231b3b80d8
* Make VFS and FileManager match the current MemoryBuffer API.Benjamin Kramer2014-10-261-10/+11
| | | | | | | This eliminates converting back and forth between the 3 formats and gives us a more homogeneous interface. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220657 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix some cases where StringRef was being passed by const reference. Remove ↵Craig Topper2014-08-301-1/+1
| | | | | | const from some other StringRefs since its implicitly const already. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216825 91177308-0d34-0410-b5e6-96231b3b80d8
* unique_ptrify SourceManager::createFileIDDavid Blaikie2014-08-291-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216715 91177308-0d34-0410-b5e6-96231b3b80d8
* Update for LLVM api change.Rafael Espindola2014-08-271-4/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216585 91177308-0d34-0410-b5e6-96231b3b80d8
* Return a std::unique_ptr from getBufferForFile. NFC.Rafael Espindola2014-08-261-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216476 91177308-0d34-0410-b5e6-96231b3b80d8
* Use std::unique_ptr to simplify this code a bit.Rafael Espindola2014-08-181-11/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215926 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unused sys/stat.h includesAlp Toker2014-07-071-1/+0
| | | | | | The facility was abstracted to LLVM in r187364. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212441 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove 'const' from MemoryBuffers used through the SourceManagerDavid Blaikie2014-06-271-26/+21
| | | | | | | | | | | | | | This removes a const_cast added in r211884 that occurred due to an inconsistency in how MemoryBuffers are handled between some parts of clang and LLVM. MemoryBuffers are immutable and the general convention in the LLVM project is to omit const from immutable types as it's simply redundant/verbose (see llvm::Type, for example). While this change doesn't remove "const" from /every/ MemoryBuffer, it at least makes this chain of ownership/usage consistent. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211915 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Use 'nullptr'.Craig Topper2014-05-081-17/+18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208280 91177308-0d34-0410-b5e6-96231b3b80d8
* [Allocator] Make the ContentCache object actually carry the 8-byteChandler Carruth2014-04-151-12/+4
| | | | | | | | | alignment constraint rather than using the allocator function's over alignment "feature". This was the only use of the "feature" which I plan to remove next. =] Attaching the alignment to the type seems cleaner and more principled anyways. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206324 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove dead code I introduced 6 years, 4 months ago in r43518.Ted Kremenek2014-03-061-25/+0
| | | | | | Found by -Wunreachable-code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203167 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replace llvm::tie with std::tie.Benjamin Kramer2014-03-021-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202639 91177308-0d34-0410-b5e6-96231b3b80d8
* Use llvm::DeleteContainerSeconds when possibleReid Kleckner2014-02-191-4/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201739 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a typo: "SLocEnty" should read "SLocEntry".James Dennett2013-11-241-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195563 91177308-0d34-0410-b5e6-96231b3b80d8
* Adding an assert to help catch possible buffer underruns.Aaron Ballman2013-11-181-0/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195024 91177308-0d34-0410-b5e6-96231b3b80d8
* SourceManager: Open code isInMainFile.Benjamin Kramer2013-09-271-0/+30
| | | | | | | | | - We really shouldn't compute line numbers for every file that is asked if it's the main file, it destroys the lazy computation. - Invalid locations are no longer accounted to the main file, no other functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191535 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplified SourceManager::translateLineCol a bit.Alexander Kornienko2013-07-291-6/+3
| | | | | | | | | | | | Reviewers: rsmith Reviewed By: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1183 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187386 91177308-0d34-0410-b5e6-96231b3b80d8
* Update for llvm api change.Rafael Espindola2013-07-291-5/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187379 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert a use of status with llvm::sys::fs::getUniqueID.Rafael Espindola2013-07-291-17/+16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187367 91177308-0d34-0410-b5e6-96231b3b80d8
* Thread the 'Invalid' out parameter through SourceManager::getSLocEntry() and ↵Argyrios Kyrtzidis2013-06-071-1/+4
| | | | | | | | callees of SourceManager::getSLocEntryByID(). Also add an 'Invalid' check in SourceManager::computeMacroArgsCache(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183538 91177308-0d34-0410-b5e6-96231b3b80d8
* Make isBeforeInTranslationUnit consistent in the face of failures to get a ↵Argyrios Kyrtzidis2013-05-251-1/+1
| | | | | | valid FileID (V2). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182698 91177308-0d34-0410-b5e6-96231b3b80d8
* Make isBeforeInTranslationUnit consistent in the face of failures to get a ↵Argyrios Kyrtzidis2013-05-241-1/+4
| | | | | | | | valid FileID. Suggested by Jordan. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182695 91177308-0d34-0410-b5e6-96231b3b80d8
* Add some safety checks in a couple of SourceManager functions.Argyrios Kyrtzidis2013-05-241-5/+14
| | | | | | This is to address crash in rdar://13932308 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182681 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace Count{Leading,Trailing}Zeros_{32,64} with count{Leading,Trailing}Zeros.Michael J. Spencer2013-05-241-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182675 91177308-0d34-0410-b5e6-96231b3b80d8
* [Lexer] Improve Lexer::getSourceText() when the given range deals with ↵Argyrios Kyrtzidis2013-05-161-0/+108
| | | | | | | | function macro arguments. This is a modified version of a patch by Manuel Klimek. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182055 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce SourceManager::getDecomposedIncludedLoc, that returns the ↵Argyrios Kyrtzidis2013-04-131-11/+30
| | | | | | | | | "included/expanded in" decomposed location of the given FileID. The main benefit is to speed-up SourceManager::isBeforeInTranslationUnit which is common to query the included/expanded location of the same FileID multiple times. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179435 91177308-0d34-0410-b5e6-96231b3b80d8
* Add one more sanity check in SourceManager::getFileIDLoaded().Argyrios Kyrtzidis2013-03-011-0/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176333 91177308-0d34-0410-b5e6-96231b3b80d8
* In SourceManager::getFileIDLoaded(), add some sanity checks to make sure we ↵Argyrios Kyrtzidis2013-03-011-0/+7
| | | | | | | | don't enter an infinite loop. rdar://13120919 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176331 91177308-0d34-0410-b5e6-96231b3b80d8
* Refine SourceManager's isBeforeInTranslationUnit() cache to have more entries.Ted Kremenek2013-02-271-1/+31
| | | | | | | | | | | | | | | | | | | | | | isBeforeInTranslationUnit() uses a cache to reduce the expensive work to compute a common ancestor for two FileIDs. This work is very expensive, so even caching the latest used FileIDs was a big win. A closer analysis of the cache before, however, shows that the cache access pattern would oscillate between a working set of FileIDs, and thus caching more pairs would be profitable. This patch adds a side table for extending caching. This side table is bounded in size (experimentally determined in this case from a simple Objective-C project), and when the table gets too large we fall back to the single entry caching before as before. On Sketch (a small example Objective-C project), this optimization reduces -fsyntax-only time on SKTGraphicView.m by 5%. This is for a project that is already using PCH. Fixes <rdar://problem/13299847> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176142 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace some typically large vectors with SmallVector.Benjamin Kramer2013-02-221-1/+1
| | | | | | | | This may seem counter-intuitive but the POD-like optimization helps when the vectors grow into multimegabyte buffers. SmallVector calls realloc which knows how to twiddle virtual memory bits and avoids large copies. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175906 91177308-0d34-0410-b5e6-96231b3b80d8
* Use None rather than Optional<T>() where possible.David Blaikie2013-02-211-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175705 91177308-0d34-0410-b5e6-96231b3b80d8
* Include llvm::Optional in clang/Basic/LLVM.hDavid Blaikie2013-02-201-8/+7
| | | | | | Post-commit CR feedback from Jordan Rose regarding r175594. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175679 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix -Wunused-comparison for comparisons in arguments to function-like macros.Matt Beaumont-Gay2013-01-121-2/+9
| | | | | | | | | | | Previously, -Wunused-comparison ignored comparisons in both macro bodies and macro arguments, but we would still emit a -Wunused-value warning for either. Now we correctly emit -Wunused-comparison for expressions in macro arguments. Also, add isMacroBodyExpansion to SourceManager, to go along with isMacroArgExpansion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172279 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't use SourceLineCache in getColumnNumber if LastLineNoResult is past the ↵Craig Topper2012-12-161-1/+2
| | | | | | end of the cache. Fixes PR14570. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170281 91177308-0d34-0410-b5e6-96231b3b80d8
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-5/+5
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169237 91177308-0d34-0410-b5e6-96231b3b80d8
* Add -cc1 option -fno-diagnostics-use-presumed-location, a handy mode forRichard Smith2012-11-141-2/+3
| | | | | | | | | | working with preprocessed testcases. This causes source locations in diagnostics to point at the spelling location instead of the presumed location, while still keeping the semantic effects of the line directives (entering and leaving system-header mode, primarily). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168004 91177308-0d34-0410-b5e6-96231b3b80d8
* When associating file ranges of macro arguments with theirArgyrios Kyrtzidis2012-10-201-37/+82
| | | | | | | | | | macro expansion ranges, make sure to check all the FileID entries that are contained in the spelling range of the expansion for the macro argument. Fixes rdar://12537982 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166359 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach getColumnNumber to use the line cache to get the start of the line if ↵Craig Topper2012-10-191-0/+11
| | | | | | its on the same line as the last call to getLineNumber. Prevents needing to scan backwards for the new line. Fixes PR14106. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166265 91177308-0d34-0410-b5e6-96231b3b80d8
* Silence dead store warning. It is conceptually possible we willTed Kremenek2012-10-121-0/+1
| | | | | | | add more code that references SourceFile, so removing the dead store doesn't seem appropriate for the long term. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165837 91177308-0d34-0410-b5e6-96231b3b80d8
* Dont cast away const needlessly. Found by gcc48 -Wcast-qual.Roman Divacky2012-09-061-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163325 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce a flag in SourceManager to treat non-system source filesArgyrios Kyrtzidis2012-07-111-3/+11
| | | | | | | | | | | | | | | | | | | | as "volatile", meaning there's a high enough chance that they may change while we are trying to use them. This flag is only enabled by libclang. Currently "volatile" source files will be stat'ed immediately before opening them, because the file size stat info may not be accurate since when we got it (e.g. from the PCH). This avoids crashes when trying to reference mmap'ed memory from a file whose size is not what we expect. Note that there's still a window for a racing issue to occur but the window for it should be way smaller than before. We can consider later on to avoid mmap completely on such files. rdar://11612916 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160074 91177308-0d34-0410-b5e6-96231b3b80d8
* Documentation cleanup: Delete a duplicated/malformed doc comment.James Dennett2012-07-021-2/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159628 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert predefined decl tracking.Meador Inge2012-06-191-1/+0
| | | | | | | | | | | r158085 added some logic to track predefined declarations. The main reason we had predefined declarations in the input was because the __builtin_va_list declarations were injected into the preprocessor input. As of r158592 we explicitly build the __builtin_va_list declarations. Therefore the predefined decl tracking is no longer needed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158732 91177308-0d34-0410-b5e6-96231b3b80d8