summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/TokenLexer.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-2/+2
| | | | | | | | | | | | | 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
* Try to make the source location information for token pastes a bit more ↵Eli Friedman2012-12-011-0/+6
| | | | | | | | | consistent. Fixes a crash printing diagnostics on the gcc testsuite, and also makes diagnostic range printing print nicer results for token pastes. llvm-svn: 169068
* Improved support for removing the comma preceding __VA_ARGS__ where __VA_ARGS__Andy Gibbs2012-11-091-17/+64
| | | | | | | | | | is empty in a variadic macro expansion. This fixes a divergence in support for the ", ## __VA_ARGS__" GCC extension which differed in behaviour when in strict C99 mode (note: there is no change in behaviour has been made in the gnu99 mode that clang uses by default). In addition, there is improved support for the Microsoft alternative extension ", __VA_ARGS__". llvm-svn: 167613
* Revert r163022, it caused PR13924.Nico Weber2012-09-261-6/+0
| | | | | | | Add a test for PR13924. Do not revert the test added in r163022, it surprisingly still passes even after reverting the code changes. llvm-svn: 164672
* StringRef'ize Preprocessor::CreateString().Dmitri Gribenko2012-09-241-1/+1
| | | | llvm-svn: 164555
* Emulate MSVC's preprocessor macro argument separator behavior by not ↵Joao Matos2012-08-311-0/+6
| | | | | | considering commas from nested macro expansions as argument separators. Fixes parsing of VS 2012 headers. llvm-svn: 163022
* Make preprocessor act in a GCC-compatible fashion when a macro is redefinedRichard Smith2012-08-301-2/+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
* Fix a typo (the the => the)Sylvestre Ledru2012-07-231-1/+1
| | | | llvm-svn: 160622
* Minor improvements to some C99 variadic-macro-related diagnostics.Richard Smith2012-06-221-3/+3
| | | | llvm-svn: 159054
* Fix issue where a token paste which forms a /* or // would discard the rest ofRichard Smith2012-06-131-2/+2
| | | | | | | | the input: token-pasting was producing a tok::eof. Patch by Andy Gibbs! llvm-svn: 158412
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-4/+4
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Move a method from IdentifierTable.h out of line and remove the SmallString ↵Benjamin Kramer2012-02-041-1/+1
| | | | | | | | include. Fix all the transitive include users. llvm-svn: 149783
* Fixed exapnsion range for # and ##.Abramo Bagnara2011-10-031-8/+18
| | | | llvm-svn: 141012
* Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset.Argyrios Kyrtzidis2011-09-191-2/+2
| | | | | | It already works (and is useful with) macro locs as well. llvm-svn: 140057
* Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear ↵Francois Pichet2011-09-171-3/+3
| | | | | | | | that this flag must be used only for Microsoft extensions and not emulation; to avoid confusion with the new LangOptions::MicrosoftMode flag. Many of the code now under LangOptions::MicrosoftExt will eventually be moved under the LangOptions::MicrosoftMode flag. llvm-svn: 139987
* Silence 'may be used uninitialized' warnings.Argyrios Kyrtzidis2011-08-241-2/+2
| | | | llvm-svn: 138475
* Amend r138129 (reduction of SLocEntries) which introduced performance ↵Argyrios Kyrtzidis2011-08-231-18/+46
| | | | | | | | | | | | | | | | | | | | | | 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
* Introduce SourceManager::isInSLocAddrSpace and use it in TokenLexer instead ↵Argyrios Kyrtzidis2011-08-231-12/+9
| | | | | | | | of isInFileID since it is a bit more efficient. llvm-svn: 138379
* Rename SourceManager::isBeforeInSourceLocationOffset -> isBeforeInSLocAddrSpace.Argyrios Kyrtzidis2011-08-231-2/+1
| | | | llvm-svn: 138378
* TokenLexer::getExpansionLocForMacroDefLoc doesn't need to return an invalid ↵Argyrios Kyrtzidis2011-08-231-29/+16
| | | | | | SourceLocation. llvm-svn: 138377
* For assigning SourceLocations to macro arg tokens, reserve a single SLocEntryArgyrios Kyrtzidis2011-08-191-22/+69
| | | | | | | | | | | | | | for tokens that are lexed consecutively from the same FileID, instead of creating a SLocEntry for each token. e.g for assert(foo == bar); there will be a single SLocEntry for the "foo == bar" chunk and locations for the 'foo', '==', 'bar' tokens will point inside that chunk. For parsing SemaExpr.cpp, this reduced the number of SLocEntries by 25%. llvm-svn: 138129
* Rename TokenLexer::getMacroExpansionLocation -> ↵Argyrios Kyrtzidis2011-08-191-8/+10
| | | | | | getExpansionLocForMacroDefLoc, no functionality change. llvm-svn: 138128
* Rename create(MacroArg)InstantiationLoc to create(MacroArg)ExpansionLoc.Chandler Carruth2011-07-261-20/+19
| | | | llvm-svn: 136054
* Mechanically rename SourceManager::getInstantiationLoc andChandler Carruth2011-07-251-1/+1
| | | | | | | | FullSourceLoc::getInstantiationLoc to ...::getExpansionLoc. This is part of the API and documentation update from 'instantiation' as the term for macros to 'expansion'. llvm-svn: 135914
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-1/+1
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Revamp the SourceManager to separate the representation of parsedDouglas Gregor2011-07-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | source locations from source locations loaded from an AST/PCH file. Previously, loading an AST/PCH file involved carefully pre-allocating space at the beginning of the source manager for the source locations and FileIDs that correspond to the prefix, and then appending the source locations/FileIDs used for parsing the remaining translation unit. This design forced us into loading PCH files early, as a prefix, whic has become a rather significant limitation. This patch splits the SourceManager space into two parts: for source location "addresses", the lower values (growing upward) are used to describe parsed code, while upper values (growing downward) are used for source locations loaded from AST/PCH files. Similarly, positive FileIDs are used to describe parsed code while negative FileIDs are used to file/macro locations loaded from AST/PCH files. As a result, we can load PCH/AST files even during parsing, making various improvemnts in the future possible, e.g., teaching #include <foo.h> to look for and load <foo.h.gch> if it happens to be already available. This patch was originally written by Sebastian Redl, then brought forward to the modern age by Jonathan Turner, and finally polished/finished by me to be committed. llvm-svn: 135484
* Switch the TokenLexer's terminology from various forms of 'instantiate'Chandler Carruth2011-07-141-21/+21
| | | | | | | | | to 'expand' for macros. Only comments and uses local to the TokenLexer are updated. No functionality changed. llvm-svn: 135137
* Tweak formatting.Chandler Carruth2011-07-081-1/+1
| | | | llvm-svn: 134675
* Switch the token-paste source locations inside of function style macroChandler Carruth2011-07-081-3/+3
| | | | | | | | argument expansion to use the macro argument source locations as well. Add a few tests to exercise this. There is still a bit more work needed here though. llvm-svn: 134674
* Keep track of which source locations are part of a macro argumentChandler Carruth2011-07-071-3/+3
| | | | | | | | | | | | | | | | | | | | instantiation and improve diagnostics which are stem from macro arguments to trace the argument itself back through the layers of macro expansion. This requires some tricky handling of the source locations, as the argument appears to be expanded in the opposite direction from the surrounding macro. This patch provides helper routines that encapsulate the logic and explain the reasoning behind how we step through macros during diagnostic printing. This fixes the rest of the test cases originially in PR9279, and later split out into PR10214 and PR10215. There is still some more work we can do here to improve the macro backtrace, but those will follow as separate patches. llvm-svn: 134660
* Turn hashhash into tok::unkwown when it comes from expanding an argument, ↵Argyrios Kyrtzidis2011-07-071-8/+19
| | | | | | per Chris' suggestion. llvm-svn: 134621
* When expanding macro arguments, treat '##' coming from an argument as a ↵Argyrios Kyrtzidis2011-07-071-5/+12
| | | | | | | | | | | normal token. e.g. #define M(x) A x B M(##) // should expand to 'A ## B', not 'AB' llvm-svn: 134588
* Make the Preprocessor more memory efficient and improve macro instantiation ↵Argyrios Kyrtzidis2011-07-071-10/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | diagnostics. When a macro instantiation occurs, reserve a SLocEntry chunk with length the full length of the macro definition source. Set the spelling location of this chunk to point to the start of the macro definition and any tokens that are lexed directly from the macro definition will get a location from this chunk with the appropriate offset. For any tokens that come from argument expansion, '##' paste operator, etc. have their instantiation location point at the appropriate place in the instantiated macro definition (the argument identifier and the '##' token respectively). This improves macro instantiation diagnostics: Before: t.c:5:9: error: invalid operands to binary expression ('struct S' and 'int') int y = M(/); ^~~~ t.c:5:11: note: instantiated from: int y = M(/); ^ After: t.c:5:9: error: invalid operands to binary expression ('struct S' and 'int') int y = M(/); ^~~~ t.c:3:20: note: instantiated from: \#define M(op) (foo op 3); ~~~ ^ ~ t.c:5:11: note: instantiated from: int y = M(/); ^ The memory savings for a candidate boost library that abuses the preprocessor are: - 32% less SLocEntries (37M -> 25M) - 30% reduction in PCH file size (900M -> 635M) - 50% reduction in memory usage for the SLocEntry table (1.6G -> 800M) llvm-svn: 134587
* Introduce a caching mechanism for macro expanded tokens.Argyrios Kyrtzidis2011-06-291-9/+5
| | | | | | | | | | | | | | | 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
* revert r133003 and fix the bug properly: the issue was that ## in a tokenChris Lattner2011-06-141-5/+5
| | | | | | | | | | lexer is not a paste operator, it is a normal token. This fixes a conformance issue shown here: http://p99.gforge.inria.fr/c99-conformance/c99-conformance-clang-2.9.html and it defines away the crash from before. llvm-svn: 133005
* Fix a crash on the testcase in PR9981 / rdar://9486765.Chris Lattner2011-06-141-3/+4
| | | | llvm-svn: 133003
* Parsing/AST support for Structured Exception HandlingJohn Wiegley2011-04-281-5/+1
| | | | | | | | Patch authored by Sohail Somani. Provide parsing and AST support for Windows structured exception handling. llvm-svn: 130366
* Rename tok::eom to tok::eod.Peter Collingbourne2011-02-281-1/+1
| | | | | | | | 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
* Make TokenLexer capable of storing preprocessor directive tokensPeter Collingbourne2011-02-221-0/+5
| | | | llvm-svn: 126220
* Introduced raw_identifier token kind.Abramo Bagnara2010-12-221-4/+5
| | | | llvm-svn: 122394
* Rename alignof -> alignOf to avoid irritating C++'0x compilers,Chris Lattner2010-10-301-1/+1
| | | | | | PR8423 llvm-svn: 117775
* fix PR7943, a corner case with the GNU __VA_ARGS__ comma Chris Lattner2010-08-211-0/+7
| | | | | | swallowing extension. llvm-svn: 111701
* Random temporary string cleanup.Benjamin Kramer2010-08-111-1/+1
| | | | llvm-svn: 110807
* Add another terrible VC++ compatibility hack: allow users toChris Lattner2010-07-171-2/+7
| | | | | | | allow invalid token pastes (when in -fms-extensions mode) with -Wno-invalid-token-paste llvm-svn: 108624
* Audit all Preprocessor::getSpelling() callers, improving failureDouglas Gregor2010-03-161-3/+8
| | | | | | recovery for those that need it. llvm-svn: 98689
* Let SourceManager::getBufferData return StringRef instead of a pair of two ↵Benjamin Kramer2010-03-161-1/+1
| | | | | | const char*. llvm-svn: 98630
* Give SourceManager a Diagnostic object with which to report errors,Douglas Gregor2010-03-161-2/+3
| | | | | | and start simplifying the interfaces in SourceManager that can fail. llvm-svn: 98594
* Introduce a new BufferResult class to act as the return type ofDouglas Gregor2010-03-151-1/+4
| | | | | | | | | | | | | | 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
* Use SmallString instead of SmallVectorKovarththanan Rajaratnam2010-03-131-1/+1
| | | | llvm-svn: 98436
OpenPOWER on IntegriCloud