Commit Graph

152 Commits

Author SHA1 Message Date
David Majnemer 294e20faaf [MS Extensions] Remove support for the i128 integer literal suffix
There is currently no support in MSVC for using i128 as an integer
literal suffix.  In fact, there appears to be no evidence that they have
ever supported this feature in any of their compilers.  This was an over
generalization of their actual feature and is a nasty source of bugs.
Why is it a source of bugs?  Because most code in clang expects that
evaluation of an integer constant expression won't give them something
that 'long long' can't represent.  Instead of providing a meaningful
feature, i128 gives us cute ways of exploding the compiler.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243243 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-26 09:02:26 +00:00
Benjamin Kramer 8725a30000 [lex] Don't read past the end of the buffer
While dereferencing ThisTokEnd is fine and we know that it's not in
[a-zA-Z0-9_.], ThisTokEnd[1] is really past the end.

Found by asan and with a little help from clang-fuzz.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233491 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-29 14:11:37 +00:00
Benjamin Kramer 3dd6fa5d29 [lex] Turn range checks into asserts.
We know that the last accessible char is not in [a-zA-Z0-9_.] so we can
happily scan on as long as it is. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233490 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-29 14:11:22 +00:00
David Blaikie fde14cc829 Make Oveflow tracking more legible (CR feedback from Richard Smith on r232999)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233006 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-23 19:54:44 +00:00
David Blaikie c0f04d6052 Refactor: Simplify boolean expresssions in lib/Lex
Simplify boolean expressions using `true` and `false` with `clang-tidy`

Patch by Richard Thomson.

Differential Revision: http://reviews.llvm.org/D8531

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232999 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-23 19:39:19 +00:00
Richard Smith 9443d047e8 [c++1z] Support for u8 character literals.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221576 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-08 06:08:42 +00:00
Aaron Ballman fbc9c9f05e C++1y is now C++14!
Changes diagnostic options, language standard options, diagnostic identifiers, diagnostic wording to use c++14 instead of c++1y. It also modifies related test cases to use the updated diagnostic wording.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215982 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 15:55:55 +00:00
Craig Topper ba3d751136 Convert StringLiteralParser constructor to use ArrayRef instead of a pointer and count.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211763 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-26 04:58:39 +00:00
David Majnemer 52ce795128 Lex: Use the correct types for MS integer suffixes
Something went wrong with r211426, it is an older version of this code
and should not have been committed.  It was reverted with r211434.

Original commit message:
We didn't properly implement support for the sized integer suffixes.
Suffixes like i16 were essentially ignored instead of mapping them to
the appropriately sized integer type.

This fixes PR20008.

Differential Revision: http://reviews.llvm.org/D4132

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211441 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-21 18:46:07 +00:00
Rafael Espindola f533fd477a Revert "Lex: Use the correct types for MS integer suffixes"
This reverts commit r211426.

This broke the arm bots. The crash can be reproduced on X86 by running.
./bin/clang -cc1  -fsyntax-only -verify -fms-extensions ~/llvm/clang/test/Lexer/ms-extensions.c -triple arm-linux

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211434 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-21 12:39:25 +00:00
David Majnemer d31bc8bc75 Lex: Use the correct types for MS integer suffixes
We didn't properly implement support for the sized integer suffixes.
Suffixes like i16 were essentially ignored instead of mapping them to
the appropriately sized integer type.

This fixes PR20008.

