summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
Commit message (Collapse)AuthorAgeFilesLines
* PTHLexer now owns the Token vector.Ted Kremenek2008-11-272-23/+18
| | | | llvm-svn: 60136
* Comment fix.Daniel Dunbar2008-11-251-1/+1
| | | | llvm-svn: 59997
* make the 'to match this' diagnostic a note.Chris Lattner2008-11-231-3/+3
| | | | llvm-svn: 59921
* Convert IdentifierInfo's to be printed the same as DeclarationNames Chris Lattner2008-11-231-1/+1
| | | | | | | | | | | | | | | | | | | | | with implicit quotes around them. This has a bunch of follow-on effects and requires tweaking to a whole lot of code. This causes a regression in two tests (xfailed) by causing it to emit things like: Line 10: duplicate interface declaration for category 'MyClass1' ('Category1') instead of: Line 10: duplicate interface declaration for category 'MyClass1(Category1)' I will fix this in a follow-up commit. As part of this, I had to start switching stuff to use ->getDeclName() instead of Decl::getName() for consistency. This is good, but I was planning to do this as an independent patch. There will be several follow-on patches to clean up some of the mess, but this patch is already too big. llvm-svn: 59917
* Fix a weird inconsistency with hex floats. Previously the lexer Chris Lattner2008-11-222-5/+3
| | | | | | | | | 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
* remove the NumericLiteralParser::Diag helper method, inlining it intoChris Lattner2008-11-221-29/+32
| | | | | | | | its call sites. This makes it more explicit when the hasError flag is getting set and removes a confusing difference in behavior between PP.Diag and Diag in this code. llvm-svn: 59863
* Move the Preprocessor::Diag methods inline. This has the interestingChris Lattner2008-11-221-12/+0
| | | | | | | | | | | | | | | | (and carefully calculated) effect of allowing the compiler to reason about the aliasing properties of DiagnosticBuilder object better, allowing the whole thing to be promoted to registers instead of resulting in a ton of stack traffic. While I'm not very concerned about the performance of the Diag() method invocations, I *am* more concerned about their code size and impact on the non-diagnostic code. This patch shrinks the clang executable (in release-asserts mode with gcc-4.2) from 14523980 to 14519816 bytes. This isn't much, but it shrinks the lexer from 38192 to 37776, PPDirectives.o from 31116 to 28868 bytes, etc. llvm-svn: 59862
* inline a method into its only two call sites.Chris Lattner2008-11-221-2/+3
| | | | llvm-svn: 59860
* 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-222-10/+7
| | | | llvm-svn: 59858
* Change the Lexer::Diag method to not magically silence warnings,Chris Lattner2008-11-222-29/+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-222-4/+4
| | | | | | | | | | 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
* In PTHLexer::DiscardToEndOfLine() use Lex() instead of AdvanceToken(). This ↵Ted Kremenek2008-11-211-1/+2
| | | | | | handles transitions in the preprocessor state. llvm-svn: 59845
* Reenable the default lexer.Ted Kremenek2008-11-211-1/+1
| | | | llvm-svn: 59843
* When creating the raw tokens for PTHLexer, make sure the token representing ↵Ted Kremenek2008-11-211-1/+4
| | | | | | the file to include is checked for being an identifier. llvm-svn: 59842
* When creating raw tokens for the PTHLexer specially handle angled strings ↵Ted Kremenek2008-11-211-6/+30
| | | | | | for #include directives. llvm-svn: 59840
* PTHLexer:Ted Kremenek2008-11-211-14/+26
| | | | | | - Move out logic for handling the end-of-file to LexEndOfFile (to match the Lexer) class. The logic now mirrors the Lexer class more, which allows us to pass most of the Preprocessor test cases. llvm-svn: 59768
* PTHLexer:Ted Kremenek2008-11-201-0/+12
| | | | | | | - Move PTHLexer::GetToken() to be inside PTHLexer.cpp. - When lexing in raw mode, null out identifiers. llvm-svn: 59744
* Handle another case where we should use PTHLexer as an alternative to the ↵Ted Kremenek2008-11-201-1/+3
| | | | | | normal Lexer. llvm-svn: 59736
* PTHLexer:Ted Kremenek2008-11-201-19/+11
| | | | | | | | | | - Rename 'CurToken' and 'LastToken' to 'CurTokenIdx' and 'LastTokenIdx' respectively. - Add helper methods GetToken(), AdvanceToken(), AtLastToken() to abstract away details of the token stream. This also allows us to easily replace their implementation later. llvm-svn: 59733
* Rename IsNonPragmaNonMacroLexer to IsFileLexer.Ted Kremenek2008-11-202-7/+7
| | | | llvm-svn: 59731
* Rewrote PTHLexer::Lex by digging through the sources of Lexer again. Now we ↵Ted Kremenek2008-11-201-28/+37
| | | | | | can do basic macro expansion using the PTHLexer. llvm-svn: 59724
* Add ugly "test harness" for PTHLexer that is not enabled by default. TheTed Kremenek2008-11-201-6/+49
| | | | | | | | | | (temporary hack) to test the PTHLexer is that whenever we would create a Lexer object we instead raw lex a memory buffer first and then use the PTHLexer. This logic exists only to driver the PTHLexer and will be removed/changed in the future. Note that the regular path using normal Lexer objects is what is used by default. llvm-svn: 59723
* Make FIXME a hard assertion.Ted Kremenek2008-11-201-2/+6
| | | | llvm-svn: 59695
* Preprocessor::getCurrentFileLexer() now returns a PreprocessorLexer* instead ofTed Kremenek2008-11-201-5/+6
| | | | | | | a Lexer*. This means it will either return the current (normal) file Lexer or a PTHLexer. llvm-svn: 59694
* Just use the SourceLocation of SysHeaderTok when doing a callback to emit #lineTed Kremenek2008-11-201-2/+2
| | | | | | | information. A diff of the -E output for Cocoa.h shows that there is no change in output. llvm-svn: 59693
* Assign the result of getCurrentFileLexer() to a PreprocessorLexer* instead ↵Ted Kremenek2008-11-201-1/+1
| | | | | | of Lexer* (narrower interface). llvm-svn: 59691
* - Default initialize ParsingPreprocessorDirective, ParsingFilename, andTed Kremenek2008-11-202-16/+16
| | | | | | | | LexingRawMode in the ctor of PreprocessorLexer. - PTHLexer: Use "LastToken" instead of "NumToken" llvm-svn: 59690
* Add (untested) implementation of PTHLexer::isNextPPTokenLParen() and ↵Ted Kremenek2008-11-201-4/+14
| | | | | | PTHLexer::DiscardToEndOfLine(). llvm-svn: 59687
* Use PreprocessorLexer::getFileID() instead of Lexer::getFileLoc(). This is ↵Ted Kremenek2008-11-193-7/+7
| | | | | | an intermediate step to having getCurrentLexer() return a PreprocessorLexer* instead of a Lexer*. llvm-svn: 59672
* Move more cases of using 'CurLexer' to 'CurPPLexer'.Ted Kremenek2008-11-193-27/+38
| | | | | | Use PTHLexer::isNextPPTokenLParen() when using the PTHLexer. llvm-svn: 59671
* Add stub for PTHLexer::isNextPPTokenLParen().Ted Kremenek2008-11-191-1/+6
| | | | llvm-svn: 59670
* When using a PTHLexer, use DiscardToEndOfLine() instead of ReadToEndOfLine().Ted Kremenek2008-11-194-7/+20
| | | | llvm-svn: 59668
* - Move static function IsNonPragmaNonMacroLexer into Preprocessor.h.Ted Kremenek2008-11-195-24/+21
| | | | | | | | | | | | | - 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
* CMake: Added some source files.Oscar Fuentes2008-11-191-0/+2
| | | | | | Patch contributed by Jay Foad! llvm-svn: 59656
* Remove Preprocessor::CacheTokens boolean data member. The same functionality ↵Argyrios Kyrtzidis2008-11-192-5/+1
| | | | | | can be provided by using Preprocessor::isBacktrackEnabled(). llvm-svn: 59631
* don't turn identifierinfo's into strings in diagnostics.Chris Lattner2008-11-192-3/+3
| | | | llvm-svn: 59602
* Revert 59574 (caused tests to fail).Ted Kremenek2008-11-192-7/+16
| | | | llvm-svn: 59579
* - Move static function IsNonPragmaNonMacroLexer into Preprocessor.h.Ted Kremenek2008-11-192-16/+7
| | | | | | | | | | | - Add variants of IsNonPragmaNonMacroLexer to accept an IncludeMacroStack entry (simplifies some uses). - Use IsNonPragmaNonMacroLexer in Preprocessor::LookupFile. Performance testing of -Eonly on Cocoa.h shows no performance regression because of this patch. llvm-svn: 59574
* Initialize CurPPLexer in Preprocessor's constructor.Ted Kremenek2008-11-191-1/+1
| | | | llvm-svn: 59573
* Remove the last of the old-style Preprocessor::Diag methods.Chris Lattner2008-11-186-65/+42
| | | | llvm-svn: 59554
* remove one more Preprocessor::Diag method.Chris Lattner2008-11-183-12/+16
| | | | llvm-svn: 59512
* Convert the lexer and start converting the PP over to using canonical Diag ↵Chris Lattner2008-11-184-33/+56
| | | | | | methods. llvm-svn: 59511
* This reworks some of the Diagnostic interfaces a bit to change how diagnosticsChris Lattner2008-11-181-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | are formed. In particular, a diagnostic with all its strings and ranges is now packaged up and sent to DiagnosticClients as a DiagnosticInfo instead of as a ton of random stuff. This has the benefit of simplifying the interface, making it more extensible, and allowing us to do more checking for things like access past the end of the various arrays passed in. In addition to introducing DiagnosticInfo, this also substantially changes how Diagnostic::Report works. Instead of being passed in all of the info required to issue a diagnostic, Report now takes only the required info (a location and ID) and returns a fresh DiagnosticInfo *by value*. The caller is then free to stuff strings and ranges into the DiagnosticInfo with the << operator. When the dtor runs on the DiagnosticInfo object (which should happen at the end of the statement), the diagnostic is actually emitted with all of the accumulated information. This is a somewhat tricky dance, but it means that the accumulated DiagnosticInfo is allowed to keep pointers to other expression temporaries without those pointers getting invalidated. This is just the minimal change to get this stuff working, but this will allow us to eliminate the zillions of variant "Diag" methods scattered throughout (e.g.) sema. For example, instead of calling: Diag(BuiltinLoc, diag::err_overload_no_match, typeNames, SourceRange(BuiltinLoc, RParenLoc)); We will soon be able to just do: Diag(BuiltinLoc, diag::err_overload_no_match) << typeNames << SourceRange(BuiltinLoc, RParenLoc)); This scales better to support arbitrary types being passed in (not just strings) in a type-safe way. Go operator overloading?! llvm-svn: 59502
* Change the diagnostics interface to take an array of pointers to Chris Lattner2008-11-181-2/+4
| | | | | | | | strings instead of array of strings. This reduces string copying in some not-very-important cases, but paves the way for future improvements. llvm-svn: 59494
* - Add Lexer::isPragma() accessor for clients of Lexer that aren't friends.Ted Kremenek2008-11-181-8/+14
| | | | | | | | | - Add static method to test if the current lexer is a non-macro/non-pragma lexer. - Refactor some code in PPLexerChange to use this static method. - No performance change. llvm-svn: 59486
* Replace more uses of 'CurLexer->' with 'CurPPLexer->'. No performance change.Ted Kremenek2008-11-182-5/+5
| | | | llvm-svn: 59482
* Add hooks to use PTHLexer::Lex instead of Lexer::Lex when CurLexer is null.Ted Kremenek2008-11-181-3/+5
| | | | | | | Performance tests on Cocoa.h (using the regular Lexer) shows no performance difference. llvm-svn: 59479
* Added conditional guard 'if (CurLexer)' when using SetCommentRetentionState().Ted Kremenek2008-11-181-6/+6
| | | | | | | | | | | | This is because the PTHLexer will not support this method. Performance testing on preprocessing Cocoa.h shows that this results in a negligible performance difference (less than 1%). I tried making Lexer::SetCommentRetentionState() an out-of-line function (a precursor to making it a virtual function in PreprocessorLexer) and noticed a 1% decrease in speed (it is called in a hot part of the Preprocessor). llvm-svn: 59477
* Change a bunch of uses of 'CurLexer->' to 'CurPPLexer->', which should be theTed Kremenek2008-11-181-40/+40
| | | | | | | | alias for the current PreprocessorLexer. No functionality change. Performance testing shows this results in no performance degradation when preprocessing Cocoa.h. llvm-svn: 59474
OpenPOWER on IntegriCloud