summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/SourceManager.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Don't use SourceLineCache in getColumnNumber if LastLineNoResult is past the ↵Craig Topper2012-12-161-1/+2
| | | | | | end of the cache. Fixes PR14570. llvm-svn: 170281
* 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. llvm-svn: 169237
* 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). llvm-svn: 168004
* 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 llvm-svn: 166359
* 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. llvm-svn: 166265
* 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. llvm-svn: 165837
* Dont cast away const needlessly. Found by gcc48 -Wcast-qual.Roman Divacky2012-09-061-1/+1
| | | | llvm-svn: 163325
* 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 llvm-svn: 160074
* Documentation cleanup: Delete a duplicated/malformed doc comment.James Dennett2012-07-021-2/+0
| | | | llvm-svn: 159628
* 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. llvm-svn: 158732
* Fix the location of the fixit for -Wnewline-eof.Jordan Rose2012-06-191-2/+3
| | | | | | | It turns out SourceManager treating the "one-past-the-end" location as invalid, but then failing to set the invalid flag properly. llvm-svn: 158699
* Documentation cleanup: escaped # characters in Doxygen comments.James Dennett2012-06-171-3/+3
| | | | llvm-svn: 158614
* Documentation cleanup: escape # in a Doxygen comment.James Dennett2012-06-151-1/+1
| | | | llvm-svn: 158549
* Switch LineTableInfo to use FileID instead of int for file references,Douglas Gregor2012-06-081-8/+8
| | | | | | from Tom Honermann! llvm-svn: 158211
* Add pedantic warning -Wempty-translation-unit (C11 6.9p1).Jordan Rose2012-06-061-0/+1
| | | | | | | | | | | | | | | | | | | In standard C since C89, a 'translation-unit' is syntactically defined to have at least one "external-declaration", which is either a decl or a function definition. In Clang the latter gives us a declaration as well. The tricky bit about this warning is that our predefines can contain external declarations (__builtin_va_list and the 128-bit integer types). Therefore our AST parser now makes sure we have at least one declaration that doesn't come from the predefines buffer. Also, remove bogus warning about empty source files. This doesn't catch source files that only contain comments, and never fired anyway because of our predefines. PR12665 and <rdar://problem/9165548> llvm-svn: 158085
* [PCH] When validating that the files coming from PCH did not change, alsoArgyrios Kyrtzidis2012-05-031-14/+37
| | | | | | | | | | | validate that we didn't override the contents of any of such files. If this is detected, emit a diagnostic error and recover gracefully by using the contents of the original file that the PCH was built from. Part of rdar://11305263 llvm-svn: 156107
* SourceManager: Vectorize ComputeLineNumbers for SSE2.Benjamin Kramer2012-04-061-2/+39
| | | | | | | | | | | | | | | | This method is very hot, it is called when emitting diagnostics, in -E mode and for many #pragma handlers. It scans through the whole source file to count newlines, records and caches them in a vector. The speedup from vectorization isn't very large, as we fall back to bytewise scanning when we hit a newline. There might be a way to avoid leaving the sse loop but everything I tried didn't work out because a call to push_back clobbers xmm registers. About 2% speedup on average on "clang -E > /dev/null" of all .cpp files in clang's lib/Sema. llvm-svn: 154204
* [PCH] Recover gracefully if the ASTReader detects that a file is differentArgyrios Kyrtzidis2012-02-201-1/+34
| | | | | | | | | | | | | | | | | | | from the one stored in the PCH/AST, while trying to load a SLocEntry. We verify that all files of the PCH did not change before loading it but this is not enough because: - The AST may have been 1) kept around, 2) to do queries on it. - We may have 1) verified the PCH and 2) started parsing. Between 1) and 2) files may change and we are going to have crashes because the rest of clang cannot deal with the ASTReader failing to read a SLocEntry. Handle this by recovering gracefully in such a case, by initializing the SLocEntry with the info from the PCH/AST as well as reporting failure by the ASTReader. rdar://10888929 llvm-svn: 151004
* Fix bugs in SourceManager::computeMacroArgsCache() and add a unit test for it.Argyrios Kyrtzidis2011-12-211-5/+22
| | | | llvm-svn: 147057
* For SourceManager::isBeforeInTranslationUnit(), have it consider macro arg ↵Argyrios Kyrtzidis2011-12-211-1/+1
| | | | | | | | | | expanded token locations as coming before the closing ')' of a function macro expansion. Include a unit test for SourceManager. llvm-svn: 147056
* SourceManager: use getBufferSize()Dylan Noblesmith2011-12-191-4/+5
| | | | | | | Forming an out of bounds pointer to check if it's out of bounds was undefined behavior. llvm-svn: 146861
* In SourceManager::~SourceManager do a sanity check to make sure weArgyrios Kyrtzidis2011-12-151-4/+8
| | | | | | | | don't try to destruct a null ContentCache. rdar://10567159 llvm-svn: 146707
* In ContentCache::replaceBuffer, add sanity check to make sure that we do not ↵Argyrios Kyrtzidis2011-12-101-1/+5
| | | | | | | | free a buffer and then continue using it. rdar://10359140. llvm-svn: 146308
* Add a sanity check in SourceManager::getColumnNumber, make sureArgyrios Kyrtzidis2011-12-101-1/+8
| | | | | | we don't try to access beyond the buffer. llvm-svn: 146305
* Implement (de-)serialization of the buffer contents for an overriddenDouglas Gregor2011-11-161-0/+1
| | | | | | | | | | file in the source manager. This allows us to properly create and use modules described by module map files without umbrella headers (or with incompletely umbrella headers). More generally, we can actually build a PCH file that makes use of file -> buffer remappings, which could be useful in libclang in the future. llvm-svn: 144830
* Use assert(0) instead of duplicating the check, suggestion by Anna.Argyrios Kyrtzidis2011-10-251-3/+3
| | | | llvm-svn: 142886
* Introduce SourceManager::getFileLoc which returns a file locationArgyrios Kyrtzidis2011-10-121-0/+10
| | | | | | taking into account macro arguments. llvm-svn: 141771
* Make sure SourceManager::getFileIDLoaded doesn't hang in release build ↵Argyrios Kyrtzidis2011-10-031-0/+4
| | | | | | | | because of invalid passed parameter. rdar://10210140 llvm-svn: 141048
* Break SourceManager::translateFileLineCol into translateFile, no ↵Argyrios Kyrtzidis2011-09-271-5/+16
| | | | | | functionality change. llvm-svn: 140610
* Associate the macro arguments location map with a FileID insteadArgyrios Kyrtzidis2011-09-261-17/+17
| | | | | | | of a ContentCache, since multiple FileIDs can have the same ContentCache but the expanded macro arguments locations will be different. llvm-svn: 140521
* Rename Diagnostic to DiagnosticsEngine as per issue 5397David Blaikie2011-09-251-4/+4
| | | | llvm-svn: 140478
* In SourceManager::translateLineCol, handle the case where we are pointingArgyrios Kyrtzidis2011-09-201-4/+9
| | | | | | directly at the end of the source file. llvm-svn: 140192
* [libclang] When getting a source location from a file:line:col tripletArgyrios Kyrtzidis2011-09-191-4/+8
| | | | | | | check whether the requested location points inside the precompiled preamble, in which case the returned source location will be a "loaded" one. llvm-svn: 140060
* Break SourceManager::translateFileLineCol into translateLineCol that returns theArgyrios Kyrtzidis2011-09-191-7/+22
| | | | | | source location of line:col of a specific FileID. llvm-svn: 140059
* Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset.Argyrios Kyrtzidis2011-09-191-8/+8
| | | | | | It already works (and is useful with) macro locs as well. llvm-svn: 140057
* For SourceManager::isBeforeInTranslationUnit, a location pointingArgyrios Kyrtzidis2011-09-191-1/+1
| | | | | | | inside a macro argument should be regarded as coming before the location of the expanded tokens. llvm-svn: 140053
* Remove one SourceManager::isInFileID overload and use isOffsetInFileID for ↵Argyrios Kyrtzidis2011-08-231-24/+0
| | | | | | the other. llvm-svn: 138381
* Amend r138129 (reduction of SLocEntries) which introduced performance ↵Argyrios Kyrtzidis2011-08-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | regression due to increased calls to SourceManager::getFileID. (rdar://9992664) Use a slightly different approach that is more efficient both in terms of speed (no extra getFileID calls) and in SLocEntries reduction. Comparing pre-r138129 and this patch we get: For compiling SemaExpr.cpp reduction of SLocEntries by 26%. For the boost enum library: -SLocEntries -34% (note that this was -5% for r138129) -Memory consumption -50% -PCH size -31% Reduced SLocEntries also benefit the hot function SourceManager::getFileID, evident by the reduced "FileID scans". llvm-svn: 138380
* Move a couple of SourceManager functions out-of-line; no functionality change.Argyrios Kyrtzidis2011-08-231-0/+43
| | | | llvm-svn: 138375
* Boost the efficiency of SourceManager::getMacroArgExpandedLocation.Argyrios Kyrtzidis2011-08-211-39/+101
| | | | | | | | | | | | | | | | | | Currently getMacroArgExpandedLocation is very inefficient and for the case of a location pointing at the main file it will end up checking almost all of the SLocEntries. Make it faster: -Use a map of macro argument chunks to their expanded source location. The map is for a single source file, it's stored in the file's ContentCache and lazily computed, like the source lines cache. -In SLocEntry's FileInfo add an 'unsigned NumCreatedFIDs' field that keeps track of the number of FileIDs (files and macros) that were created during preprocessing of that particular file SLocEntry. This is useful when computing the macro argument map in skipping included files while scanning for macro arg FileIDs that lexed from a specific source file. Due to padding, the new field does not increase the size of SLocEntry. llvm-svn: 138225
* Refactor common functionality into SourceManager::getFileIDSize, no ↵Argyrios Kyrtzidis2011-08-191-14/+1
| | | | | | functionality change. llvm-svn: 138127
* Introduce SourceManager::getMacroArgExpandedLocation function.Argyrios Kyrtzidis2011-08-171-6/+75
| | | | | | | | | | | | | | | | If we pass it a source location that points inside a function macro argument, the returned location will be the macro location in which the argument was expanded. If a macro argument is used multiple times, the expanded location will be at the first expansion of the argument. e.g. MY_MACRO(foo); ^ Passing a file location pointing at 'foo', will yield a macro location where 'foo' was expanded into. Make SourceManager::getLocation call getMacroArgExpandedLocation as well. llvm-svn: 137794
* Make SourceManager::isBeforeInTranslationUnit handle macro locations correctly.Argyrios Kyrtzidis2011-08-171-7/+3
| | | | llvm-svn: 137793
* Change SourceManager::getDataStructureSizes() to use llvm::capacity_in_bytes().Ted Kremenek2011-07-271-7/+8
| | | | llvm-svn: 136236
* clang_getCXTUResourceUsage: Report memory used by data structures in ↵Ted Kremenek2011-07-261-0/+8
| | | | | | SourceManager. llvm-svn: 136189
* Clean up as many of the comments in Basic I can find to talk in terms ofChandler Carruth2011-07-261-28/+25
| | | | | | 'expansion' rather than 'instantiation' for macro source locations. llvm-svn: 136058
* Migrate 'Instantiation' data and API bits of SLocEntry to 'Expansion'Chandler Carruth2011-07-261-17/+15
| | | | | | | | etc. With this I think essentially all of the SourceManager APIs are converted. Comments and random other bits of cleanup should be all thats left. llvm-svn: 136057
* Convert InstantiationInfo and much of the related code to ExpansionInfoChandler Carruth2011-07-261-17/+17
| | | | | | | | | and various other 'expansion' based terms. I've tried to reformat where appropriate and catch as many references in comments but I'm going to do several more passes. Also I've tried to expand parameter names to be more clear where appropriate. llvm-svn: 136056
* Rename create(MacroArg)InstantiationLoc to create(MacroArg)ExpansionLoc.Chandler Carruth2011-07-261-18/+20
| | | | llvm-svn: 136054
* Rename SourceManager (and InstantiationInfo) isMacroArgInstantiation APIChandler Carruth2011-07-261-2/+2
| | | | | | to isMacroArgExpansion. llvm-svn: 136053
OpenPOWER on IntegriCloud