aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/cplusplus/Parser.cpp
Commit message (Collapse)AuthorAgeFilesLines
* CPlusPlus: Fix parser crashChristian Kandeler2023-11-241-2/+2
| | | | | | | | | The parseCompoundStatement() function can return without setting the output parameter if the maximum statement depth is exceeded. Task-number: QTCREATORBUG-29847 Change-Id: Ifd76cd948c30498863246a1b80bd0657950101ca Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CPlusPlus: Fix crash on weird-looking constructChristian Kandeler2023-08-181-0/+5
| | | | | | | | | | | This was misparsed as a function with an initializer (e.g. "= default"), and then the empty id caused trouble later on. Fixes: QTCREATORBUG-29386 Change-Id: I85a35db544e11ad85f50e3a15b1a071b36e79cd0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* CppEditor: Revert changes to parseExpressionStatement()Christian Kandeler2023-05-261-12/+22
| | | | | | | | | | | | | Amends c8f29b9e0148202ab1959466e14fa23411fd8214. It turns out that there are contexts where we want to parse an expression statement even with the semicolon missing (e.g. completion on incomplete code). So leave the existing functions unchanged and do the thorough check afterwards in parseIfStatement(). Change-Id: Id6209ef1abfe9d155c5b9381e6ae655cc721feb2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Add support for init statements in if conditionsChristian Kandeler2023-05-251-6/+21
| | | | | | Fixes: QTCREATORBUG-29182 Change-Id: I9b7969da694b368236246123ad0028d8e754e903 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CPlusPlus: Add parser support for generic lambdasChristian Kandeler2023-03-131-2/+28
| | | | | | Change-Id: Id17975a4296925c10b1b43f963412eea61ccfa5d Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CPlusPlus: Add support for coroutinesChristian Kandeler2023-03-061-18/+59
| | | | | | | | | 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/+18
| | | | | | | 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-1/+184
| | | | | | | 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>
* Cpp: support space ship operator in lexerDavid Schulz2023-01-301-18/+21
| | | | | | Fixes: QTCREATORBUG-27503 Change-Id: Idbff5a9b5b2e6e841e298ca6f706ef3c6aa1622b Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* CPlusPlus: Allow " = default" also on function implementationsChristian Kandeler2022-10-241-1/+1
| | | | | | | | | | | Note that we only make sure not to trip over valid code; we make no effort to check whether default/delete is actually allowed at this type of declaration. Fixes: QTCREATORBUG-28102 Change-Id: Ic693319b9dfaf8652cf4cae9cd907a6e258ad773 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CPlusPlus: Remove unused parser functionsChristian Kandeler2022-10-211-50/+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-18/+25
| | | | | | | | | | | ... 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/+42
| | | | | | | | | | 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>
* CPlusPlus: Increase maximum statement depthChristian Kandeler2021-04-201-1/+1
| | | | | | | | | | We're hitting the limit in a real-world project. (Of course, it's pretty horrific that we unconditionally access pointers that can legally be null, but that's difficult to change now.) Fixes: QTCREATORBUG-25606 Change-Id: I1d8c883550e8968bbfa6ce26965573697774361f Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Merge remote-tracking branch 'origin/4.14'Eike Ziller2021-01-121-0/+2
|\ | | | | | | Change-Id: I26a53ef81a54a2f7aa482448118298895b712941
| * CPlusPlus lib: Add support for BINDABLE in Q_PROPERTYLeander Schulten2021-01-081-0/+2
| | | | | | | | | | Change-Id: I8ca00aff63261eea997267d41b12c2397d676748 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | CPlusPlus: Support C++11 attributes also for function parametersChristian Kandeler2020-11-121-0/+5
| | | | | | | | | | | | Fixes: QTCREATORBUG-24636 Change-Id: I9dc3d2cc6ca102b09f6b040455fa901c362dae7d Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* | CPlusPlus: Expose "static" specifier also for function declarationsChristian Kandeler2020-11-111-0/+3
| | | | | | | | | | | | | | | | | | | | To be able to do this, the parser needs to store the decl specifier list in FunctionDeclaratorAST objects, the same way it is done for FunctionDefinitionAST. Task-number: QTCREATORBUG-24894 Change-Id: I475fb08b1f14c63f3050d72dff200c1b08df5789 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* | C++: Extend alias declaration support in built-in parserChristian Kandeler2020-11-091-3/+16
|/ | | | | | | | The type-id in an alias declaration can also define a new type. Change-Id: I65dc397d2526c56334676c6ab522564f6748d594 Task-number: QTCREATORBUG-24875 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* C++: Fix variable template parsing in expressionVolodymyr Zibarov2020-06-041-6/+0
| | | | | | | | | | | Fix parser to not fail on TemplateId without parentheses, for example: int i = foo<int> + foo<char>; This fixes std::pair structure parsing in MSVC headers and find Usages to work with pair->first and pair->second. Change-Id: Ic300ea99d44a749705430d5eb47b2744715af995 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-1/+78
| | | | | | | | | | | | | | | | | | | | | | | 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-142/+142
| | | | | Change-Id: I1bed5e85a5b7948d08502a72a10f80baa075c204 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
* Standardize on int for line and column valueshjk2019-07-261-155/+155
| | | | | | | | | | | | | | | 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++: Fix parsing enum specifier IIINikolai Kosjar2018-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This amends the obviously wrong aac1bebacec384a0f8dd7053c06cb3418f88c722. Fixes FAIL! : tst_Semantic::q_enum_1() Compared values are not the same FAIL! : tst_CheckSymbols::test_checksymbols(EnumerationUse) 'resultCount > 0' returned FALSE. () FAIL! : tst_CheckSymbols::test_checksymbols(VariableHasTheSameNameAsEnumUse) Compared values are not the same FAIL! : tst_CheckSymbols::test_checksymbols(enum_inside_block_inside_function_QTCREATORBUG5456) Compared values are not the same FAIL! : tst_CheckSymbols::test_checksymbols(enum_inside_function_QTCREATORBUG5456) Compared values are not the same FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_block_inside_function) Compared lists have different sizes. FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_block_inside_function_cxx11) Compared lists have different sizes. FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_function) Compared lists have different sizes. FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_function_cxx11) Compared lists have different sizes. FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_class) Compared lists have different sizes. FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_class_cxx11) Compared lists have different sizes. FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_namespace) Compared lists have different sizes. FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_namespace_cxx11) Compared lists have different sizes. FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_member_function) Compared lists have different sizes. FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_member_function_cxx11) Compared lists have different sizes. FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_in_class_accessed_in_member_func_inline) Compared lists have different sizes. FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_in_class_accessed_in_member_func) Compared lists have different sizes. FAIL! : CppTools::Internal::CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter(CppLocatorFilter-filtered) Compared lists have different sizes. FAIL! : CppTools::Internal::CppToolsPlugin::test_cpplocatorfilters_CppCurrentDocumentFilter() Compared lists have different sizes. FAIL! : CppTools::Internal::CppToolsPlugin::test_builtinsymbolsearcher(BuiltinSymbolSearcher::AllTypes) Compared lists have different sizes. FAIL! : CppTools::Internal::CppToolsPlugin::test_builtinsymbolsearcher(BuiltinSymbolSearcher::Enums) Compared lists have different sizes. Task-number: QTCREATORBUG-21413 Change-Id: I71ace00091e37f0a148086e5047efaec08923b1a Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* C++: Fix parsing enum specifier IINikolai Kosjar2018-10-241-3/+1
| | | | | | | | | | | | This amends the obviously wrong de975aca4f08141b1c6475e58f5cfa316fdd1350, which did not honored nameless enum specifiers. This fixes e.g. "Find Usages" for declarations following "enum {};". Change-Id: Id98c074156f576b9a63e6c25dab38721ca34e496 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* C++: Fix parsing enum specifierNikolai Kosjar2018-10-111-1/+5
| | | | | | | | | | The enum name has to be an identifier. For the example in the referenced report it was a destructor, which violated invariants in the lookup code. Fixes: QTCREATORBUG-20952 Change-Id: Ib8c9c23d6e001368c11c6a4b80c4295559786823 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* TextEditor: Highlight punctuators as TextHugo Holgersson2018-05-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Utils: Purge qtcfallthrough.hOrgad Shaneh2018-04-091-2/+0
| | | | | | | No longer needed. Change-Id: I9b0bee014df89d4c567f1d2431b5ff9404f5f925 Reviewed-by: hjk <hjk@qt.io>
* Add support for nested namespaces (C++17)Colin Duquesnoy2018-02-091-2/+21
| | | | | | Task-number: QTCREATORBUG-16774 Change-Id: I3de3ac65810213e21c9a3bafef2474d252e191f7 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Introduce Q_FALLTHROUGH()Friedemann Kleint2018-01-241-4/+4
| | | | | | | Silence g++ 7.X warnings. Change-Id: I9d06d04b496c9ec060e13e1be6f43d8fbadb1f3b Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
* Add Q_FALLTHROUGH for Qt < 5.8Christian Kandeler2017-07-171-1/+3
| | | | | | | | | | | | | | ... and make use of it. With gcc 7, the new option -Wimplicit-fallthrough is introduced and added to the -Wextra set, triggering dozens of warnings in our sources. Therefore, we annotate all obviously intended fall-throughs. The ones that are still left are unclear and need to be checked by the respective maintainer. Change-Id: I44ead33cd42a4b41c28ee5fcb5a31db272710bbc Reviewed-by: Nikita Baryshnikov <nib952051@gmail.com> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Remove workarounds for unsupported compilersOrgad Shaneh2017-04-261-3/+1
| | | | | Change-Id: Ie28ff761b0bae13c6ebdf7dd649cfbba28e0fc2c Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* C++: Fix expensive parsing of declarationsNikolai Kosjar2016-04-201-18/+47
| | | | | | | | | | | | | ...which can occurr for e.g. files with a high difference of opening and closing curly braces and many structs. Make use of the ASTCache for parseSimpleDeclaration() and parseMemberSpecification(). Those two were the most recurring calls for the code provided in the bug report. Task-number: QTCREATORBUG-16049 Change-Id: I13cc7fba2fb6c3be863690a222c8bbfeacbddc05 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* C++: Fix crashes with the pattern "enum class operator A"Lassi Hämäläinen2015-11-181-0/+5
| | | | | | | | | | | | Parser parsed the pattern as an enum declaration the name of which is a conversion operator. Add check to disallow keywords after enum-key (enum, enum class, enum struct). Add tests tst_AST::enumDeclaration and invalidEnumClassDeclaration. Task-number: QTCREATORBUG-15341 Change-Id: Ia037f00184c1d7e5b0374f39331bb6748f8d90b1 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* C++: Support noexcept operatorClaus Steuer2015-10-031-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | 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++: Limit parsing of initializer clauses IINikolai Kosjar2015-07-061-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This completes commit e69d20e10bf040c78a98d42514453d990aa56217 C++: Limit parsing of initializer clauses by handling the following code path: -------- parseExpressionStatement --------- parseExpression ---------- parseCastExpression ----------- parseUnaryExpression ------------ parsePostfixExpression ------------- parseCorePostfixExpression -------------- parsePrimaryExpression --------------- parseNumericLiteral ---------- parseExpressionWithOperatorPrecedence ----------- parseInitializerClause0x ------------ parseAssignmentExpression ------------- parseCastExpression -------------- parseUnaryExpression --------------- parsePostfixExpression ---------------- parseCorePostfixExpression ----------------- parsePrimaryExpression ------------------ parseNumericLiteral ------------- parseExpressionWithOperatorPrecedence ----------- parseInitializerClause0x ------------ parseAssignmentExpression ------------- parseCastExpression -------------- parseUnaryExpression --------------- parsePostfixExpression ---------------- parseCorePostfixExpression ----------------- parsePrimaryExpression ------------------ parseNumericLiteral ------------- parseExpressionWithOperatorPrecedence ----------- parseInitializerClause0x ... Task-number: QTCREATORBUG-14645 Change-Id: I8a71fd687e15a3a4ae26e7b9830276464e3fa76e Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* C++: Use MAX_EXPRESSION_DEPTH and increase to 1000Nikolai Kosjar2015-07-061-4/+3
| | | | | | | | We do not want different depths for different ASTs. Change-Id: Idc4aff226b20dbc5c14a77ef729b16044b55b837 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* C++: Add missing DEBUG_THIS_RULE() for Parser::parse*Nikolai Kosjar2015-07-061-0/+4
| | | | | Change-Id: Ic4d3ccd72618c512567140ea5af39ca0799cde3a Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* C++: Support ellipsis on variadic inheritance parsingJohannes Lorenz2015-06-021-0/+5
| | | | | | | Change-Id: I571aefdb1f2aba88ba0c7710f16b6d8ad2e8f5a8 Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* C++: Limit parsing of initializer clausesNikolai Kosjar2015-05-131-2/+13
| | | | | | | | | ...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++: fix parsing nested C99 designated initializers.Francois Ferrand2015-02-271-1/+7
| | | | | Change-Id: Iaa0e7550abf6be77601b1852652bb3d0731d0323 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* C++: Basic support for C++11 user-defined literalsAdam Strzelecki2015-02-171-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | 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++: Cache parsing of template idsNikolai Kosjar2015-02-121-3/+8
| | | | | | | | | | | | | | | | ...in order to stop memory intensive parsing for invalid code. Parsing the test data/snippet "hard" led to a memory consumption of about 5.5MB and this could easily get up to hundreds/gigabytes by adding some more "if_<bool_<true>,\n" lines. With the caching, we are at about 1.0MB, even if more lines are added. The "memory consumption" was measured with valgrind-massif. The stated numbers are the reported peaks. Task-number: QTCREATORBUG-12890 Change-Id: Ie7eb00cfc7915552d29bb27410a6b13a486f486e Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* C++: Remove workaround for crashing if parsing invalid codeNikolai Kosjar2015-02-121-30/+3
| | | | | | | | | | | | | | | | | | 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-5/+4
| | | | | | | | | | | | | | | 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-2/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 parsing of "Foo *foo = new Foo()"Nikolai Kosjar2014-10-151-27/+42
| | | | | | | | | | | | | | | | | | | It should be parsed as an DeclarationStatement, but instead it was parsed as an ExpressionStatement. Regression introduced with commit d3c5fff66de034e46e825b63943909d36067405f. C++: Fix expensive parsing of expressions The introduced ASTCache did not save the correct return value of a parse* function. Because of that, the first return in Parser::parseExpressionList returned false on the second invocation (cache hit), instead of true, which resulted in an ExpressionStatement. Task-number: QTCREATORBUG-13122 Change-Id: I8dbd8852b0909edddcd3195b484f4cea92328cc5 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
* C++: remove dead store.Erik Verbruggen2014-09-121-1/+0
| | | | | | | Pointed out by the clang static analyzer. Change-Id: I2d73d4c9ef2511c5697a4e4da89b61efb1149a3f Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
* Merge remote-tracking branch 'origin/3.2'Oswald Buddenhagen2014-08-051-57/+192
|\ | | | | | | | | | | | | | | | | Conflicts: qtcreator.pri qtcreator.qbs src/plugins/android/androidglobal.h Change-Id: I3367bf2ea47c088989175dddeed2210294346f4c
| * C++: Fix expensive parsing of expressionsNikolai Kosjar2014-07-241-8/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>