summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Lexer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* allow _Pragmas formed from #defines to keep their full instantiationChris Lattner2009-01-261-2/+1
| | | | | | history llvm-svn: 63035
* This change refactors some of the low-level lexer interfaces a bit.Chris Lattner2009-01-261-3/+10
| | | | | | | | | | | | | Token now has a class of kinds for "literals", which include numeric constants, strings, etc. These tokens can optionally have a pointer to the start of the token in the lexer buffer. This makes it faster to get spelling and do other gymnastics, because we don't have to go through source locations. This change is performance neutral, but will make other changes more feasible down the road. llvm-svn: 63028
* Check in the long promised SourceLocation rewrite. This lays theChris Lattner2009-01-261-12/+13
| | | | | | | | | | ground work for implementing #line, and fixes the "out of macro ID's" problem. There is nothing particularly tricky about the code, other than the very performance sensitive SourceManager::getFileID() method. llvm-svn: 62978
* This is a follow-up to r62675:Chris Lattner2009-01-231-0/+4
| | | | | | | | | | Refactor how the preprocessor changes a token from being an tok::identifier to a keyword (e.g. tok::kw_for). Instead of doing this in HandleIdentifier, hoist this common case out into the caller, so that every keyword doesn't have to go through HandleIdentifier. This drops time in HandleIdentifier from 1.25ms to .62ms, and speeds up clang -Eonly with PTH by about 1%. llvm-svn: 62855
* a trivial micro optimization to save a load.Chris Lattner2009-01-211-2/+2
| | | | llvm-svn: 62676
* Add a bit to IdentifierInfo that acts as a simple predicate whichChris Lattner2009-01-211-1/+3
| | | | | | | | | tells us whether Preprocessor::HandleIdentifier needs to be called. Because this method is only rarely needed, this saves a call and a bunch of random checks. This drops the time in HandleIdentifier from 3.52ms to .98ms on cocoa.h on my machine. llvm-svn: 62675
* Rename SourceManager::getCanonicalFileID -> getFileID. There isChris Lattner2009-01-191-1/+1
| | | | | | no longer such thing as a non-canonical FileID. llvm-svn: 62499
* Make SourceLocation::getFileLoc private to reduce the API exposure of Chris Lattner2009-01-191-7/+9
| | | | | | | SourceLocation. This requires making some cleanups to token pasting and _Pragma expansion. llvm-svn: 62490
* Rename SourceLocation::getFileID to getChunkID, because it returnsChris Lattner2009-01-171-2/+2
| | | | | | | | the chunk ID not the file ID. This exposes problems in TextDiagnosticPrinter where it should have been using the canonical file ID but wasn't. Fix these along the way. llvm-svn: 62427
* simplify some lookups.Chris Lattner2009-01-171-4/+4
| | | | llvm-svn: 62426
* Change the Lexer ctor used to lex _Pragma directives into a static factoryChris Lattner2009-01-171-21/+44
| | | | | | | | | | | method. This lets us clean up the interface and make it more obvious that this method is *really really* _Pragma specific. Note that _Pragma handling uglifies the Lexer in the critical path. It would be very interesting to consider making _Pragma remapping be a new special lexer class of its own. llvm-svn: 62425
* Change the Lexer ctor used in the non _Pragma case to take a FileID insteadChris Lattner2009-01-171-11/+6
| | | | | | of a SourceLocation. This should speed it up and definitely simplifies it. llvm-svn: 62422
* More simplifications to the lexer ctors.Chris Lattner2009-01-171-10/+24
| | | | llvm-svn: 62419
* make the verbose raw-lexer ctor fully explicit instead of havingChris Lattner2009-01-171-9/+3
| | | | | | embedded magic. llvm-svn: 62417
* add a simplified lexer ctor that sets up the lexer to raw-lex anChris Lattner2009-01-171-1/+14
| | | | | | entire file. llvm-svn: 62414
* refactor some common initialization code out of the two lexer ctors.Chris Lattner2009-01-171-52/+45
| | | | llvm-svn: 62411
* this massive patch introduces a simple new abstraction: it makesChris Lattner2009-01-171-10/+14
| | | | | | | | | | | | | | | "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
* Instead of iterating over FileID's, have PTH generation iterate over theChris Lattner2009-01-171-2/+1
| | | | | | | content cache directly. Content cache has a 1-1 mapping with fileentries, whereas multiple FileIDs can be the same FileEntry. llvm-svn: 62401
* Fix PR2477 - clang misparses "//*" in C89 modeChris Lattner2009-01-161-9/+24
| | | | llvm-svn: 62368
* more SourceLocation lexicon change: instead of referring to theChris Lattner2009-01-161-4/+4
| | | | | | "logical" location, refer to the "instantiation" location. llvm-svn: 62316
* Change some terminology in SourceLocation: instead of referring to Chris Lattner2009-01-161-6/+6
| | | | | | | the "physical" location of tokens, refer to the "spelling" location. This is more concrete and useful, tokens aren't really physical objects! llvm-svn: 62309
* rdar://6060752 - don't warn about trigraphs in bcpl-style commentsChris Lattner2008-12-121-1/+6
| | | | llvm-svn: 60942
* fix thought-oChris Lattner2008-12-121-1/+1
| | | | llvm-svn: 60937
* Objective-C keywords are not always identifiers. Some are also C++ keywordsDouglas Gregor2008-12-011-2/+3
| | | | llvm-svn: 60373
* Comment fix.Daniel Dunbar2008-11-251-1/+1
| | | | llvm-svn: 59997
* Fix a weird inconsistency with hex floats. Previously the lexer Chris Lattner2008-11-221-2/+2
| | | | | | | | | would not eat the "-1" in "0x0p-1", but LiteralSupport would accept it when extensions are on. This caused strangeness and failures when hexfloats were properly treated as an extension (not error) in LiteralSupport. llvm-svn: 59865
* actually, this version isn't really needed.Chris Lattner2008-11-221-6/+2
| | | | llvm-svn: 59859
* remove a sneaky version of Diag hiding in PreprocessorLexer.Chris Lattner2008-11-221-3/+6
| | | | llvm-svn: 59858
* Change the Lexer::Diag method to not magically silence warnings,Chris Lattner2008-11-221-27/+46
| | | | | | | force the caller to check instead. This eliminates the need (and the risk!) of weird null DiagnosticBuilder's floating around. llvm-svn: 59856
* Split the DiagnosticInfo class into two disjoint classes:Chris Lattner2008-11-221-2/+2
| | | | | | | | | | one for building up the diagnostic that is in flight (DiagnosticBuilder) and one for pulling structured information out of the diagnostic when formatting and presenting it. There is no functionality change with this patch. llvm-svn: 59849
* - Move static function IsNonPragmaNonMacroLexer into Preprocessor.h.Ted Kremenek2008-11-191-2/+5
| | | | | | | | | | | | | - Add variants of IsNonPragmaNonMacroLexer to accept an IncludeMacroStack entry (simplifies some uses). - Use IsNonPragmaNonMacroLexer in Preprocessor::LookupFile. - Add 'FileID' to PreprocessorLexer, and have Preprocessor query this fileid when looking up the FileEntry for a file Performance testing of -Eonly on Cocoa.h shows no performance regression because of this patch. llvm-svn: 59666
* Convert the lexer and start converting the PP over to using canonical Diag ↵Chris Lattner2008-11-181-11/+10
| | | | | | methods. llvm-svn: 59511
* Move some diagnostic handling to PreprocessorLexer.Ted Kremenek2008-11-121-10/+5
| | | | llvm-svn: 59191
* Remove Lexer::LexIncludeFilename.Ted Kremenek2008-11-121-21/+0
| | | | llvm-svn: 59186
* Change FormTokenWithChars to take the token kind to form, since all clientsChris Lattner2008-10-121-126/+107
| | | | | | | were setting a kind and then forming it. This is just a minor API cleanup, no functionality change. llvm-svn: 57404
* When in keep whitespace mode, make sure to return block comments that areChris Lattner2008-10-121-2/+22
| | | | | | unterminated. llvm-svn: 57403
* Change SkipBlockComment and SkipBCPLComment to return true when inChris Lattner2008-10-121-18/+22
| | | | | | keep comment mode, instead of returning false. This matches SkipWhitespace. llvm-svn: 57402
* Add a new mode to the lexer which enables it to return all characters,Chris Lattner2008-10-121-15/+49
| | | | | | | | | | | | | | | | | | | | | | | | even whitespace, as tokens from the file. This is enabled with L->SetKeepWhitespaceMode(true) on a raw lexer. In this mode, you too can use clang as a really complex version of 'cat' with code like this: Lexer RawLex(SourceLocation::getFileLoc(SM.getMainFileID(), 0), PP.getLangOptions(), File.first, File.second); RawLex.SetKeepWhitespaceMode(true); Token RawTok; RawLex.LexFromRawLexer(RawTok); while (RawTok.isNot(tok::eof)) { std::cout << PP.getSpelling(RawTok); RawLex.LexFromRawLexer(RawTok); } This will emit exactly the input file, with no canonicalization or other translation. Realistic clients actually do something with the tokens of course :) llvm-svn: 57401
* Fix a couple more places that poke KeepCommentMode unnecesarily. Chris Lattner2008-10-121-3/+4
| | | | llvm-svn: 57398
* add a new inKeepCommentMode() accessor to abstract the KeepCommentModeChris Lattner2008-10-121-4/+4
| | | | | | ivar. llvm-svn: 57397
* fix misleading comment.Chris Lattner2008-10-121-1/+1
| | | | llvm-svn: 57396
* Simplify raw mode lexing by treating an unterminate /**/ comment theChris Lattner2008-10-121-3/+4
| | | | | | | | same we we do an unterminated string or character literal. This makes it so we can guarantee that the lexer never calls into the preprocessor (which would be suicide for a raw lexer). llvm-svn: 57395
* add a comment.Chris Lattner2008-10-121-0/+2
| | | | llvm-svn: 57394
* Change how raw lexers are handled: instead of creating them and thenChris Lattner2008-10-121-5/+6
| | | | | | | | | | | using LexRawToken, create one and use LexFromRawLexer. This avoids twiddling the RawLexer flag around and simplifies some code (even speeding raw lexing up a tiny bit). This change also improves the token paster to use a Lexer on the stack instead of new/deleting it. llvm-svn: 57393
* silence some release-assert warnings.Chris Lattner2008-10-121-2/+1
| | | | llvm-svn: 57391
* improve a comment.Chris Lattner2008-10-121-1/+2
| | | | llvm-svn: 57389
* Change Parser & Sema to use interned "super" for comparions.Daniel Dunbar2008-08-141-6/+0
| | | | | | | | | | | | | | - Added as private members for each because it is not clear where to put the common definition. Perhaps the IdentifierInfos all of these "pseudo-keywords" should be collected into one place (this would KnownFunctionIDs and Objective-C property IDs, for example). Remove Token::isNamedIdentifier. - There isn't a good reason to use strcmp when we have interned strings, and there isn't a good reason to encourage clients to do so. llvm-svn: 54794
* Fix typoNate Begeman2008-04-141-1/+1
| | | | llvm-svn: 49632
* don't diagnose empty source files, thanks Neil!Chris Lattner2008-04-121-2/+3
| | | | llvm-svn: 49575
* don't read off the front of the buffer. Thanks to Sam for pointing this out.Chris Lattner2008-04-111-1/+1
| | | | llvm-svn: 49535
OpenPOWER on IntegriCloud