NAKAMURA Takumi
f2bc8f35a2
NumericLiteralParser::ParseNumberStartingWithZero(): Try to appease MSC16's miscompilation.
...
Investigating yet. It seems msc16 miscompiles s[1] to be folded.
llvm-svn: 191485
2013-09-27 04:42:28 +00:00
Richard Smith
99dc071104
Fix buildbot breakage.
...
llvm-svn: 191424
2013-09-26 05:57:03 +00:00
Richard Smith
1e130489b3
Replace a bool with an enum for clarity, based on review comment from James Dennett.
...
llvm-svn: 191420
2013-09-26 04:19:11 +00:00
Richard Smith
fde9485297
Implement C++1y digit separator proposal (' as a digit separator). This is not
...
yet approved by full committee, but was unanimously supported by EWG.
llvm-svn: 191417
2013-09-26 03:33:06 +00:00
Richard Smith
2a98862be2
Handle standard libraries that miss out the space when defining the standard
...
literal operators. Also, for now, allow the proposed C++1y "il", "i", and "if"
suffixes too. (Will revert the latter if LWG decides not to go ahead with that
change after all.)
llvm-svn: 191274
2013-09-24 04:06:10 +00:00
Eli Friedman
f9edb00fa4
Fix CharByteWidth assertion in LiteralSupport.
...
Patch by Eelis van der Weegen.
llvm-svn: 190971
2013-09-18 23:23:13 +00:00
Nick Lewycky
8054f1de88
Revert r188863 which could propose wrong fixits for multibyte character literals.
...
llvm-svn: 188918
2013-08-21 18:57:51 +00:00
Nick Lewycky
3151d7c76a
Issue fixits replacing invalid character literals with the equivalent \xNN
...
escape code.
llvm-svn: 188863
2013-08-21 04:10:58 +00:00
Nick Lewycky
63cc55b479
No functionality change. Adjust a bunch of formatting issues in this code and
...
fix a typo in a comment.
llvm-svn: 188857
2013-08-21 02:40:19 +00:00
Richard Smith
f4198b7598
C++1y literal suffix support:
...
* Allow ns, us, ms, s, min, h as numeric ud-suffixes
* Allow s as string ud-suffix
llvm-svn: 186933
2013-07-23 08:14:48 +00:00
Eli Friedman
088d39afc6
Integers which are too large should be an error.
...
Switch some warnings over to errors which should never have been warnings
in the first place. (Also, a minor fix to the preprocessor rules for
integer literals while I'm here.)
llvm-svn: 186903
2013-07-23 00:25:18 +00:00
Richard Smith
c5c27f2a1f
Note that we support (and in fact have supported since the dawn of time itself)
...
C++1y binary literals.
llvm-svn: 179883
2013-04-19 20:47:20 +00:00
Jordan Rose
a7d03840e6
Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.
...
Nearly all of these changes are one-to-one replacements; the few that
aren't have to do with custom identifier validation.
llvm-svn: 174768
2013-02-08 22:30:41 +00:00
Dmitri Gribenko
9feeef40f5
Move UTF conversion routines from clang/lib/Basic to llvm/lib/Support
...
This is required to use them in TableGen.
llvm-svn: 173924
2013-01-30 12:06:08 +00:00
Jordan Rose
c0cba27230
PR15067: Don't assert when a UCN appears in a C90 file.
...
Unfortunately, we can't accept the UCN as an extension because we're
required to treat it as two tokens for preprocessing purposes.
llvm-svn: 173622
2013-01-27 20:12:04 +00:00
Jordan Rose
aa89cf1a66
Unify diagnostics for \x, \u, and \U without any following hex digits.
...
llvm-svn: 173368
2013-01-24 20:50:13 +00:00
Jordan Rose
78ed86a7e5
Adopt llvm::hexDigitValue.
...
llvm-svn: 172861
2013-01-18 22:33:58 +00:00
Richard Smith
2bf7fdb723
s/CPlusPlus0x/CPlusPlus11/g
...
llvm-svn: 171367
2013-01-02 11:42:31 +00:00
Chandler Carruth
3a02247dc9
Sort all of Clang's files under 'lib', and fix up the broken headers
...
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
2012-12-04 09:13:33 +00:00
Benjamin Kramer
7d574e269d
LiteralSupport: Don't overflow the temporary buffer when decoding invalid string parts.
...
Instead just use a dummy buffer, we're not going to use the decoded string anyways.
Fixes PR14292.
llvm-svn: 167594
2012-11-08 19:22:31 +00:00
Benjamin Kramer
f23a6e6f80
LiteralSupport: Clean up style violations. No functionality change.
...
llvm-svn: 167593
2012-11-08 19:22:26 +00:00
David Blaikie
a0613170b4
Handle string encoding diagnostics when there are too many invalid ranges.
...
llvm-svn: 167059
2012-10-30 23:22:22 +00:00
Seth Cantrell
4cfc817a9a
improve highlighting of invalid string encodings
...
limit highlight to exactly the bad encoding, and highlight every
bad encoding in a string.
llvm-svn: 166900
2012-10-28 18:24:46 +00:00
Jordan Rose
de584de370
Rename CanFitInto64Bits to alwaysFitsInto64Bits per discussion on IRC.
...
This makes the behavior clearer concerning literals with the maximum
number of digits. For a 32-bit example, 4,000,000,000 is a valid uint32_t,
but 5,000,000,000 is not, so we'd have to count 10-digit decimal numbers
as "unsafe" (meaning we have to check for overflow when parsing them,
just as we would for numbers with 11 digits or higher). This is the same,
only with 64 bits to play with.
No functionality change.
llvm-svn: 164639
2012-09-25 22:32:51 +00:00
Dmitri Gribenko
511288b2b5
Optimize NumericLiteralParser::GetIntegerValue().
...
It does a conservative estimate on the size of numbers that can fit into
uint64_t. This bound is improved.
llvm-svn: 164624
2012-09-25 19:09:15 +00:00
Dmitri Gribenko
7ba91723e7
Small cleanup of literal semantic analysis: hiding 'char *' pointers behind
...
StringRef makes code cleaner. Also, make the temporary buffer smaller:
512 characters is unreasonably large for integer literals.
llvm-svn: 164484
2012-09-24 09:53:54 +00:00
Richard Smith
639b8d05dd
When a bad UTF-8 encoding or bogus escape sequence is encountered in a
...
string literal, produce a diagnostic pointing at the erroneous character
range, not at the start of the literal.
llvm-svn: 163459
2012-09-08 07:16:20 +00:00
Nico Weber
4b18c3ff40
Share ConvertUTF8toWide() between Lex and CodeGen.
...
llvm-svn: 159634
2012-07-03 02:24:52 +00:00
James Dennett
99c193b3c0
Documentation cleanup: add \verbatim markup for grammar productions
...
llvm-svn: 158740
2012-06-19 21:04:25 +00:00
James Dennett
1cc2203286
Documentation cleanup: added \verbatim...\verbatim markup to fix the
...
formatting of Doxygen's output for StringLiteralParser::StringLiteralParser.
llvm-svn: 158616
2012-06-17 03:34:42 +00:00
Richard Smith
0948d93b7f
Fix off-by-one error in UTF-16 encoding: don't try to use a surrogate pair for U+FFFF.
...
llvm-svn: 158391
2012-06-13 05:41:29 +00:00
Richard Smith
4060f77462
PR13099: Teach -Wformat about raw string literals, UTF-8 strings and Unicode escape sequences.
...
llvm-svn: 158390
2012-06-13 05:37:23 +00:00
Argyrios Kyrtzidis
9933e3ac88
In StringLiteralParser::init, make sure we emit an error when
...
failing to lex the string, as suggested by Eli.
Part of rdar://11305263.
llvm-svn: 156081
2012-05-03 17:50:32 +00:00
Argyrios Kyrtzidis
4e5b5c36f4
In StringLiteralParser::init(), fail gracefully if the string is
...
not as we expect; it may be due to racing issue of a file coming from PCH
changing after the PCH is loaded.
rdar://11353109
llvm-svn: 156043
2012-05-03 01:01:56 +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
2a70e65436
Improve diagnostics for UCNs referring to control characters and members of the
...
basic source character set in C++98. Add -Wc++98-compat diagnostics for same in
literals in C++11. Extend such support to cover string literals as well as
character literals, and mark N2170 as done.
This seems too minor to warrant a release note to me. Let me know if you disagree.
llvm-svn: 152444
2012-03-09 22:27:51 +00:00
Richard Smith
812924502b
When checking the encoding of an 8-bit string literal, don't just check the
...
first codepoint! Also, don't reject empty raw string literals for spurious
"encoding" issues. Also, don't rely on undefined behavior in ConvertUTF.c.
llvm-svn: 152344
2012-03-08 21:59:28 +00:00
Richard Smith
39570d0020
Add support for cooked forms of user-defined-integer-literal and
...
user-defined-floating-literal. Support for raw forms of these literals
to follow.
llvm-svn: 152302
2012-03-08 08:45:32 +00:00
Richard Smith
75b67d6dc5
User-defined literal support for character literals.
...
llvm-svn: 152277
2012-03-08 01:34:56 +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
Eli Friedman
9436352a82
Implement warning for non-wide string literals with an unexpected encoding. Downgrade error for non-wide character literals with an unexpected encoding to a warning for compatibility with gcc and older versions of clang. <rdar://problem/10837678>.
...
llvm-svn: 150295
2012-02-11 05:08:10 +00:00
Aaron Ballman
e1224a5067
Fixing hex floating literal support so that it handles 0x.2p2 properly.
...
llvm-svn: 150072
2012-02-08 13:36:33 +00:00
Aaron Ballman
b97a5addd5
Hex literals without a significand no longer crash the lexer. Fixes bug 7910
...
Patch by Eitan Adler
llvm-svn: 149984
2012-02-07 13:46:03 +00:00
Dylan Noblesmith
2c1dd2716a
Basic: import SmallString<> into clang namespace
...
(I was going to fix the TODO about DenseMap too, but
that would break self-host right now. See PR11922.)
llvm-svn: 149799
2012-02-05 02:13:05 +00:00
Seth Cantrell
9c2d6f0279
stop claiming unicode escape sequences are too long in strings, because they never are
...
llvm-svn: 148391
2012-01-18 12:27:08 +00:00
Seth Cantrell
8b2b677f39
Improves support for Unicode in character literals
...
Updates ProcessUCNExcape() for C++. C++11 allows UCNs in character
and string literals that represent control characters and basic
source characters. Also C++03 allows UCNs that refer to surrogate
codepoints.
UTF-8 sequences in character literals are now handled as single
c-chars.
Added error for multiple characters in Unicode character literals.
Added errors for when a the execution charset encoding of a c-char
cannot be represented as a single code unit in the associated
character type. Note that for the purposes of this error the asso-
ciated character type for a narrow character literal is char, not
int, even though in C narrow character literals have type int.
llvm-svn: 148389
2012-01-18 12:27:04 +00:00
Nico Weber
d60b72f696
Fix a regression in wide character codegen. See PR11369.
...
llvm-svn: 144521
2011-11-14 05:17:37 +00:00
Eli Friedman
20554708fb
Fix one last place where we weren't writing into a string literal consistently.
...
llvm-svn: 143769
2011-11-05 00:41:04 +00:00
Eli Friedman
d1370791c2
Use native endianness for writing out character escapes to the result buffer for string literal parsing. No functional change on little-endian architectures; should fix test failures on PPC.
...
llvm-svn: 143585
2011-11-02 23:06:23 +00:00
Eli Friedman
703e7153af
Perform proper conversion for strings encoded in the source file as UTF-8. (For now, we are assuming the source character set is always UTF-8; this can be easily extended if necessary.)
...
Tests will be coming up in a subsequent commit.
Patch by Seth Cantrell.
llvm-svn: 143416
2011-11-01 02:14:50 +00:00