diff options
author | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2014-11-18 11:58:37 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2014-11-18 13:46:34 +0100 |
commit | 78ab287fc6d3770646012e461b0a518db4e9c9f4 (patch) | |
tree | 530e3492ed4b7aaff18cf20ac25010872639fa0d /src/libs/3rdparty/cplusplus/Parser.h | |
parent | 657797f7a06de9c5297952896421fc94a360b848 (diff) |
C++: Stop parsing a declaration after two tries
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>
Diffstat (limited to 'src/libs/3rdparty/cplusplus/Parser.h')
-rw-r--r-- | src/libs/3rdparty/cplusplus/Parser.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/libs/3rdparty/cplusplus/Parser.h b/src/libs/3rdparty/cplusplus/Parser.h index 4a2a6dfb7e..923b0c4dc8 100644 --- a/src/libs/3rdparty/cplusplus/Parser.h +++ b/src/libs/3rdparty/cplusplus/Parser.h @@ -254,6 +254,7 @@ public: bool parseDesignator(DesignatorAST *&node); bool skipUntil(int token); + void skipUntilAfterSemicolonOrRightBrace(); void skipUntilDeclaration(); bool skipUntilStatement(); bool skip(int l, int r); |