Differential Revision: http://reviews.llvm.org/D4132

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211426 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-21 00:51:59 +00:00
Peter Collingbourne f3117b8d89 Permit the "if" literal suffix with Microsoft extensions enabled.
Differential Revision: http://reviews.llvm.org/D3963

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209859 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-29 23:10:15 +00:00
Alexander Kornienko c2f2b74ec2 Remove limits on the number of fix-it hints and ranges in the DiagnosticsEngine.
Summary:
The limits on the number of fix-it hints and ranges attached to a
diagnostic are arbitrary and don't apply universally to all users of the
DiagnosticsEngine. The way the limits are enforced may lead to diagnostics
generating invalid sets of fixes. I suggest removing the limits, which will also
simplify the implementation.

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D3879

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209468 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-22 19:56:11 +00:00
Craig Topper da176c6d6a [C++11] Use 'nullptr'. Lex edition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209083 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-17 23:10:59 +00:00
Richard Smith 431393eb91 Add some missing checks for C++1y digit separators that don't in fact separate
digits. Turns out we have completely separate lexing codepaths for floating
point numbers depending on whether or not they start with a zero. Who knew...
=)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206932 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-22 23:50:25 +00:00
David Blaikie 29d3b026fd Remove uses of SmallString::equals in favor of SmallVectorImpl<char>'s operator==
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203373 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-09 05:18:27 +00:00
Richard Smith 40de650390 PR18855: Add support for UCNs and UTF-8 encoding within ud-suffixes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201532 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-17 21:52:30 +00:00
NAKAMURA Takumi 2add97e841 NumericLiteralParser::ParseNumberStartingWithZero(): Try to appease MSC16's miscompilation.
Investigating yet. It seems msc16 miscompiles s[1] to be folded.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191485 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-27 04:42:28 +00:00
Richard Smith 7f270f002a Fix buildbot breakage.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191424 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-26 05:57:03 +00:00
Richard Smith 064c3f1ed7 Replace a bool with an enum for clarity, based on review comment from James Dennett.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191420 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-26 04:19:11 +00:00
Richard Smith 859b622769 Implement C++1y digit separator proposal (' as a digit separator). This is not
yet approved by full committee, but was unanimously supported by EWG.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191417 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-26 03:33:06 +00:00
Richard Smith 06dd2b317a 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.)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191274 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-24 04:06:10 +00:00
Eli Friedman 83b6397f2d Fix CharByteWidth assertion in LiteralSupport.
Patch by Eelis van der Weegen.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190971 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-18 23:23:13 +00:00
Nick Lewycky c3d9da2a59 Revert r188863 which could propose wrong fixits for multibyte character literals.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188918 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-21 18:57:51 +00:00
Nick Lewycky 6347a8af82 Issue fixits replacing invalid character literals with the equivalent \xNN
escape code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188863 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-21 04:10:58 +00:00
Nick Lewycky f3693889e7 No functionality change. Adjust a bunch of formatting issues in this code and
fix a typo in a comment.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188857 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-21 02:40:19 +00:00
Richard Smith 4ac537b0f0 C++1y literal suffix support:
* Allow ns, us, ms, s, min, h as numeric ud-suffixes
 * Allow s as string ud-suffix


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186933 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-23 08:14:48 +00:00
Eli Friedman b3da613977 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.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186903 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-23 00:25:18 +00:00
Richard Smith 2fcf0de8a1 Note that we support (and in fact have supported since the dawn of time itself)
C++1y binary literals.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179883 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-19 20:47:20 +00:00
Jordan Rose 3f6f51e282 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174768 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-08 22:30:41 +00:00
Dmitri Gribenko cb5620c9b2 Move UTF conversion routines from clang/lib/Basic to llvm/lib/Support
This is required to use them in TableGen.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173924 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-30 12:06:08 +00:00
Jordan Rose bfec916e5f 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173622 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-27 20:12:04 +00:00
Jordan Rose 5209e2bc4d Unify diagnostics for \x, \u, and \U without any following hex digits.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173368 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-24 20:50:13 +00:00
Jordan Rose 728bb4c418 Adopt llvm::hexDigitValue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172861 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18 22:33:58 +00:00
Richard Smith 80ad52f327 s/CPlusPlus0x/CPlusPlus11/g
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171367 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-02 11:42:31 +00:00
Chandler Carruth 55fc873017 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169237 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 09:13:33 +00:00
Benjamin Kramer 4f056ac7f8 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167594 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-08 19:22:31 +00:00
Benjamin Kramer 5d704fef6e LiteralSupport: Clean up style violations. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167593 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-08 19:22:26 +00:00
David Blaikie 82c6dc72ad Handle string encoding diagnostics when there are too many invalid ranges.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167059 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-30 23:22:22 +00:00
Seth Cantrell 5bffbe5c10 improve highlighting of invalid string encodings
limit highlight to exactly the bad encoding, and highlight every
bad encoding in a string.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166900 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-28 18:24:46 +00:00
Jordan Rose 2fd6956fd3 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164639 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-25 22:32:51 +00:00
Dmitri Gribenko 191046d050 Optimize NumericLiteralParser::GetIntegerValue().
It does a conservative estimate on the size of numbers that can fit into
uint64_t.  This bound is improved.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164624 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-25 19:09:15 +00:00
Dmitri Gribenko fc97ea29b1 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164484 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-24 09:53:54 +00:00
Richard Smith e5f0588840 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163459 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-08 07:16:20 +00:00
Nico Weber 941e47cef2 Share ConvertUTF8toWide() between Lex and CodeGen.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159634 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-03 02:24:52 +00:00
James Dennett a1263cfb87 Documentation cleanup: add \verbatim markup for grammar productions
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158740 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-19 21:04:25 +00:00
James Dennett 58f9ce1664 Documentation cleanup: added \verbatim...\verbatim markup to fix the
formatting of Doxygen's output for StringLiteralParser::StringLiteralParser.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158616 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-17 03:34:42 +00:00
Richard Smith 59b26d84b6 Fix off-by-one error in UTF-16 encoding: don't try to use a surrogate pair for U+FFFF.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158391 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-13 05:41:29 +00:00
Richard Smith df9ef1bc8c PR13099: Teach -Wformat about raw string literals, UTF-8 strings and Unicode escape sequences.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158390 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-13 05:37:23 +00:00
Argyrios Kyrtzidis 3144749f8b In StringLiteralParser::init, make sure we emit an error when
failing to lex the string, as suggested by Eli.

Part of rdar://11305263.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156081 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-03 17:50:32 +00:00