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>
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>
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>
Based on Tobias Hunger's work from a few months ago.
The CMake configuration needs libclang and Qt paths specified as
CMAKE_PREFIX_PATH.
Auto tests are run with "ctest". At the moment the pass rate is 87%.
Change-Id: Iba98e39bf22077d52706dce6c85986be67a6eab0
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This amends the obviously wrong
de975aca4f, 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>
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>
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>
...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>
This reverts the changes
commit beac7b9539
C++: Fix highlighting after "invalid code"
commit 78ab287fc6
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>
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>
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>
And not have it converted to int after converting to unsigned.
Change-Id: If95caec46936c2a140c3fbd668fa2f085a9287ed
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>
Until now std::vector::at() was used to access the elements. This is
handy for debugging since an exception is thrown for invalid indices,
but it does not stop Qt Creator from crashing because exceptions are not
caught.
This is especially a problem for the parser, which has to look ahead via
LA(n), which accesses TranslationUnit::_tokens.
With this patch, explicit bounds checking is done before accessing the
elements and thus calls to
std::vector::at() // bounds checking, throwing out_of_range
were replaced by calls to
std::vector::operator[]() // no bounds checking, not throwing out_of_range
Measuring the parse time for the Qt Creator project shows that there is
no slowdown. In both cases, with and without the patch, about 15s are
needed on the authors machine.
Task-number: QTCREATORBUG-10453
Change-Id: I32b12a526ff7199bcadfc21a3deb5354063a3e3b
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
MEMBER was added in Qt5.
Task-number: QTCREATORBUG-10068
Change-Id: Ic6c15a0e5ee8981ab98e4c12fc1521dc281b731f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Note: Since not all autotests are able to run from an installed location,
we need to be able to start them from the build directory, which
in turn forces us to set a destination directory for libraries and plugins,
so they will be found at run-time.
Change-Id: Idcf7e1333dfa6e9dbf745391b78c035f842ccc5a
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
...otherwise they add up and subsequent tests checking for the error count will
fail:
FAIL! : tst_AST::objc_try_statement_1() Compared values are not the same
Actual (diag.errorCount): 5
Expected (0): 0
Loc: [/home/nikolai/dev/creator/qtcreator-master/tests/auto/cplusplus/ast/tst_ast.cpp(1400)]
...
Change-Id: I8b4356331e95dceb1e99bb26e6ebf4591d70a08c
Reviewed-by: David Schulz <david.schulz@digia.com>
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>
This test is marked as failing, because the bug is still there. To be
fixed when we re-use the generated token stream of the preprocessor as
input for the parser.
Task-number: QTCREATORBUG-9799
Change-Id: I454a9939aa188a6ff934a11699232f39c828bc7b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
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>
... and adjust INCLUDEPATH accordingly.
while i'm at messing with include statements, also re-order the include
blocks according to policy and sort them within bigger blocks.
Change-Id: I7762abfd7c4ecf59432b99db2f424e4fa25733a5
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
When a constructor is defined with a single, unnamed argument of a custom type without
extra type specifiers (const...), then the constructor was not identified as such.
There was an heuristic in case the constructor was in the class definition, but not if the
the constructor was defined later.
Examples:
class Arg;
class Other;
class Foo {
Foo(Arg /*arg*/); // working
Foo(const Arg /*arg*/); // working
Foo(int /*arg*/); // working
Foo(Other /*arg*/) {} // working
};
Foo::Foo(Arg /*arg*/) {} // used not to work, fixed
Foo::Foo(Arg arg){} // working
Foo::Foo(const Arg /*arg*/) {} // working
Foo::Foo(int arg) {} // working
Change-Id: I741e4ba62672ddc99a837fdcdc27996fba5ae6c7
Reviewed-by: hjk <qthjk@ovi.com>