summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Lexer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Documentation cleanup:James Dennett2012-06-171-11/+7
| | | | | | | | | | * Removed docs for Lexer::makeFileCharRange from Lexer.cpp, as they're in the header file; * Reworked the documentation for SkipBlockComment so that it doesn't confuse Doxygen's comment parsing; * Added another summary with \brief markup. llvm-svn: 158618
* [-E] Emit a rewritten _Pragma on its own line.Jordan Rose2012-06-151-1/+1
| | | | | | | | | | | 1. Teach Lexer that pragma lexers are like macro expansions at EOF. 2. Treat pragmas like #define/#undef when printing. 3. If we just printed a directive, add a newline before any more tokens. (4. Miscellaneous cleanup in PrintPreprocessedOutput.cpp) PR10594 and <rdar://problem/11562490> (two separate related problems) llvm-svn: 158571
* Documentation cleanup: escape backslashes in Doxygen comments.James Dennett2012-06-151-4/+5
| | | | llvm-svn: 158552
* PR12717: Clang supports hexadecimal floating-point literals in all languageRichard Smith2012-06-151-2/+14
| | | | | | | | | | | | | modes. For languages other than C99/C11, this isn't quite a conforming extension, and for C++11, it breaks some reasonable code containing user-defined literals. In languages which don't officially have hexfloats, pare back this extension to only apply in cases where the token starts 0x and does not contain an underscore. The extension is still not quite conforming, but it's a lot closer now. llvm-svn: 158487
* Fix PR13065.David Blaikie2012-06-151-1/+1
| | | | | | This condition (added in r158093) was overly conservative. llvm-svn: 158483
* Correct method name in comment: from LexRawToken to LexFromRawLexer, accordingDmitri Gribenko2012-06-081-2/+2
| | | | | | to a change done long ago in r57393. llvm-svn: 158243
* Insert a space if necessary when suggesting CFBridgingRetain/Release.Jordan Rose2012-06-071-0/+5
| | | | | | | | | | | | This was a problem for people who write 'return(result);' Also fix ARCMT's corresponding code, though there's no test case for this because implicit casts like this are rejected by the migrator for being ambiguous, and explicit casts have no problem. <rdar://problem/11577346> llvm-svn: 158130
* Add a -rewrite-includes option, which is similar to -rewrite-macros, but ↵David Blaikie2012-06-061-2/+3
| | | | | | | | | only expands #include directives. Patch contributed by Lubos Lunak (l.lunax@suse.cz). Review by Matt Beaumont-Gay (matthewbg@google.com). llvm-svn: 158093
* Escape \n and \r in doxycomment.David Blaikie2012-06-061-2/+2
| | | | llvm-svn: 158091
* Lexer::ReadToEndOfLine: Only build the string if it's actually used and do ↵Benjamin Kramer2012-05-181-7/+8
| | | | | | so in a less malloc-intensive way. llvm-svn: 157064
* Support -Wc++98-compat-pedantic as requested:Seth Cantrell2012-04-131-4/+4
| | | | | | http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120409/056126.html llvm-svn: 154655
* C++11 no longer requires files to end with a newlineSeth Cantrell2012-04-131-1/+2
| | | | llvm-svn: 154643
* ext_reserved_user_defined_literal must not default to Error in ↵Francois Pichet2012-04-071-1/+3
| | | | | | | | MicrosoftMode. Hence create ext_ms_reserved_user_defined_literal that doesn't default to Error; otherwise MSVC headers won't parse. Fixes PR12383. llvm-svn: 154273
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-60/+60
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Implement C++11 [lex.ext]p10 for string and character literals: a ud-suffix notRichard Smith2012-03-081-1/+14
| | | | | | | | | | | | | | | | | | starting with an underscore is ill-formed. Since this rule rejects programs that were using <inttypes.h>'s macros, recover from this error by treating the ud-suffix as a separate preprocessing-token, with a DefaultError ExtWarn. The approach of treating such cases as two tokens is under discussion for standardization, but is in any case a conforming extension and allows existing codebases to keep building while the committee makes up its mind. Reword the warning on the definition of literal operators not starting with underscores (which are, strangely, legal) to more explicitly state that such operators can't be called by literals. Remove the special-case diagnostic for hexfloats, since it was both triggering in the wrong cases and incorrect. llvm-svn: 152287
* Add -Wc++11-compat warning for string and character literals followed byRichard Smith2012-03-071-5/+12
| | | | | | | identifiers, in cases where those identifiers would be treated as user-defined literal suffixes in C++11. llvm-svn: 152198
* User-defined literals: reject string and character UDLs in all places where theRichard Smith2012-03-061-0/+1
| | | | | | | | | | grammar requires a string-literal and not a user-defined-string-literal. The two constructs are still represented by the same TokenKind, in order to prevent a combinatorial explosion of different kinds of token. A flag on Token tracks whether a ud-suffix is present, in order to prevent clients from needing to look at the token's spelling. llvm-svn: 152098
* Lexing support for user-defined literals. Currently these lex as the same tokenRichard Smith2012-03-051-1/+36
| | | | | | | kinds as the underlying string literals, and we silently drop the ud-suffix; those issues will be fixed by subsequent patches. llvm-svn: 152012
* Change Lexer::makeFileCharRange() to have it accept a CharSourceRangeArgyrios Kyrtzidis2012-02-031-24/+35
| | | | | | | instead of a SourceRange, and handle the case where the range is a char (not token) range. llvm-svn: 149677
* Improve Lexer::getImmediateMacroName to take into account inner macrosArgyrios Kyrtzidis2012-01-231-3/+29
| | | | | | | | | of macro arguments. For "MAC1( MAC2(foo) )" and location of 'foo' token it would return "MAC1" instead of "MAC2". llvm-svn: 148704
* Enhance Lexer::makeFileCharRange to check for ranges inside a macro argumentArgyrios Kyrtzidis2012-01-201-11/+61
| | | | | | | expansion, in which case it returns a file range in the location where the argument was spelled. llvm-svn: 148551
* Introduce Lexer::getSourceText() that returns a string for the sourceArgyrios Kyrtzidis2012-01-191-0/+42
| | | | | | that the given source range encompasses. llvm-svn: 148481
* Introduce Lexer::makeFileCharRange() that accepts a token source rangeArgyrios Kyrtzidis2012-01-191-0/+29
| | | | | | and returns a character range with file locations. llvm-svn: 148480
* For Lexer's isAt[Start/End]OfMacroExpansion add an out parameter for the macroArgyrios Kyrtzidis2012-01-191-15/+21
| | | | | | | | | start/end location. It is commonly needed after calling the function; with this way we avoid recalculating it. llvm-svn: 148479
* Refactor: Pull getImmediateMacroName() out of DiagnosticRenderer andAnna Zaks2012-01-181-0/+21
| | | | | | into Lexer and Preprocessor; making it widely available. llvm-svn: 148410
* Two variables had been added for an assert, but their values wereChandler Carruth2012-01-151-3/+3
| | | | | | | | | | re-computed rather than the variables be re-used just after the assert. Just use the variables since we have them already. Fixes an unused variable warning. Also fix an 80-column violation. llvm-svn: 148212
* In Lexer::getCharAndSizeSlow[NoWarn] if we come up againstArgyrios Kyrtzidis2011-12-221-12/+10
| | | | | | | | | | \<newline><newline> don't consume the second newline. Thanks to David Blaikie for pointing out the crash! llvm-svn: 147138
* In Lexer::getCharAndSizeSlow[NoWarn] make sure we don't go over the end of ↵Argyrios Kyrtzidis2011-12-211-0/+7
| | | | | | | | | | the buffer when the end of the buffer is immediately after an escaped newline. Fixes http://llvm.org/PR10153. llvm-svn: 147091
* Unweaken vtables as per ↵David Blaikie2011-12-201-0/+2
| | | | | | http://llvm.org/docs/CodingStandards.html#ll_virtual_anch llvm-svn: 146959
* Remove assert from hot code path and add a clarifying comment.Benjamin Kramer2011-11-221-4/+4
| | | | | | The assert wasn't adding much value but slowed down Release+Asserts builds. llvm-svn: 145082
* Lexer: Don't throw away the hard work SSE did to find a slash.Benjamin Kramer2011-11-221-5/+12
| | | | | | We can reuse the information and avoid looping over all the bytes again. llvm-svn: 145070
* Move about 20 random diagnostics under -W flags. Patch by Ahmed Charles!Ted Kremenek2011-10-171-2/+2
| | | | llvm-svn: 142284
* -Wc++98-compat warnings for the lexer.Richard Smith2011-10-151-0/+15
| | | | | | | | This also adds a -Wc++98-compat-pedantic for warning on constructs which would be diagnosed by -std=c++98 -pedantic (that is, it warns even on C++11 features which we enable by default, with no warning, in C++98 mode). llvm-svn: 142034
* We do parse hexfloats in C++11; make it actually work.Douglas Gregor2011-10-121-2/+1
| | | | llvm-svn: 141798
* Handle Perforce-style conflict markers like normal conflict markers. PerforceRichard Smith2011-10-121-24/+38
| | | | | | | swaps over the <<<< and >>>> markers, and uses shorter markers than traditional tools. llvm-svn: 141751
* Fixed exapnsion range for # and ##.Abramo Bagnara2011-10-031-1/+1
| | | | llvm-svn: 141012
* Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset.Argyrios Kyrtzidis2011-09-191-10/+10
| | | | | | 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-4/+4
| | | | | | | | 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
* Speed up BCPL comment lexing by looking aggressively for newlines and then ↵Benjamin Kramer2011-09-051-9/+24
| | | | | | | | scannig backwards to see if the newline is escaped. 3% speedup in preprocessing all of clang with -Eonly. Also includes a small testcase for coverage. llvm-svn: 139116
* Use the Lexer's definition of whitespace here.Benjamin Kramer2011-09-051-3/+2
| | | | llvm-svn: 139115
* Support code-completion for C++ inline methods and ObjC buffering methods.Argyrios Kyrtzidis2011-09-041-36/+62
| | | | | | | | | | | | | | 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
* Fix Lexer::ComputePreamble when MaxLines parameter is non-zero.Argyrios Kyrtzidis2011-09-041-3/+18
| | | | | | | | The function was only counting lines that included tokens and not empty lines, but MaxLines (mainly initiated to the line where the code-completion point resides) is a count of overall lines (even empty ones). llvm-svn: 139085
* Introduce support for a simple module import declaration, whichDouglas Gregor2011-08-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | loads the named module. The syntax itself is intentionally hideous and will be replaced at some later point with something more palatable. For now, we're focusing on the semantics: - Module imports are handled first by the preprocessor (to get macro definitions) and then the same tokens are also handled by the parser (to get declarations). If both happen (as in normal compilation), the second one is redundant, because we currently have no way to hide macros or declarations when loading a module. Chris gets credit for this mad-but-workable scheme. - The Preprocessor now holds on to a reference to a module loader, which is responsible for loading named modules. CompilerInstance is the only important module loader: it now knows how to create and wire up an AST reader on demand to actually perform the module load. - We search for modules in the include path, using the module name with the suffix ".pcm" (precompiled module) for the file name. This is a temporary hack; we hope to improve the situation in the future. llvm-svn: 138679
* Make Lexer::ComputePreamble accept a LangOptions parameter, otherwise it may beArgyrios Kyrtzidis2011-08-251-3/+3
| | | | | | out-of-sync how a file is compiled. Patch by Matthias Kleine! llvm-svn: 138580
* In Lexer::isAtEndOfMacroExpansion use SourceManager::isInFileID and avoidArgyrios Kyrtzidis2011-08-231-5/+3
| | | | | | the extra SourceManager::getFileID call. llvm-svn: 138376
* Make Lexer::GetBeginningOfToken able to handle macro arg expansion locations.Argyrios Kyrtzidis2011-08-171-3/+23
| | | | llvm-svn: 137795
* Add support for C++0x raw string literals.Craig Topper2011-08-111-19/+156
| | | | llvm-svn: 137298
* Add a utility function to the Lexer, which makes it easier to find a token ↵Anna Zaks2011-07-271-0/+59
| | | | | | after the given location. (It is a generalized version of trans::findLocationAfterSemi from ArcMigrate, which will be changed to use the Lexer utility). llvm-svn: 136268
* Add support for C++0x unicode string and character literals, from Craig Topper!Douglas Gregor2011-07-271-13/+64
| | | | llvm-svn: 136210
* Migrate 'Instantiation' data and API bits of SLocEntry to 'Expansion'Chandler Carruth2011-07-261-3/+2
| | | | | | | | 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
OpenPOWER on IntegriCloud