summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPLexerChange.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-4/+4
| | | | | | | | | | | | | 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
* Make preprocessor act in a GCC-compatible fashion when a macro is redefinedRichard Smith2012-08-301-3/+3
| | | | | | | | within its own argument list. The original definition is used for the immediate expansion, but the new definition is used for any subsequent occurences within the argument list or after the expansion. llvm-svn: 162906
* Documentation cleanup: escape # characters in Doxygen comments as needed.James Dennett2012-06-221-1/+1
| | | | llvm-svn: 158970
* From Vassil Vassilev:Axel Naumann2012-03-161-4/+6
| | | | | | | | | | | | | | Enable incremental parsing by the Preprocessor, where more code can be provided after an EOF. It mainly prevents the tearing down of the topmost lexer. To be used like this: PP.enableIncrementalProcessing(); while (getMoreSource()) { while (Parser.ParseTopLevelDecl(ADecl)) {...} } PP.enableIncrementalProcessing(false); llvm-svn: 152914
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-2/+2
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Implement support for module requirements, which indicate the languageDouglas Gregor2011-12-311-8/+11
| | | | | | | | | features needed for a particular module to be available. This allows mixed-language modules, where certain headers only work under some language variants (e.g., in C++, std.tuple might only be available in C++11 mode). llvm-svn: 147387
* Remove spurious, but now legal, typenameDouglas Gregor2011-12-231-1/+1
| | | | llvm-svn: 147208
* When building a module with an umbrella header, warn about any headersDouglas Gregor2011-12-231-0/+67
| | | | | | | | found within that umbrella directory that were not actually included by the umbrella header. They should either be referenced in the module map or included by the umbrella header. llvm-svn: 147207
* Don't mark include guard macros as implicitly private. This isn'tDouglas Gregor2011-12-121-21/+1
| | | | | | | actually a terribly good heuristic, and the world is too horrible for it to work. llvm-svn: 146393
* Argyrios says this change is required for safety under PTH.John McCall2011-10-181-1/+1
| | | | | | Me, I believe him. llvm-svn: 142327
* Fix several bugs with #pragma clang arc_cf_code_audited and macros.John McCall2011-10-181-2/+5
| | | | llvm-svn: 142324
* For modules, all macros that aren't include guards are implicitlyDouglas Gregor2011-10-171-1/+22
| | | | | | | public. Add a __private_macro__ directive to hide a macro, similar to the __module_private__ declaration specifier. llvm-svn: 142188
* For the FileChanged Preprocessor callback, when exiting a file, pass its FileID.Argyrios Kyrtzidis2011-10-111-1/+5
| | | | llvm-svn: 141681
* Add explicit attributes to mark functions as having had theirJohn McCall2011-09-301-0/+8
| | | | | | | | | | | CoreFoundation object-transfer properties audited, and add a #pragma to cause them to be automatically applied to functions in a particular span of code. This has to be implemented largely in the preprocessor because of the requirement that the region be entirely contained in a single file; that's hard to impose from the parser without registering for a ton of callbacks. llvm-svn: 140846
* Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset.Argyrios Kyrtzidis2011-09-191-1/+1
| | | | | | It already works (and is useful with) macro locs as well. llvm-svn: 140057
* Optimize the preprocessor's handling of the __import_module__Douglas Gregor2011-09-071-2/+10
| | | | | | | | | | | | keyword. We now handle this keyword in HandleIdentifier, making a note for ourselves when we've seen the __import_module__ keyword so that the next lexed token can trigger a module import (if needed). This greatly simplifies Preprocessor::Lex(), and completely erases the 5.5% -Eonly slowdown Argiris noted when I originally implemented __import_module__. Big thanks to Argiris for noting that horrible regression! llvm-svn: 139265
* Support code-completion for C++ inline methods and ObjC buffering methods.Argyrios Kyrtzidis2011-09-041-1/+27
| | | | | | | | | | | | | | Previously we would cut off the source file buffer at the code-completion point; this impeded code-completion inside C++ inline methods and, recently, with buffering ObjC methods. Have the code-completion inserted into the source buffer so that it can be buffered along with a method body. When we actually hit the code-completion point the cut-off lexing or parsing. Fixes rdar://10056932&8319466 llvm-svn: 139086
* Boost the efficiency of SourceManager::getMacroArgExpandedLocation.Argyrios Kyrtzidis2011-08-211-0/+10
| | | | | | | | | | | | | | | | | | 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
* Introduce a caching mechanism for macro expanded tokens.Argyrios Kyrtzidis2011-06-291-0/+4
| | | | | | | | | | | | | | | Previously macro expanded tokens were added to Preprocessor's bump allocator and never released, even after the TokenLexer that were lexing them was finished, thus they were wasting memory. A very "useful" boost library was causing clang to eat 1 GB just for the expanded macro tokens. Introduce a special cache that works like a stack; a TokenLexer can add the macro expanded tokens in the cache, and when it finishes, the tokens are removed from the end of the cache. Now consumed memory by expanded tokens for that library is ~ 1.5 MB. Part of rdar://9327049. llvm-svn: 134105
* Rename tok::eom to tok::eod.Peter Collingbourne2011-02-281-10/+10
| | | | | | | | The previous name was inaccurate as this token in fact appears at the end of every preprocessing directive, not just macro definitions. No functionality change, except for a diagnostic tweak. llvm-svn: 126631
* Fix diagnostic pragmas.Argyrios Kyrtzidis2010-12-151-9/+5
| | | | | | | | | | | | Diagnostic pragmas are broken because we don't keep track of the diagnostic state changes and we only check the current/latest state. Problems manifest if a diagnostic is emitted for a source line that has different diagnostic state than the current state; this can affect a lot of places, like C++ inline methods, template instantiations, the lexer, etc. Fix the issue by having the Diagnostic object keep track of the source location of the pragmas so that it is able to know what is the diagnostic state at any given source location. Fixes rdar://8365684. llvm-svn: 121873
* push some source location information down through the compiler,Chris Lattner2010-04-201-8/+12
| | | | | | | | into ContentCache::getBuffer. This allows it to produce diagnostics on the broken #include line instead of without a location. llvm-svn: 101939
* PPCallbacks: Add hook for reaching the end of the main file, and fix ↵Daniel Dunbar2010-03-231-0/+1
| | | | | | DependencyFile to not do work in its destructor. llvm-svn: 99257
* Audit all getBuffer() callers (for both the FullSourceLoc andDouglas Gregor2010-03-161-2/+4
| | | | | | | SourceManager versions), updating those callers that need to recover gracefully from failure. llvm-svn: 98665
* Use SourceManager's Diagnostic object for all file-reading errors,Douglas Gregor2010-03-161-2/+1
| | | | | | simplifying the SourceManager interfaces somewhat. llvm-svn: 98598
* Introduce a new BufferResult class to act as the return type ofDouglas Gregor2010-03-151-3/+3
| | | | | | | | | | | | | | 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()). llvm-svn: 98585
* Teach Preprocessor::macro_begin/macro_end to lazily load all macroDouglas Gregor2010-01-041-1/+2
| | | | | | | | definitions from a precompiled header. This ensures that code-completion with macro names behaves the same with or without precompiled headers. llvm-svn: 92497
* Unbreak and add test case for r90276, a situation in which getBuffer is ↵Daniel Dunbar2009-12-061-1/+1
| | | | | | | | expected to fail. Also, update SourceManager.h doxyments for getBuffer() to reflect reality. llvm-svn: 90701
* Change Preprocessor::EnterSourceFile to make ErrorStr non-optional, clients ↵Daniel Dunbar2009-12-061-2/+2
| | | | | | should be forced to deal with error conditions. llvm-svn: 90700
* pass the reason for failure up from MemoryBuffer and report itChris Lattner2009-12-011-2/+4
| | | | | | | | | | | | 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" ^ llvm-svn: 90276
* Fix PR5633 by making the preprocessor handle the case where we canChris Lattner2009-11-301-4/+13
| | | | | | | | | | stat a file but where mmaping it fails. In this case, we emit an error like: t.c:1:10: fatal error: error opening file '../../foo.h' instead of "cannot find file". llvm-svn: 90110
* remove stall commentNuno Lopes2009-11-291-2/+1
| | | | llvm-svn: 90080
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-34/+34
| | | | llvm-svn: 81346
* Add PCH support for #import.Steve Naroff2009-04-241-1/+1
| | | | llvm-svn: 69987
* when preprocessing a .S file, unknown directives should just be passed through,Chris Lattner2009-03-181-1/+0
| | | | | | | | | | | | | | and the token after the # should be expanded if it is not a valid directive. This allows us to transform things like: #define FOO BAR # FOO into # BAR, even though FOO is not normally expanded for directives. This should fix PR3833 llvm-svn: 67236
* use accessor instead of poking ivar directlyChris Lattner2009-03-131-1/+2
| | | | llvm-svn: 66954
* track "just a little more" location information for macro instantiations.Chris Lattner2009-02-151-3/+4
| | | | | | | | | | | | 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. llvm-svn: 64601
* add an assertion from Alexei Svitkine!Chris Lattner2009-02-131-2/+2
| | | | llvm-svn: 64503
* add interface for walking macro table.Chris Lattner2009-02-061-3/+1
| | | | llvm-svn: 63925
* move library-specific diagnostic headers into library private dirs. ReduceChris Lattner2009-01-291-1/+1
| | | | | | redundant #includes. Patch by Anders Johnsen! llvm-svn: 63271
* Split the single monolithic DiagnosticKinds.def file into oneChris Lattner2009-01-271-1/+1
| | | | | | | | | .def file for each library. This means that adding a diagnostic to sema doesn't require all the other libraries to be rebuilt. Patch by Anders Johnsen! llvm-svn: 63111
* do not use SourceManager::getFileCharacteristic(FileID), it is notChris Lattner2009-01-191-6/+7
| | | | | | | safe because a #line can change the file characteristic on a per-loc basis. llvm-svn: 62502
* simplify PTHManager::CreateLexerChris Lattner2009-01-171-1/+1
| | | | llvm-svn: 62424
* Change the Lexer ctor used in the non _Pragma case to take a FileID insteadChris Lattner2009-01-171-9/+3
| | | | | | of a SourceLocation. This should speed it up and definitely simplifies it. llvm-svn: 62422
* this massive patch introduces a simple new abstraction: it makesChris Lattner2009-01-171-9/+6
| | | | | | | | | | | | | | | "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. llvm-svn: 62407
* Remove old PTH token-generation test harness.Ted Kremenek2008-12-231-71/+0
| | | | llvm-svn: 61382
* PTH: Remove some methods and simplify some conditions in PTHLexer::Lex(). ↵Ted Kremenek2008-12-231-1/+1
| | | | | | No big functionality change. llvm-svn: 61381
* PreprocessorLexer (and subclasses):Ted Kremenek2008-12-101-10/+2
| | | | | | | | - Added virtual method 'getSourceLocation()' (no arguments) that gets the location of the next "observable" location (e.g., next character, next token). PPLexerChange.cpp: - Implemented FIXME by using PreprocessorLexer::getSourceLocation() to get the location in the file we are returning to after lexing a #included file. This appears to be slightly faster than having the branch (i.e., 'if(CurLexer)'). It's also not a really hot part of the Preprocessor. llvm-svn: 60860
* Preprocessor:Ted Kremenek2008-12-021-2/+32
| | | | | | | | | - Added method "setPTHManager" that will be called by the driver to install a PTHManager for the Preprocessor. - Fixed some comments. - Added EnterSourceFileWithPTH to mirror EnterSourceFileWithLexer. llvm-svn: 60437
* PTHLexer now owns the Token vector.Ted Kremenek2008-11-271-12/+14
| | | | llvm-svn: 60136
OpenPOWER on IntegriCloud