aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/cplusplus/Parser.h
Commit message (Collapse)AuthorAgeFilesLines
* CPlusPlus: Add support for coroutinesChristian Kandeler2023-03-061-0/+2
| | | | | | | | | Also fix some concept-related bugs uncovered by the test case. Change-Id: Ia67c971026bcd85d9cc252f46cd4f56c2865d432 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CPlusPlus: Support requires clause in parserChristian Kandeler2023-03-031-0/+1
| | | | | | | Change-Id: Ice6a7a287453516a1cfc296e2c9f16160b3ea130 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CPlusPlus: Handle C++20 concepts in parserChristian Kandeler2023-02-281-0/+5
| | | | | | | Change-Id: I8c6b8b1ba3f36b83cd1d667bec9830271147b1ac Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CPlusPlus: Remove unused parser functionsChristian Kandeler2022-10-211-10/+0
| | | | | | | | | | It's unclear whether they should actually be used, but right now their presence is confusing. Change-Id: I15d8a7a2524c3abc668bcd0a4b3e0e956f68b065 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
* CPlusPlus: Fix mis-parsing array-related constructsChristian Kandeler2022-08-251-1/+3
| | | | | | | | | | | ... as structured bindings. Also add a safety check to Bind that might be needed for invalid code. Amends ca00b874a7. Change-Id: I7b174b80ad97ed7424f1e369b876c99acf7e95d2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CPlusPlus: Support structured bindingsChristian Kandeler2022-08-231-0/+1
| | | | | | | | | | While we do recommend clangd for modern code bases, we should still be able to parse basic language constructs. Fixes: QTCREATORBUG-27975 Change-Id: I189b991685a5cd5f62f2afce77878b60c895e8f9 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
* C++: fix built-in code model to work with shared_ptr on MSVC 2017Volodymyr Zibarov2020-05-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Some clang-tidy -use-modernize-nullptrhjk2019-08-011-6/+6
| | | | | Change-Id: I1bed5e85a5b7948d08502a72a10f80baa075c204 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
* Standardize on int for line and column valueshjk2019-07-261-19/+19
| | | | | | | | | | | | | | | 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>
* Add support for nested namespaces (C++17)Colin Duquesnoy2018-02-091-0/+3
| | | | | | Task-number: QTCREATORBUG-16774 Change-Id: I3de3ac65810213e21c9a3bafef2474d252e191f7 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Wholesale conversion to #pragma oncehjk2016-03-301-5/+1
| | | | | | | Kudos to cgmb and https://github.com/cgmb/guardonce Change-Id: Ifa8970734b8d43fd08c9260c645bdb0228633791 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
* C++: Support noexcept operatorClaus Steuer2015-10-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | The code model failed to parse the noexcept operator which is often used in noexcept specifiers, e.g.: "void f() noexcept(noexcept(g()));" Consequently some c++11 headers such as unordered_map, array and unordered_set could not be parsed and no code completition was available. I have created the NoExceptOperatorExpressionAST class which is created whenever a noexcept token is found in an expression with operator precedence. The noExcept test case in the cplusplus/cxx11 test now contains a function that uses the noexcept operator. Fixed noexcept operator parsing Added the test requested by Sergey Shambir, which then revealed that i had not implemeneted the noexpect operator parsing according to the c++ specification. As stated here http://cpp0x.centaur.ath.cx/expr.unary.noexcept.html the noexcept operator is a unary-expression that contains an expression (and not a constant-expression). This should now be fixed. Change-Id: Id4a99a43b660bd83e7680274491d99a698b57094 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* C++: Remove pointless declarationsNikolai Kosjar2015-07-061-2/+0
| | | | | Change-Id: I78ac11e081fc1136d41459e8408f8788276a454e Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* C++: Limit parsing of initializer clausesNikolai Kosjar2015-05-131-0/+2
| | | | | | | | | ...to prevent out of memory crash for generated tables. Change-Id: I8f9f51829fcce5bccfe0dba8852023f8dd7d6e37 Task-number: QTCREATORBUG-14390 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* C++: Remove workaround for crashing if parsing invalid codeNikolai Kosjar2015-02-121-3/+1
| | | | | | | | | | | | | | | | | | This reverts the changes commit beac7b9539457fe721de1709b9a406cac2379851 C++: Fix highlighting after "invalid code" commit 78ab287fc6d3770646012e461b0a518db4e9c9f4 C++: Stop parsing a declaration after two tries which were a work around for QTCREATORBUG-12890. A follow-up patch provides a proper fix. Task-number: QTCREATORBUG-12890 Change-Id: I2650a8e41c8ff1180cad9f069e463fc51bd2f1b1 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* C++: Fix highlighting after "invalid code"Nikolai Kosjar2014-11-191-1/+2
| | | | | | | | | | | | | | | For the semantic info document we do not expand function like macros and because of that certain macro invocations lead to invalid code that we need to handle, e.g.: Q_GLOBAL_STATIC(CppTools::SymbolFinder, symbolFinder) class Foo {}; This change makes parsing Foo in the semantic info document successfully again, which affects highlighting of that class. Change-Id: I389265ac64d3f0b8b8f406d38fa58d78820b14ba Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* C++: Stop parsing a declaration after two triesNikolai Kosjar2014-11-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we fail to parse a declaration, we rewind, eat the token and look for the next token that might be a good candidate for a declaration start (e.g. an identifier). This becomes cpu and memory expensive with super long and invalid expressions like typedef b::m::if_< b::m::bool_< (sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<70> *) 0)) == sizeof(defined_)) >, b::m::if_< b::m::bool_< (sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<71> *) 0)) == sizeof(defined_)) >, b::m::if_< b::m::bool_< (sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<72> *) 0)) == sizeof(defined_)) >, b::m::if_< b::m::bool_< (sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<73> *) 0)) == sizeof(defined_)) >, b::m::if_< b::m::bool_< (sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<74> *) 0)) == sizeof(defined_)) >, b::m::if_< b::m::bool_< (sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<75> *) 0)) == sizeof(defined_)) >, b::m::if_< b::m::bool_< // ...some more crazy lines like this Therefore, stop trying after two failures by looking for the next semicolon or closing curly brace. Task-number: QTCREATORBUG-12890 Change-Id: I6637daeb840dd549d669080775228fa91fc932eb Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* C++: Fix expensive parsing of expressionsNikolai Kosjar2014-07-241-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | For expression statements like "(g(g(g(...(g(0))...))))" we reparsed quite much again and again for nothing. The high-level trace for this expression looks like this: parseCastExpression parseTypeId parseAbstractDeclarator parseAbstractCoreDeclarator parseParameterDeclarationClause (--> DEEP) ... parseUnaryExpression ... parseCorePostfixExpression parseTypeId (--> DEEP) parsePrimaryExpression (--> DEEP) Especially parseTypeId is expensive in this case and it's called two times, both from the same token (index). With this patch, we remember for certain ASTs the parse results and re-use them when needed. Change-Id: I013d1c064c655636bc94db408097863b5e183fc2 Task-number: QTCREATORBUG-12252 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++: Remove superfluous declarations in ParserNikolai Kosjar2014-07-241-4/+0
| | | | | Change-Id: I6bf729a999494a84eb235a891ea14bbccd44aeb8 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++: Support alignas in C++11 mode.Erik Verbruggen2014-07-221-2/+4
| | | | | | Change-Id: Ifa81a481bf92b5b71495a105ae292f3e9895f704 Task-number: QTCREATORBUG-9279 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* C++: block recursion when parsing subsequent case statements.Erik Verbruggen2014-07-221-1/+1
| | | | | | | | | | | | | | | | | | A case or a default statement must be followed by another statement. When a such a case (or default) statement is followed immediately by another case (or default) statement, then this would create a linked list, and the parser will recurse to parse such input. In order to prevent the parser running out of stack space while recursing, parse this corner case by blocking parsing a labeled statement as the first statement after a labeled statement. The advantage is that these statements do not form a linked list, so any subsequent visitation of the AST won't run out of stack space either. Change-Id: Id2111a49509132997f5fbe4bb12c92c729ec2522 Task-number: QTCREATORBUG-12673 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* C: Parser: Support parsing of c99 designated initializersWang Hoi2014-06-171-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | 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++11: Fix parsing of trailing-type-specifier.Christian Kamm2014-06-041-7/+9
| | | | | | | In particular "auto foo() -> typename Foo<T>::X;" didn't parse. Change-Id: I7665c9b387e222e4107f053a529d502813ebf617 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* C++: Remove dead code in the parserPovilas Kanapickas2014-01-201-1/+0
| | | | | | | | CPlusPlus::Parser::parseAccessSpecifier() is not used anywhere throughout the QtCreator codebase. Change-Id: I062a4ae257b9c61f02bf85079feb6d48bd07c49e Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* CPlusPlus: Make (sub-)languague selection more generichjk2013-10-151-12/+1
| | | | | Change-Id: I4e2df6992b446adec662ab07671acd41715e41fd Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* C++: Add parser support for @throw statements.Erik Verbruggen2013-08-211-0/+1
| | | | | Change-Id: I366733ec821ee264f182f4d4a3cf69cdada20cfc Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* C++: handle @try statements in the parser.Erik Verbruggen2013-07-191-0/+1
| | | | | | | | | No semantic analysis yet, but this prevents the parser from generating bogus diagnostics. Task-number: QTCREATORBUG-9309 Change-Id: I2ec575a8474cd51bfa97b17678d3da71ab8dcd7a Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* C++: Inline {TranslationUnit,Parser}::blockErrorshjk2013-04-181-1/+1
| | | | | | | As indicated by profiling. Change-Id: I04d741dcc6200eb351d7aec316572e0e94ef5bec Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* CPlusPlus: fixed parsing function-try-catch with ctor-initializerSergey Shambir2013-04-091-1/+1
| | | | | | | | | | C++ standard defines that 'try' should be before optional ctor initializer, so wrong order changed. Added documentation to parseTryBlockStatement and new test. Task-number: QTCREATORBUG-9064 Change-Id: Id19cdc53c034cb1232ae27e0bfe36d85b7ad0452 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* C++11: More (expression-list) or brace-init-list.Christian Kamm2012-09-191-1/+1
| | | | | | | | | This time in the 'new' expression. Changed it to make new C(1, abc...) and new C{1, abc} work. Change-Id: I7232798fd083b653ee04ef9ede386d6536133e16 Reviewed-by: hjk <qthjk@ovi.com>
* C++11: Make expression-list expand to initializer-list.Christian Kamm2012-09-191-2/+1
| | | | | | | | | | | | | This will fix a couple more places where brace-init-lists and pack expansions are allowed but are not currently accepted by the parser. For example: foo(abc...); now parses correctly. Change-Id: I93710cef35154fea8437329f3174e4a2d56637b8 Reviewed-by: hjk <qthjk@ovi.com>
* C++11: Fix use of >> in template arguments.Christian Kamm2012-09-191-1/+2
| | | | | Change-Id: Ic99ca897e7a3b9c82cf8c5093a90bf9c88dbb0ed Reviewed-by: hjk <qthjk@ovi.com>
* C++11: Parse alias declarations.Christian Kamm2012-09-191-0/+2
| | | | | | | | The parser no longer fails declarations like: using Foo = std::vector<int>::iterator; Change-Id: Ib3a552ebbe0147fa138db6448a52cdba8f9b9207 Reviewed-by: hjk <qthjk@ovi.com>
* C++11: Accept ref-qualifiers in function declarators.Christian Kamm2012-09-191-0/+1
| | | | | | | | | | Means void foo() const &; void bar() &&; and the corresponding pointer-to-member declarators now parse. Change-Id: Idbf295bd4f51cd5d9e38efcac1940b8cc2e32fce Reviewed-by: hjk <qthjk@ovi.com>
* C++11: Allow uniform initialization in ctor init lists.Christian Kamm2012-09-191-0/+1
| | | | | | | | | So class C { C() : _x{12}, _y({12}) {} }; now parses correctly. Change-Id: I4281dcb0541a86b550e74630cad6ae0a59fef1b4 Reviewed-by: hjk <qthjk@ovi.com>
* C++: Rename NewPlacementAST to ExpressionListParenAST.Christian Kamm2012-09-171-1/+1
| | | | | | | | It'll be reused as the initializer expression for declarators that are followed by "( expression-list )". Change-Id: I6c76a76641941874ef1ed21daa7b6e057c6d170f Reviewed-by: hjk <qthjk@ovi.com>
* Added support for override/final and enum classesSergey Shambir2012-07-301-0/+1
| | | | | Change-Id: I6dfe9dd606781046ff5a1ed61315741d2f332cb8 Reviewed-by: Christian Kamm <christian.d.kamm@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++: Recognize C++11 nullptrLeandro Melo2011-11-181-0/+1
| | | | | Change-Id: I5b7ac8f9b2137ffe9439ada4ec4aeb9cee8e249d Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* Fixed stack-overflow when parsing insanely nested compound statements.Erik Verbruggen2011-10-171-0/+1
| | | | | | | | Thanks to Clang's parser_overflow.cpp which has >16000 nested compound statements to check exactly the same. Change-Id: I2b604f8ceb01115d7fe950994e0677a081e99481 Reviewed-by: Christian Kamm <christian.d.kamm@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/+364
Approved-by: legal