Fix for auto completion in case of auto declaration inside if condition:
struct Foo { int bar; };
void func()
{
if (auto s = new Foo)
s->; // auto completion does not work
}
Task-number: QTCREATORBUG-13805
Change-Id: Ia1776e8cc04e6040a6bf5f43cf82cfd6ce6dde7a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Trust the matcher to do the job.
Task-number: QTCREATORBUG-13564
Change-Id: I4ff14608a1ce12d3f4424242e50ba71233ac9bfd
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Inserting to a std::vector (possibly) invalidates all iterators and
references for it.
In this piece of code tok is a reference to a member in _tokens and it
should not be used after an insertion is made to _tokens. Switched the
order of two code lines to prevent this.
Change-Id: Ia9d1ce66fc67406f56b426e7431402c6fe68a38f
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Separate the messy pp-number parsing from the numeric literal parsing.
The C/C++ preprocessor makes a grown man cry, but at least we have
"proper" literal parsing when we want it, including C++1y binary
literals.
Next step is digit separators (n3781).
Change-Id: Ia069eef454ed5c056f77694a5b8a595d0b76adc4
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
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>
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:Ⓜ️:if_< b:Ⓜ️:bool_<
(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b:Ⓜ️:int_<70> *) 0)) ==
sizeof(defined_)) >, b:Ⓜ️:if_< b:Ⓜ️:bool_<
(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b:Ⓜ️:int_<71> *) 0)) ==
sizeof(defined_)) >, b:Ⓜ️:if_< b:Ⓜ️:bool_<
(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b:Ⓜ️:int_<72> *) 0)) ==
sizeof(defined_)) >, b:Ⓜ️:if_< b:Ⓜ️:bool_<
(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b:Ⓜ️:int_<73> *) 0)) ==
sizeof(defined_)) >, b:Ⓜ️:if_< b:Ⓜ️:bool_<
(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b:Ⓜ️:int_<74> *) 0)) ==
sizeof(defined_)) >, b:Ⓜ️:if_< b:Ⓜ️:bool_<
(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b:Ⓜ️:int_<75> *) 0)) ==
sizeof(defined_)) >, b:Ⓜ️:if_< b:Ⓜ️: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>
Basically all that generate at most 7 bytes. With the call being 5
and some hope of intra-caller optimization gains that shouldn't explode.
Change-Id: I4145d69d38a7956362263e9d432eb47bb58d3261
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
It should be parsed as an DeclarationStatement, but instead it was
parsed as an ExpressionStatement.
Regression introduced with
commit d3c5fff66d.
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>
See [global.names] (17.6.4.3.2 in the C++11 spec.)
Change-Id: If6905bbac3a7464aeb5a49227e0f6b5c91d6033b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
See [global.names] (17.6.4.3.2 in the C++11 spec.)
Change-Id: I8434496dbe392b52d339d5f17cfaeee8dbd88995
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
And not have it converted to int after converting to unsigned.
Change-Id: If95caec46936c2a140c3fbd668fa2f085a9287ed
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
The variable is checked for 0 elsewhere in this method, so it probably
makes sense to check it here as well.
Change-Id: Idb869dda54ed340e1b2f03c7d4c06f2a93c00887
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
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>
@classes, @protocols, @properties and -methods (and +methods) will now
show up in the locator.
Change-Id: I33f904c456c321fc80b8aba7ff52d5f1207c58be
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
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>
Relying on "_type" for the lambda was wrong.
In case of the bug report the return type of the lambda happened to be
the template class. Because of that Clone never stopped cloning.
Change-Id: I377d12e6a8278198abd1488fbdbc89b4157c1357
Task-number: QTCREATORBUG-12631
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
In TranslationUnit, the "normal" lines are based on utf16char offsets,
but the preprocessor lines were based on byte/latin1 offsets.
The preprocessor lines are now based on utf16char offsets, too.
Task-number: QTCREATORBUG-7356
Change-Id: I3c41d1dcee8e9e487210f36da806b0229d3f4cd0
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
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>
The introduction of C99 designators led to parsing problems with lambdas
that were passed in as a function arguments.
Fixed by prefering to parse without designators first. This will be
cleaner/clearer once the appropriate "LanguageFeatures" from the Project
Parts will be passed in.
Change-Id: Ia9cb7c4a4c9345e729cf2044e1e5411fe63e33ec
Reviewed-by: Wang Hoi <wanghoi@126.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
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>
The tool 'cplusplus-update-frontend' can't handle that and thus will
rewrite that class without this initialization.
The member is properly initialized at use.
Change-Id: I2c8c57be47b5fe953c2518254656e5e38ba90f08
Reviewed-by: Wang Hoi <wanghoi@126.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
The parser considers '{' an operator and thus thought
"template-id {" couldn't possibly be valid. This patch adds
'{' as an exception to the rule.
Change-Id: I40730fcdc5cade48566b4c8b6fde390f455bbdba
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>