summaryrefslogtreecommitdiff
path: root/lib/Lex/LiteralSupport.cpp
Commit message (Collapse)AuthorAge
* Convert StringLiteralParser constructor to use ArrayRef instead of a pointer ↵Craig Topper2014-06-26
| | | | | | and count. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211763 91177308-0d34-0410-b5e6-96231b3b80d8
* Lex: Use the correct types for MS integer suffixesDavid Majnemer2014-06-21
| | | | | | | | | | | | | | | | 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
* Revert "Lex: Use the correct types for MS integer suffixes"Rafael Espindola2014-06-21
| | | | | | | | | 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
* Lex: Use the correct types for MS integer suffixesDavid Majnemer2014-06-21
| | | | | | | | | | | | 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
* Permit the "if" literal suffix with Microsoft extensions enabled.Peter Collingbourne2014-05-29
| | | | | | Differential Revision: http://reviews.llvm.org/D3963 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209859 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove limits on the number of fix-it hints and ranges in the DiagnosticsEngine.Alexander Kornienko2014-05-22
| | | | | | | | | | | | | | | | | | | 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
* [C++11] Use 'nullptr'. Lex edition.Craig Topper2014-05-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209083 91177308-0d34-0410-b5e6-96231b3b80d8
* Add some missing checks for C++1y digit separators that don't in fact separateRichard Smith2014-04-22
| | | | | | | | | 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
* Remove uses of SmallString::equals in favor of SmallVectorImpl<char>'s ↵David Blaikie2014-03-09
| | | | | | operator== git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203373 91177308-0d34-0410-b5e6-96231b3b80d8
* PR18855: Add support for UCNs and UTF-8 encoding within ud-suffixes.Richard Smith2014-02-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201532 91177308-0d34-0410-b5e6-96231b3b80d8
* NumericLiteralParser::ParseNumberStartingWithZero(): Try to appease MSC16's ↵NAKAMURA Takumi2013-09-27
| | | | | | | | 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
* Fix buildbot breakage.Richard Smith2013-09-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191424 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace a bool with an enum for clarity, based on review comment from James ↵Richard Smith2013-09-26
| | | | | | Dennett. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191420 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement C++1y digit separator proposal (' as a digit separator). This is notRichard Smith2013-09-26
| | | | | | | 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
* Handle standard libraries that miss out the space when defining the standardRichard Smith2013-09-24
| | | | | | | | | 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
* Fix CharByteWidth assertion in LiteralSupport.Eli Friedman2013-09-18
| | | | | | Patch by Eelis van der Weegen. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190971 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r188863 which could propose wrong fixits for multibyte character ↵Nick Lewycky2013-08-21
| | | | | | literals. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188918 91177308-0d34-0410-b5e6-96231b3b80d8
* Issue fixits replacing invalid character literals with the equivalent \xNNNick Lewycky2013-08-21
| | | | | | | escape code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188863 91177308-0d34-0410-b5e6-96231b3b80d8
* No functionality change. Adjust a bunch of formatting issues in this code andNick Lewycky2013-08-21
| | | | | | | fix a typo in a comment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188857 91177308-0d34-0410-b5e6-96231b3b80d8
* C++1y literal suffix support:Richard Smith2013-07-23
| | | | | | | | * 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
* Integers which are too large should be an error.Eli Friedman2013-07-23
| | | | | | | | 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
* Note that we support (and in fact have supported since the dawn of time itself)Richard Smith2013-04-19
| | | | | | | C++1y binary literals. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179883 91177308-0d34-0410-b5e6-96231b3b80d8
* Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.Jordan Rose2013-02-08
| | | | | | | 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
* Move UTF conversion routines from clang/lib/Basic to llvm/lib/SupportDmitri Gribenko2013-01-30
| | | | | | | 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
* PR15067: Don't assert when a UCN appears in a C90 file.Jordan Rose2013-01-27
| | | | | | | 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
* Unify diagnostics for \x, \u, and \U without any following hex digits.Jordan Rose2013-01-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173368 91177308-0d34-0410-b5e6-96231b3b80d8
* Adopt llvm::hexDigitValue.Jordan Rose2013-01-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172861 91177308-0d34-0410-b5e6-96231b3b80d8
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-02
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171367 91177308-0d34-0410-b5e6-96231b3b80d8
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-04
| | | | | | | | | | | | | 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
* LiteralSupport: Don't overflow the temporary buffer when decoding invalid ↵Benjamin Kramer2012-11-08
| | | | | | | | | 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
* LiteralSupport: Clean up style violations. No functionality change.Benjamin Kramer2012-11-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167593 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle string encoding diagnostics when there are too many invalid ranges.David Blaikie2012-10-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167059 91177308-0d34-0410-b5e6-96231b3b80d8
* improve highlighting of invalid string encodingsSeth Cantrell2012-10-28
| | | | | | | 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
* Rename CanFitInto64Bits to alwaysFitsInto64Bits per discussion on IRC.Jordan Rose2012-09-25
| | | | | | | | | | | | | 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
* Optimize NumericLiteralParser::GetIntegerValue().Dmitri Gribenko2012-09-25
| | | | | | | | 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
* Small cleanup of literal semantic analysis: hiding 'char *' pointers behindDmitri Gribenko2012-09-24
| | | | | | | | 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
* When a bad UTF-8 encoding or bogus escape sequence is encountered in aRichard Smith2012-09-08
| | | | | | | | 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
* Share ConvertUTF8toWide() between Lex and CodeGen.Nico Weber2012-07-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159634 91177308-0d34-0410-b5e6-96231b3b80d8
* Documentation cleanup: add \verbatim markup for grammar productionsJames Dennett2012-06-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158740 91177308-0d34-0410-b5e6-96231b3b80d8
* Documentation cleanup: added \verbatim...\verbatim markup to fix theJames Dennett2012-06-17
| | | | | | | 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
* Fix off-by-one error in UTF-16 encoding: don't try to use a surrogate pair ↵Richard Smith2012-06-13
| | | | | | for U+FFFF. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158391 91177308-0d34-0410-b5e6-96231b3b80d8
* PR13099: Teach -Wformat about raw string literals, UTF-8 strings and Unicode ↵Richard Smith2012-06-13
| | | | | | escape sequences. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158390 91177308-0d34-0410-b5e6-96231b3b80d8
* In StringLiteralParser::init, make sure we emit an error whenArgyrios Kyrtzidis2012-05-03
| | | | | | | | 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
* In StringLiteralParser::init(), fail gracefully if the string isArgyrios Kyrtzidis2012-05-03
| | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156043 91177308-0d34-0410-b5e6-96231b3b80d8
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-11
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152536 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve diagnostics for UCNs referring to control characters and members of theRichard Smith2012-03-09
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152444 91177308-0d34-0410-b5e6-96231b3b80d8
* When checking the encoding of an 8-bit string literal, don't just check theRichard Smith2012-03-08
| | | | | | | | first codepoint! Also, don't reject empty raw string literals for spurious "encoding" issues. Also, don't rely on undefined behavior in ConvertUTF.c. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152344 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for cooked forms of user-defined-integer-literal andRichard Smith2012-03-08
| | | | | | | | user-defined-floating-literal. Support for raw forms of these literals to follow. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152302 91177308-0d34-0410-b5e6-96231b3b80d8
* User-defined literal support for character literals.Richard Smith2012-03-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152277 91177308-0d34-0410-b5e6-96231b3b80d8
* Lexing support for user-defined literals. Currently these lex as the same tokenRichard Smith2012-03-05
| | | | | | | | kinds as the underlying string literals, and we silently drop the ud-suffix; those issues will be fixed by subsequent patches. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152012 91177308-0d34-0410-b5e6-96231b3b80d8