Nico Weber
7cc28804e2
UCNs in char literals are done (in LiteralSupport), remove FIXME. Expand UCN FIXME in LexNumericConstant.
...
llvm-svn: 167818
2012-11-13 06:25:15 +00:00
Argyrios Kyrtzidis
4f10a3e9f0
[preprocessor] When #including something that contributes no tokens at all,
...
don't recursively continue lexing.
This avoids a stack overflow with a sequence of many empty #includes.
rdar://11988695
llvm-svn: 167801
2012-11-13 01:03:15 +00:00
Argyrios Kyrtzidis
36675b75fb
In Lexer::LexTokenInternal, avoid code duplication; no functionality change.
...
llvm-svn: 167800
2012-11-13 01:02:40 +00:00
Nico Weber
158a31abe2
s/BCPLComment/LineComment/
...
llvm-svn: 167690
2012-11-11 07:02:14 +00:00
Argyrios Kyrtzidis
d53d0daab9
Take into account that there may be a BOM at the beginning of the file,
...
when computing the size of the precompiled preamble.
llvm-svn: 166659
2012-10-25 01:51:45 +00:00
Dmitri Gribenko
b8e9e7507e
StringRef'ize Preprocessor::CreateString().
...
llvm-svn: 164555
2012-09-24 21:07:17 +00:00
Roman Divacky
e637711ae0
Dont cast away const needlessly. Found by gcc48 -Wcast-qual.
...
llvm-svn: 163325
2012-09-06 15:59:27 +00:00
Eli Friedman
324adad966
Make a bunch of methods on Lexer private.
...
llvm-svn: 162970
2012-08-31 02:29:37 +00:00
Dmitri Gribenko
4aa05c571e
Lexer: remove dead stores. Found by Clang static analyzer!
...
llvm-svn: 160973
2012-07-30 17:59:40 +00:00
Richard Smith
608c0b65d7
Add warning flag -Winvalid-pp-token for preprocessing-tokens which have
...
undefined behaviour, and move the diagnostic for '' from an Error into
an ExtWarn in this group. This is important for some users of the preprocessor,
and is necessary for gcc compatibility.
llvm-svn: 159335
2012-06-28 07:51:56 +00:00
James Dennett
f442d2455b
Documentation cleanup:
...
* 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
2012-06-17 03:40:43 +00:00
Jordan Rose
127f6eef7e
[-E] Emit a rewritten _Pragma on its own line.
...
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
2012-06-15 23:33:51 +00:00
James Dennett
ff3c995624
Documentation cleanup: escape backslashes in Doxygen comments.
...
llvm-svn: 158552
2012-06-15 21:36:54 +00:00
Richard Smith
e6799ddae8
PR12717: Clang supports hexadecimal floating-point literals in all language
...
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
2012-06-15 05:07:49 +00:00
David Blaikie
2af2b3071d
Fix PR13065.
...
This condition (added in r158093) was overly conservative.
llvm-svn: 158483
2012-06-15 00:47:13 +00:00
Dmitri Gribenko
702b732d6f
Correct method name in comment: from LexRawToken to LexFromRawLexer, according
...
to a change done long ago in r57393.
llvm-svn: 158243
2012-06-08 23:19:37 +00:00
Jordan Rose
288c421b3d
Insert a space if necessary when suggesting CFBridgingRetain/Release.
...
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
2012-06-07 01:10:31 +00:00
David Blaikie
d5321247c4
Add a -rewrite-includes option, which is similar to -rewrite-macros, but only expands #include directives.
...
Patch contributed by Lubos Lunak (l.lunax@suse.cz ).
Review by Matt Beaumont-Gay (matthewbg@google.com ).
llvm-svn: 158093
2012-06-06 18:52:13 +00:00
David Blaikie
987bcf9462
Escape \n and \r in doxycomment.
...
llvm-svn: 158091
2012-06-06 18:43:20 +00:00
Benjamin Kramer
e5fbc6c85d
Lexer::ReadToEndOfLine: Only build the string if it's actually used and do so in a less malloc-intensive way.
...
llvm-svn: 157064
2012-05-18 19:32:16 +00:00
Seth Cantrell
e83c731cad
Support -Wc++98-compat-pedantic as requested:
...
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120409/056126.html
llvm-svn: 154655
2012-04-13 03:43:23 +00:00
Seth Cantrell
10ac7205ce
C++11 no longer requires files to end with a newline
...
llvm-svn: 154643
2012-04-13 01:00:34 +00:00
Francois Pichet
7ebc4c1910
ext_reserved_user_defined_literal must not default to Error in 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
2012-04-07 23:09:23 +00:00
David Blaikie
bbafb8a745
Unify naming of LangOptions variable/get function across the Clang stack (Lex to AST).
...
The member variable is always "LangOpts" and the member function is always "getLangOpts".
Reviewed by Chris Lattner
llvm-svn: 152536
2012-03-11 07:00:24 +00:00
Richard Smith
0df56f4a90
Implement C++11 [lex.ext]p10 for string and character literals: a ud-suffix not
...
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
2012-03-08 02:39:21 +00:00
Richard Smith
3e4a60a2cd
Add -Wc++11-compat warning for string and character literals followed by
...
identifiers, in cases where those identifiers would be treated as
user-defined literal suffixes in C++11.
llvm-svn: 152198
2012-03-07 03:13:00 +00:00
Richard Smith
d67aea28f6
User-defined literals: reject string and character UDLs in all places where the
...
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
2012-03-06 03:21:47 +00:00
Richard Smith
e18f0faff2
Lexing support for user-defined literals. Currently these lex as the same token
...
kinds as the underlying string literals, and we silently drop the ud-suffix;
those issues will be fixed by subsequent patches.
llvm-svn: 152012
2012-03-05 04:02:15 +00:00
Argyrios Kyrtzidis
0d9e24b1db
Change Lexer::makeFileCharRange() to have it accept a CharSourceRange
...
instead of a SourceRange, and handle the case where the range is
a char (not token) range.
llvm-svn: 149677
2012-02-03 05:58:29 +00:00
Argyrios Kyrtzidis
abff5f1271
Improve Lexer::getImmediateMacroName to take into account inner macros
...
of macro arguments.
For "MAC1( MAC2(foo) )" and location of 'foo' token it would return
"MAC1" instead of "MAC2".
llvm-svn: 148704
2012-01-23 16:58:33 +00:00
Argyrios Kyrtzidis
85e7671b71
Enhance Lexer::makeFileCharRange to check for ranges inside a macro argument
...
expansion, in which case it returns a file range in the location where the
argument was spelled.
llvm-svn: 148551
2012-01-20 16:52:43 +00:00
Argyrios Kyrtzidis
7838a2bffb
Introduce Lexer::getSourceText() that returns a string for the source
...
that the given source range encompasses.
llvm-svn: 148481
2012-01-19 15:59:19 +00:00
Argyrios Kyrtzidis
a99e02d019
Introduce Lexer::makeFileCharRange() that accepts a token source range
...
and returns a character range with file locations.
llvm-svn: 148480
2012-01-19 15:59:14 +00:00
Argyrios Kyrtzidis
1b07c344b4
For Lexer's isAt[Start/End]OfMacroExpansion add an out parameter for the macro
...
start/end location.
It is commonly needed after calling the function; with this way we avoid
recalculating it.
llvm-svn: 148479
2012-01-19 15:59:08 +00:00
Anna Zaks
1bea4bf590
Refactor: Pull getImmediateMacroName() out of DiagnosticRenderer and
...
into Lexer and Preprocessor; making it widely available.
llvm-svn: 148410
2012-01-18 20:17:16 +00:00
Chandler Carruth
5b15a9be6a
Two variables had been added for an assert, but their values were
...
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
2012-01-15 09:03:45 +00:00
Argyrios Kyrtzidis
8a26c4de64
In Lexer::getCharAndSizeSlow[NoWarn] if we come up against
...
\<newline><newline>
don't consume the second newline.
Thanks to David Blaikie for pointing out the crash!
llvm-svn: 147138
2011-12-22 04:38:07 +00:00
Argyrios Kyrtzidis
e5cdd080ba
In Lexer::getCharAndSizeSlow[NoWarn] make sure we don't go over the end of the buffer
...
when the end of the buffer is immediately after an escaped newline.
Fixes http://llvm.org/PR10153 .
llvm-svn: 147091
2011-12-21 20:19:55 +00:00
David Blaikie
68e081d606
Unweaken vtables as per http://llvm.org/docs/CodingStandards.html#ll_virtual_anch
...
llvm-svn: 146959
2011-12-20 02:48:34 +00:00
Benjamin Kramer
900f1defdd
Remove assert from hot code path and add a clarifying comment.
...
The assert wasn't adding much value but slowed down Release+Asserts builds.
llvm-svn: 145082
2011-11-22 20:39:31 +00:00
Benjamin Kramer
3885737a1b
Lexer: Don't throw away the hard work SSE did to find a slash.
...
We can reuse the information and avoid looping over all the bytes again.
llvm-svn: 145070
2011-11-22 18:56:46 +00:00
Ted Kremenek
a08713ce86
Move about 20 random diagnostics under -W flags. Patch by Ahmed Charles!
...
llvm-svn: 142284
2011-10-17 21:47:53 +00:00
Richard Smith
acd4d3d52a
-Wc++98-compat warnings for the lexer.
...
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
2011-10-15 01:18:56 +00:00
Douglas Gregor
227c352bae
We do parse hexfloats in C++11; make it actually work.
...
llvm-svn: 141798
2011-10-12 18:51:02 +00:00
Richard Smith
a9e33d44a6
Handle Perforce-style conflict markers like normal conflict markers. Perforce
...
swaps over the <<<< and >>>> markers, and uses shorter markers than traditional
tools.
llvm-svn: 141751
2011-10-12 00:37:51 +00:00
Abramo Bagnara
e398e60611
Fixed exapnsion range for # and ##.
...
llvm-svn: 141012
2011-10-03 18:39:03 +00:00
Argyrios Kyrtzidis
e6e67deeed
Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset.
...
It already works (and is useful with) macro locs as well.
llvm-svn: 140057
2011-09-19 20:40:19 +00:00
Francois Pichet
0706d203cf
Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear 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
2011-09-17 17:15:52 +00:00
Benjamin Kramer
17ff23c708
Speed up BCPL comment lexing by looking aggressively for newlines and then 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
2011-09-05 07:19:39 +00:00
Benjamin Kramer
dbfb18a0a9
Use the Lexer's definition of whitespace here.
...
llvm-svn: 139115
2011-09-05 07:19:35 +00:00