aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/SourceManager.cpp
AgeCommit message (Collapse)AuthorFilesLines
2015-11-12[Basic] Fix DRY violation, just call getLineTable() (NFC)Vedant Kumar1-8/+3
llvm-svn: 252828
2015-10-20Roll-back r250822.Angel Garcia Gomez1-1/+1
Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
2015-10-20Apply modernize-use-default to clang.Angel Garcia Gomez1-1/+1
Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
2015-10-03Replace double negation of !FileID.isInvalid() with FileID.isValid().Yaron Keren1-3/+3
+couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228. llvm-svn: 249235
2015-09-24Improve the printing of ranges when macros are involved.Richard Trieu1-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 llvm-svn: 248454
2015-08-14[modules] Add an experimental -cc1 feature to embed the contents of an inputRichard Smith1-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. llvm-svn: 245028
2015-08-13Add SourceManager::dump() to dump the current set of SLocEntries.Richard Smith1-0/+57
llvm-svn: 244852
2015-08-12[modules] If loading a .pcm file would cause us to run out of source ↵Richard Smith1-1/+3
locations, attempt to fail more gracefully. (No test; this requires >= 4GB of preprocessed input...) llvm-svn: 244822
2015-04-06Prefer uninitialized memory for scratch space.Benjamin Kramer1-2/+2
No functional change intended. llvm-svn: 234184
2015-03-16Global inline assembler blocks are merged before parsing, so no specificJoerg Sonnenberger1-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. llvm-svn: 232389
2014-11-19Standardize on StringMap::insert, removing uses of StringMap::GetOrCreateValue.David Blaikie1-11/+5
llvm-svn: 222306
2014-10-26Make VFS and FileManager match the current MemoryBuffer API.Benjamin Kramer1-10/+11
This eliminates converting back and forth between the 3 formats and gives us a more homogeneous interface. llvm-svn: 220657
2014-08-30Fix some cases where StringRef was being passed by const reference. Remove ↵Craig Topper1-1/+1
const from some other StringRefs since its implicitly const already. llvm-svn: 216825
2014-08-29unique_ptrify SourceManager::createFileIDDavid Blaikie1-3/+3
llvm-svn: 216715
2014-08-27Update for LLVM api change.Rafael Espindola1-4/+4
llvm-svn: 216585
2014-08-26Return a std::unique_ptr from getBufferForFile. NFC.Rafael Espindola1-3/+3
llvm-svn: 216476
2014-08-18Use std::unique_ptr to simplify this code a bit.Rafael Espindola1-11/+7
llvm-svn: 215926
2014-07-07Remove unused sys/stat.h includesAlp Toker1-1/+0
The facility was abstracted to LLVM in r187364. llvm-svn: 212441
2014-06-27Remove 'const' from MemoryBuffers used through the SourceManagerDavid Blaikie1-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. llvm-svn: 211915
2014-05-08[C++11] Use 'nullptr'.Craig Topper1-17/+18
llvm-svn: 208280
2014-04-15[Allocator] Make the ContentCache object actually carry the 8-byteChandler Carruth1-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. llvm-svn: 206324
2014-03-06Remove dead code I introduced 6 years, 4 months ago in r43518.Ted Kremenek1-25/+0
Found by -Wunreachable-code. llvm-svn: 203167
2014-03-02[C++11] Replace llvm::tie with std::tie.Benjamin Kramer1-2/+2
llvm-svn: 202639
2014-02-19Use llvm::DeleteContainerSeconds when possibleReid Kleckner1-4/+1
llvm-svn: 201739
2013-11-24Fix a typo: "SLocEnty" should read "SLocEntry".James Dennett1-1/+1
llvm-svn: 195563
2013-11-18Adding an assert to help catch possible buffer underruns.Aaron Ballman1-0/+4
llvm-svn: 195024
2013-09-27SourceManager: Open code isInMainFile.Benjamin Kramer1-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. llvm-svn: 191535
2013-07-29Simplified SourceManager::translateLineCol a bit.Alexander Kornienko1-6/+3
Reviewers: rsmith Reviewed By: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1183 llvm-svn: 187386
2013-07-29Update for llvm api change.Rafael Espindola1-5/+8
llvm-svn: 187379
2013-07-29Convert a use of status with llvm::sys::fs::getUniqueID.Rafael Espindola1-17/+16
llvm-svn: 187367
2013-06-07Thread the 'Invalid' out parameter through SourceManager::getSLocEntry() and ↵Argyrios Kyrtzidis1-1/+4
callees of SourceManager::getSLocEntryByID(). Also add an 'Invalid' check in SourceManager::computeMacroArgsCache(). llvm-svn: 183538
2013-05-25Make isBeforeInTranslationUnit consistent in the face of failures to get a ↵Argyrios Kyrtzidis1-1/+1
valid FileID (V2). llvm-svn: 182698
2013-05-24Make isBeforeInTranslationUnit consistent in the face of failures to get a ↵Argyrios Kyrtzidis1-1/+4
valid FileID. Suggested by Jordan. llvm-svn: 182695
2013-05-24Add some safety checks in a couple of SourceManager functions.Argyrios Kyrtzidis1-5/+14
This is to address crash in rdar://13932308 llvm-svn: 182681
2013-05-24Replace Count{Leading,Trailing}Zeros_{32,64} with count{Leading,Trailing}Zeros.Michael J. Spencer1-1/+1
llvm-svn: 182675
2013-05-16[Lexer] Improve Lexer::getSourceText() when the given range deals with ↵Argyrios Kyrtzidis1-0/+108
function macro arguments. This is a modified version of a patch by Manuel Klimek. llvm-svn: 182055
2013-04-13Introduce SourceManager::getDecomposedIncludedLoc, that returns the ↵Argyrios Kyrtzidis1-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. llvm-svn: 179435
2013-03-01Add one more sanity check in SourceManager::getFileIDLoaded().Argyrios Kyrtzidis1-0/+5
llvm-svn: 176333
2013-03-01In SourceManager::getFileIDLoaded(), add some sanity checks to make sure we ↵Argyrios Kyrtzidis1-0/+7
don't enter an infinite loop. rdar://13120919 llvm-svn: 176331
2013-02-27Refine SourceManager's isBeforeInTranslationUnit() cache to have more entries.Ted Kremenek1-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> llvm-svn: 176142
2013-02-22Replace some typically large vectors with SmallVector.Benjamin Kramer1-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. llvm-svn: 175906
2013-02-21Use None rather than Optional<T>() where possible.David Blaikie1-2/+2
llvm-svn: 175705
2013-02-20Include llvm::Optional in clang/Basic/LLVM.hDavid Blaikie1-8/+7
Post-commit CR feedback from Jordan Rose regarding r175594. llvm-svn: 175679
2013-01-12Fix -Wunused-comparison for comparisons in arguments to function-like macros.Matt Beaumont-Gay1-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. llvm-svn: 172279
2012-12-16Don't use SourceLineCache in getColumnNumber if LastLineNoResult is past the ↵Craig Topper1-1/+2
end of the cache. Fixes PR14570. llvm-svn: 170281
2012-12-04Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth1-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. llvm-svn: 169237
2012-11-14Add -cc1 option -fno-diagnostics-use-presumed-location, a handy mode forRichard Smith1-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). llvm-svn: 168004
2012-10-20When associating file ranges of macro arguments with theirArgyrios Kyrtzidis1-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 llvm-svn: 166359
2012-10-19Teach getColumnNumber to use the line cache to get the start of the line if ↵Craig Topper1-0/+11
its on the same line as the last call to getLineNumber. Prevents needing to scan backwards for the new line. Fixes PR14106. llvm-svn: 166265
2012-10-12Silence dead store warning. It is conceptually possible we willTed Kremenek1-0/+1
add more code that references SourceFile, so removing the dead store doesn't seem appropriate for the long term. llvm-svn: 165837