aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/cplusplus/Token.h
Commit message (Collapse)AuthorAgeFilesLines
* CppEditor: Add support for init statements in if conditionsChristian Kandeler2023-05-251-0/+1
| | | | | | Fixes: QTCREATORBUG-29182 Change-Id: I9b7969da694b368236246123ad0028d8e754e903 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CPlusPlus: Add lexer support for new C++20 keywordsChristian Kandeler2023-02-091-0/+8
| | | | | Change-Id: I2b83deb0502ebf2cdca2af774fbb2ce26e947c11 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Cpp: support space ship operator in lexerDavid Schulz2023-01-301-0/+2
| | | | | | Fixes: QTCREATORBUG-27503 Change-Id: Idbff5a9b5b2e6e841e298ca6f706ef3c6aa1622b Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* C++: fix built-in code model to work with shared_ptr on MSVC 2017Volodymyr Zibarov2020-05-291-0/+3
| | | | | | | | | | | | | | | | | | | | | | | These changes target Find Usages feature to work with shared_ptr. Improve libs/3rdparty/cplusplus and plugins/cplusplus: parse __declspec() attribute, call to variadic function template without specified template arguments, if constexpr, c++11 attributes [[value]], function templates with default parameters, resolve order for function vs template with default parameter, template operator->() with default arguments, template specialization with numeric values, find best partial specialization, fix partial specialization for non-first specialized argument Fixes: QTCREATORBUG-7866 Fixes: QTCREATORBUG-20781 Fixes: QTCREATORBUG-22857 Fixes: QTCREATORBUG-17825 Change-Id: I31a080f7729edfb2ee9650f1aff48daeba5a673b Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Nikolai Kosjar <pinaceae.pinus@gmail.com>
* C++: Fix cplusplus-keywordgen to generate Keywords.cppVolodymyr Zibarov2020-05-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | | Fix kewordgen to generate current Keywords.cpp with minimal diff, but also to be compatible with old usage and kwgen files. Add new parameters: %no-namespace-for-tokens - not use namespace for tokens %pre-check-argument - set type and name of additional variable to use %function-name - name of a function ("classify" by default) %pre-check - name of a variable to check for a keyword (i.e. cxxEnabled) Now "%%" is also used to end and restart keywords parsing to be able to generate additional keywords for classifyOperator() Automatically add checks for LanguageFeatures to generated code Pass input and output files with command line arguments, print usage Update Keywords.kwgen to include all keywords currently used Add missing aliases to Token.h Change-Id: I6cc84e150e0d797277204032fc05ce9cfbd01f58 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Some clang-tidy -use-modernize-nullptrhjk2019-08-011-1/+1
| | | | | Change-Id: I1bed5e85a5b7948d08502a72a10f80baa075c204 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
* Standardize on int for line and column valueshjk2019-07-261-7/+7
| | | | | | | | | | | | | | | Recently tons of warnings show up for presumably "problematic" singned <-> unsigned and size conversions. The Qt side uses 'int', and that's the biggest 'integration surface' for us, so instead of establishing some internal boundary between signed and unsigned areas, push that boundary out of creator core code, and use 'int' everywhere. Because it reduces friction further, also do it in libcplusplus. Change-Id: I84f3b79852c8029713e7ea6f133ffb9ef7030a70 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* C++: Support single quote digit separator in integer literalsJoel Smith2019-07-091-0/+1
| | | | | | | | | | C++14 supports the use of single quotes inserted between integer digits as a separator. Updates the built-in C++ code model to recognize such quotes. This fixes highlighting and indentation issues. Change-Id: Ic35ce93060b96700a11d108dce1f3cf6c4543632 Fixes: QTCREATORBUG-14939 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* CPlusPlus: Fix enum valueChristian Stenger2019-01-311-1/+2
| | | | | Change-Id: I87dc174be5a9c29ed4770bcb5630d935c9bc8e3f Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Highlighting: Add highlighting style for punctuationIvan Donchevskii2018-09-131-0/+3
| | | | | | | | | Currently only operators have their own style but not punctuation tokens. Make possible to highlight both. Task-number: QTCREATORBUG-20666 Change-Id: I9533e0f1bef65b86c4e4f5c9756571103584124b Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* TextEditor: Highlight punctuators as TextHugo Holgersson2018-05-031-12/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change limits the set of tokens that fall under Token::isOperator(). That allows cpphighlighter.cpp to distinguish operator tokens from punctuator tokens (without changing any logic in cpphighlighter.cpp). This change moves punctuators from "Operator" to the "Text" style category where they belong. Punctuators are not operators. Punctuators are dumb text tokens. Why don't we let the clang backend alone separate these tokens for us? 1. Clang is slow on big files. Sometimes the highlighting dictated by clang is painted _seconds_ after cpphighlighter.cpp runs. CppHighlighter is way faster so we use it to "prepaint" code while clang is busy in the background. 2. Secondly, clang cannot yet handle all operator types. In particular, none if its "operator cursors" CXCursor_UnaryOperator: CXCursor_BinaryOperator: CXCursor_CompoundAssignOperator: CXCursor_ConditionalOperator: includes the -> and . operators. We still need CppHighlighter to paint those tokens. However, once clang has finished processing the file some operator tokens will be repainted. We need clang to get all operators' semantics. In particular, we need clang to tell us if < is a "smaller than"-operator or part of a template parameter like set<int>. Task-number: QTCREATORBUG-19659 Change-Id: I952cb58f7c79134b3281e2a8221425cc1d0ad263 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* CppEditor: Do not highlight C++ and Qt keywords for CNikolai Kosjar2017-05-161-0/+10
| | | | | | | Task-number: QTCREATORBUG-2818 Task-number: QTCREATORBUG-18004 Change-Id: Ibca60a1711c827dd8b4c0486bff3d49b19a61d8b Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* C++: Disable C++ keywords in C filesFrancois Ferrand2016-08-231-0/+1
| | | | | | | | | | | | In some (legacy) C files, new and delete may be used for regular identifier. There are some limitations: * Header files have no 'implicit' type, and may be parsed as C++ or ObjC depending on the other files in the project. * QMakeProject use a single ProjectPart for C and C++ files, so there will still be the issue. Change-Id: Iec11687b35f7ccf1e7c0d091b143ae90d950e440 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Wholesale conversion to #pragma oncehjk2016-03-301-4/+1
| | | | | | | Kudos to cgmb and https://github.com/cgmb/guardonce Change-Id: Ifa8970734b8d43fd08c9260c645bdb0228633791 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
* C++: fix trigraph parsing in macros.Francois Ferrand2016-03-081-1/+3
| | | | | | | | | | | | Trigraphs must only be parsed before/during preprocessing. The preprocessor will now replace trigraphs with their standard form, and re-lexing in TranslationUnit will not try to parse any trigraph. Also added a few missing trigraphs: ??=, ??', ??! and ??-. Task-number: QTCREATORBUG-13253 Change-Id: I1723ed53b00090b878c22b83b7e963b647b65f72 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* C++: Parse __alignof__Orgad Shaneh2015-10-021-0/+1
| | | | | Change-Id: I093c2a786cf8f10de4f05c23f3763ef1300feabd Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* C++: Highlight multi-line raw string literalsNikolai Kosjar2015-09-231-1/+3
| | | | | | | Task-number: QTCREATORBUG-13094 Change-Id: I4e6b8c202677f4c1cd4df95d59130ba8379e72fe Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* C++: Use correct features for document parsingOrgad Shaneh2015-02-201-0/+6
| | | | | | Task-number: QTCREATORBUG-8007 Change-Id: Ic96aaa433442812a99bac9d16bb9124d66762e8c Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* CppTools: Add basic completion support for qt5 style signals/slotsNikolai Kosjar2015-02-171-1/+2
| | | | | | | | | | | Trigger completion for Qt5 signals/slots as soon as the user types '&' in connect(object, & connect(object, &Foo:signal, object2, & Change-Id: I338a26415196959e3dc413bdfd023314812f3aaa Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* C++: Basic support for C++11 user-defined literalsAdam Strzelecki2015-02-171-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | 1. Extends lexer so digit or string can be followed by underscore '_' and alphanumeric defining literal. 2. Extends parser so it accepts operator"" _abc(...) user-defined literal definition. 3. Adds Token::Flags.userDefinedLiteral bool flag field representing if token carries user-defined literal. 4. Adds C++11 auto tests case with: 12_km, 0.5_Pa, 'c'_X, "abd"_L, u"xyz"_M 5. All optional suffix scanning methods now return boolean if the suffix was found. 6. Adds C++ Lexer tests for user-defined literals with C++11 feature enabled. This change however does not make QtCreator understand user-defined literal semantics, e.g. properly resolve type when applying custom literal operator. Change-Id: I30e62f025ec9fb11c39261985ea4d772b1a80949 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* C++: change return type to enum.Erik Verbruggen2014-08-201-1/+1
| | | | | | | And not have it converted to int after converting to unsigned. Change-Id: If95caec46936c2a140c3fbd668fa2f085a9287ed Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* CppEditor: Fix always-false-conditionNikolai Kosjar2014-06-241-4/+6
| | | | | | | | The condition didn't make sense. tk.kind() can't be < T_FIRST_QT_KEYWORD *and* tk.kind() > T_LAST_KEYWORD at the same time. Change-Id: Id300ad84f37eeff5081b0389c00d574a9cb23f35 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* Add syntax highlight for primitive data typesAnton Kalmykov2014-06-241-14/+22
| | | | | | | | Syntax highlight rules for keywords are changed to highlight control keywords and primitive data types separately. Change-Id: Ifb25be7a97b92589030aa190641320c233dc7f2d Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* C: Parser: Support parsing of c99 designated initializersWang Hoi2014-06-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | In case: int a[6] = { [4] = 29, [2] = 15 }; struct point { int x, y; }; struct point p = { .y = 3, .x = 2 }; Grammar change when c99 language feature is enabled: old grammar: braced-init-list :: '{' initializer-list '}' new grammar: braced-init-list :: '{' designated-initializer-list '}' designated-initializer-list :: designated-initializer (',' designated-initializer )* designated-initializer :: designator* initializer-clause designator :: '.' identifier | '[' constant-expression ']' Task-number: QTCREATORBUG-1902 Change-Id: Ib99d6f553f8d0f50ba3eff86f3a2e86d73372426 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* C++: Support for UTF-8 in the lexerNikolai Kosjar2014-05-231-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will save us toLatin1() conversations in CppTools (which already holds UTF-8 encoded QByteArrays) and thus loss of information (see QTCREATORBUG-7356). It also gives us support for non-latin1 identifiers. API-wise the following functions are added to Token. In follow-up patches these will become handy in combination with QStrings. utf16chars() - aequivalent of bytes() utf16charsBegin() - aequivalent of bytesBegin() utf16charsEnd() - aequivalent of bytesEnd() Next steps: * Adapt functions from TranslationUnit. They should work with utf16 chars in order to calculate lines and columns correctly also for UTF-8 multi-byte code points. * Adapt the higher level clients: * Cpp{Tools,Editor} should expect UTF-8 encoded Literals. * Cpp{Tools,Editor}: When dealing with identifiers on the QString/QTextDocument layer, code points represendet by two QChars need to be respected, too. * Ensure Macro::offsets() and Document::MacroUse::{begin,end}() report offsets usable in CppEditor/CppTools. Addresses QTCREATORBUG-7356. Change-Id: I0791b5236be8215d24fb8e38a1f7cb0d279454c0 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++: Clarify units of a TokenNikolai Kosjar2014-05-151-17/+17
| | | | | | | | | | | | | This will avoid confusion when later more length and indices methods are added. In Token: length() --> bytes() begin() --> bytesBegin() end() --> bytesEnd() Change-Id: I244c69b022e239ee762b4114559e707f93ff344f Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* Fix some typosSergio Ahumada2014-03-051-2/+2
| | | | | | Change-Id: I3be73c2a4d256a0d28e863fd2517a4d7442b34d8 Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
* C++: Support __thread and thread_localOrgad Shaneh2013-11-261-0/+2
| | | | | | | Task-number: QTCREATORBUG-7679 Change-Id: I794f52b2bcfb6c78ceef86ec53b6ed32b3d53d9f Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* CPlusPlus: Make (sub-)languague selection more generichjk2013-10-151-0/+16
| | | | | Change-Id: I4e2df6992b446adec662ab07671acd41715e41fd Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* C++11: Add the alignof and alignas tokens.Christian Kamm2012-09-171-1/+3
| | | | | Change-Id: I7f60057953787b3300aafa4d3f230f10b1e9a50f Reviewed-by: hjk <qthjk@ovi.com>
* C++: Introduce C++11 raw string literalsLeandro Melo2012-08-231-0/+5
| | | | | | | | | | | | Although they are now supported by the lexer and parser, it is worth to remind that we still need to address an issue concerning the highlight of multiline literals (which with the advent of the new raw strings will become more common). Task-number: QTCREATORBUG-6722 Change-Id: I137337a9ac0152a1f8b9faded0b960c6fe3dd38a Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* C++: Parse emit/Q_EMIT properlyLeandro Melo2012-06-281-1/+3
| | | | | | | | | | | | | | | | | The parser now understands emit/Q_EMIT as an expression statement. Also, the recent fixes in the preprocessor introduced a side-effect in the hanlding of code such as: emit signal(); Member signal started being treated as a local use (parsed as a declaration) and possibily being highlighted as unused variable. Previously that worked by accident since there was an inconsistency in the preprocessor on which only object-like macros were being expanded even when the "no expand" flag was set. Then, the code mentioned above was being parsed as an expression, what kind of worked. Change-Id: I47a68ed4c1c1702872620b8ed7c7264fb0997034 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* C++: Core changes in preprocessingLeandro Melo2012-06-251-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary of most relevant items: - Preprocessor output format change. No more gen true/false. Instead a more intuitive and natural expansion (like from a real compiler) is performed directly corresponding to the macro invocation. Notice that information about the generated tokens is not lost, because it's now embedded in the expansion section header (in terms of lines and columns as explained in the code). In addition the location on where the macro expansion happens is also documented for future use. - Fix line control directives and associated token line numbers. This was not detected in tests cases because some of them were actually wrong: Within expansions the line information was being considered as originally computed in the macro definition, while the desired and expected for Creator's reporting mechanism (just like regular compilers) is the line from the expanded version of the tokens. - Do not allow for eager expansion. This was previously being done inside define directives. However, it's not allowed and might lead to incorrect results, since the argument substitution should only happen upon the macro invocation (and following nested ones). At least GCC and clang are consistent with that. See test case tst_Preprocessor:dont_eagerly_expand for a detailed explanation. - Revive the 'expanded' token flag. This is used to mark every token that originates from a macro expansion. Notice, however, that expanded tokens are not necessarily generated tokens (although every generated token is a expanded token). Expanded tokens that are not generated are those which are still considered by our code model features, since they are visible on the editor. The translation unit is smart enough to calculate line/column position for such tokens based on the information from the expansion section header. - How expansions are tracked has also changed. Now, we simply add two surrounding marker tokens to each "top-level" expansion sequence. There is an enumeration that control expansion states. Also, no "previous" token is kept around. - Preprocessor client methods suffered a change in signature so they now receive the line number of the action in question as a paramater. Previously such line could be retrieved by the client implementation by accessing the environment line. However, this is not reliable because we try to avoid synchronization of the output/environment lines in order to avoid unnecessary output, while expanding macros or handling preprocessor directives. - Although macros are not expanded during define directives (as mentioned above) the preprocessor client is now "notified" when it sees a macro. This is to allow usage tracking. - Other small stuff. This is all in one patch because the fixes are a consequence of the change in preprocessing control. Change-Id: I8f4c6e6366f37756ec65d0a93b79f72a3ac4ed50 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* C++: Introduce unicode char/strings supportLeandro Melo2012-06-061-1/+8
| | | | | | | | | | | | | | Those are the types char16_t and char32_t along with the new char/string literals u'', U'', u"", u8"", and U"". This is particularly important for the use of QStringLiteral since in some platforms it relies on expansion such as above. Note: The string literals quickfixes still need some tunning. Task-number: QTCREATORBUG-7449 Change-Id: Iebcfea15677dc8e0ebb6143def89a5477e1be7d4 Reviewed-by: hjk <qthjk@ovi.com>
* C++: Add Token::isStringLiteral and Token::isCharLiteralLeandro Melo2012-06-061-2/+12
| | | | | | | | It will be particularly handy when introducing the new C++11 string/char literals: U"abc", u"abc", u8"abc", U'a', u'a'. Change-Id: Ic250f5a7b999da322debb24fc0171aaef333f356 Reviewed-by: hjk <qthjk@ovi.com>
* cplusplus: do not use out-of-line constructor and destructor for Tokenhjk2012-04-181-2/+1
| | | | | Change-Id: I10320b01a567789585a6af111de4de3f95883bd1 Reviewed-by: hjk <qthjk@ovi.com>
* C++11: first set of changes for decltype.Erik Verbruggen2012-02-101-0/+3
| | | | | Change-Id: I49d6ff7eb1805cd07bdfcb27bb37d4c6cadc9115 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* C++11: add support for static_assert.Erik Verbruggen2012-02-021-0/+1
| | | | | Change-Id: I82d8d60acaa9265fd25e0a3734855b19bdef9c06 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* C++11: handle noexcept specifications.Erik Verbruggen2012-02-021-0/+1
| | | | | Change-Id: I7da3affea2758b2e01124105e2521e1f2c5f6678 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* C++: Recognize C++11 nullptrLeandro Melo2011-11-181-0/+1
| | | | | Change-Id: I5b7ac8f9b2137ffe9439ada4ec4aeb9cee8e249d Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* C++: Recognize C++11 constexprLeandro Melo2011-11-181-0/+1
| | | | | Change-Id: Iac8ba58404284f0d90fd5a3640eb9ccd7e98058d Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* remove nokia copyrights from roberto's codeOswald Buddenhagen2011-05-161-31/+0
| | | | | | | | they are lying. nokia has no copyright on this code. and the double license in a single file looks weird. that's why we moved it to 3rdparty/, so it is clear it is not nokia's. Approved-by: legal
* move src/shared/cplusplus/ -> src/libs/3rdparty/cplusplus/Oswald Buddenhagen2011-05-161-0/+362
Approved-by: legal