Commit Graph

1327 Commits

Author SHA1 Message Date
Jarek Kobus
a0079b171f Make canceling of Type Hierarchy evaluation more responsive
On the beginning of the process of evaluating type hierarchy
the evaluating thread may freeze on a first call to
Snapshot::updateDependencyTable() for quite a long time
(e.g. when showing the type hierarchy for IPlugin class
inside Creator project - it may freeze up to about 3 seconds).
So, when we want to cancel the evaluation (e.g. when
we switch from "Type Hierarchy" into another view or when
closing Creator) we may freeze for this period. In order to
fix it we pass a future interface as an additional argument
for Snapshot::updateDependencyTable() and cancel the update
when cancellation of task was requested.

Change-Id: I2147f10a68989587476c30369ec2ac552a57d5ae
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-12-07 16:24:57 +00:00
Eike Ziller
1e78fdb71f Merge remote-tracking branch 'origin/4.14'
Change-Id: Id4c4c06b086dfe38960f4d68694ae23f3e00109f
2020-12-03 11:57:42 +01:00
Christian Kandeler
ff2322ac0b CPlusPlus: Fix mis-classification of pure virtuals
Syntactically, they do have an initializer, but they are not
initializations.

Change-Id: I0556b279ce2d173868585cbce085b803c1cff285
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-12-03 09:09:52 +00:00
Christian Kandeler
d3fafcde0f CppEditor: Support decl/def switch for conversion operators
Fixes: QTCREATORBUG-21168
Change-Id: I515fe146a679e007c96fa8d23f1457dadf07db3c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-23 10:07:20 +00:00
Eike Ziller
8d67dd57e8 Merge remote-tracking branch 'origin/4.14'
Change-Id: I5e138bb7883c0436fee14ca6af20e99396676af1
2020-11-20 13:00:37 +01:00
Leander Schulten
993b614d94 CppEditor: Remove using namespace quickfix: Don't insert inline namespaces
Change-Id: If386d31de723ca928d3c50f55e32205c50937b0a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-11-19 18:35:05 +00:00
Alessandro Portale
b2a766a79a Don't access static functions/fields via instance
Courtesy of readability-static-accessed-through-instance

Change-Id: I71f54244f1e091315dac2943d9e1bfad6efa56a9
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-11-19 08:42:14 +00:00
Alessandro Portale
30aec82285 Add missing "final" to unexported/unshared classes
Change-Id: I84d5fc39d7ef5588a20545854d0cfd0b993db090
Reviewed-by: hjk <hjk@qt.io>
2020-11-18 15:40:29 +00:00
Eike Ziller
1d2b5db02f Merge remote-tracking branch 'origin/4.14'
Change-Id: I2ae0eb18782224e48cd20d41907f9dfea6ee1771
2020-11-10 13:42:46 +01:00
Christian Kandeler
e41f3eb607 CPlusPlus: Fix "find usages" categorization for sizeof and array access
Task-number: QTCREATORBUG-24894
Change-Id: I65fa097785b19e181f15178ad6d30608899316c0
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2020-11-09 12:50:07 +00:00
Christian Kandeler
1988d89198 CPlusPlus: Check for static member functions in FindUsages
Static member functions cannot modify the object and therefore must not
be reported as writable references.
Note that this does not have an effect yet, as the function type lacks
information about the "static" specifier.

Task-number: QTCREATORBUG-24894
Change-Id: Ib04a17864a0ca5b7610579a2f5efbcfde257e08a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-09 09:51:08 +00:00
Christian Kandeler
4ad078b73a CplusPlus: Try harder to find a class
... when looking up a member function for categorization.
Contrary to our expectation, the first entry in the lookup results is not
necessarily the best fit.

Task-number: QTCREATORBUG-24894
Change-Id: I1ba6dbebeecd8c4a24fa53194996271339018d9c
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2020-11-06 13:45:38 +00:00
Christian Kandeler
de1e12f3af CPlusPlus: Correctly categorize post-increment and -decrement accesses
Change-Id: Id21c13ea58f6747c226d91aff2b00c3409faa880
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2020-11-04 13:24:33 +00:00
Christian Kandeler
a88266798f CPlusPlus: Differentiate declarations with an initializer
... from those without one, and display the former like write accesses.

Task-number: QTCREATORBUG-24894
Change-Id: I5e2d83b2a3ec4735054441c346687f97eeb039fb
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2020-11-04 13:02:52 +00:00
Christian Kandeler
cf6757406d CPlusPlus: Properly categorize usages in if statements
Change-Id: I5f6e5fa14ea51cd9e61a9e2e96c110ca618be429
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2020-11-04 13:02:34 +00:00
Christian Kandeler
89644e4a06 CPlusPlus: Properly categorize usages in switch and case statements
Change-Id: Iafbbdcca23db38d82bbc5bb24a39dac2a6d0a764
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-02 16:03:28 +00:00
Eike Ziller
724fd58a3b Merge remote-tracking branch 'origin/4.14' into master
Conflicts:
	src/plugins/cppeditor/cppquickfix_test.cpp

Change-Id: I470ee35f54f883244d819531131c172bd25c0e3f
2020-10-29 09:18:31 +01:00
Christian Kandeler
d2ebc16b92 CppEditor: Fix "move definition" quickfix for template member functions
There are a lot more problems in this area (e.g. with nested classes),
but let's tackle them one by one.

Fixes: QTCREATORBUG-24801
Change-Id: I4b3805ea6f8b28373925693650150bbd89508096
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-28 12:41:26 +00:00
Eike Ziller
9c6108afd1 Merge remote-tracking branch 'origin/4.14' into master
Change-Id: Ib4363db8e71488e1d13e8c1012023abfaf06286b
2020-10-22 14:38:01 +02:00
Christian Kandeler
b58ca33ff6 CppTools: Categorize the delete operator as a write access
... in the "Find Usages" results.

Change-Id: Ib399bf762c717b7d4439be26b9180574aefce7e3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-21 09:12:33 +00:00
Leander Schulten
5b5ae97104 CppEditor: Introduce QuickFix settings and unify getter/setter generation
Introduces a QuickFix settings page where the generation of getters and
setters can be customized. The settings can be saved into a file that can
go into a VCS. All QuickFixes that generate getter/setter/signals/
Q_PROPERTIES now use the same backend. QuickFixes that generate getters/
setters are now extended to also generate signals and Q_PROPERTIES.

Fixes: QTCREATORBUG-1532
Fixes: QTCREATORBUG-17941
Fixes: QTCREATORBUG-12678
Fixes: QTCREATORBUG-15779
Fixes: QTCREATORBUG-11620
Fixes: QTCREATORBUG-22707
Fixes: QTCREATORBUG-20157
Fixes: QTCREATORBUG-21804
Fixes: QTCREATORBUG-19814
Fixes: QTCREATORBUG-14622
Fixes: QTCREATORBUG-19803
Change-Id: I50ed2dad9b4a637fbd87b3e1f2856060ad0ad920
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-10-14 10:12:44 +00:00
Eike Ziller
9828e6887e Merge remote-tracking branch 'origin/4.14' into master
Change-Id: Ie53b4c2516d80a653d51bc6b666040c586ce44ab
2020-10-08 12:04:06 +02:00
Alessandro Portale
c68f49fefa Remove unused private functions
As found by Cppcheck.

Change-Id: I697ea69992425ff41e35990ad00be312b35ba70a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-10-08 09:06:02 +00:00
Eike Ziller
7c93f25ae9 CMake build: Fix issues with exported targets
Remove unneeded and wrong include paths which ended up as invalid
include paths in the exported QtCreatorTargets.cmake.

Add missing sqlite header.

Change-Id: Icce60037160ff06b032a03df47e6834422f86f57
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-06 11:08:59 +00:00
hjk
2da4d9ae1f CPlusPlus: Fix crash in FindUsages
Amends 45dd074441.

Change-Id: I6d32bfe4798eca4fa5cb7786cd72e4f9e109a1b7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-01 05:55:03 +00:00
Alessandro Portale
dc1439dedd CMake build system: Propagate less target dependencies and includes
...and thereby have less include paths per compile unit.

Change-Id: I70de8db12d881ea827595ca0cacaea13b5c0f3bd
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-09-21 10:53:12 +00:00
Christian Kandeler
f244a7ea4c CPlusPlus: Consider member initializations
... when checking usage types.

Change-Id: Ic875f3bcae9cf045dbb062670e8cf941de533404
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-09-18 11:01:47 +00:00
Christian Stenger
7a84381a27 CPlusPlus: Fix possible crash
Text may contain special utf characters which in turn lets
the range of the token become different if handled as normal
byte. This would end up in an assert if the QStringView tries
to access a position after the last character of the text.
Amends 242579099a.

Change-Id: Ie52c15e8729f25da850b539a6a55cca134026c3d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-09-16 10:01:19 +00:00
Eike Ziller
242579099a CppTools: Fix QStringRef and QSharedPointer related issues with Qt6
Task-number: QTCREATORBUG-24098
Change-Id: I97347ac3fb397fea8eee655e3cc4ee252c511885
Reviewed-by: hjk <hjk@qt.io>
2020-09-15 13:57:32 +00:00
Christian Kandeler
ee8e102cbc CPlusPlus: Look at all overloads
... when trying to find out the usage type of a function argument.
Otherwise, we potentially ignore functions which have additional
overloads with a shorter parameter list than is required for the call.

Change-Id: I02bf2cb359ea9d506e2644388234dc28fa072445
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-09-15 09:23:48 +00:00
Christian Kandeler
45dd074441 CPlusPlus: Categorize "Find Usages" results
That is, find out whether a certain access was a read, a write, a
declaration or something else, and report the result to upper layers.
Follow-up patches can make this information visible to users.

Task-number: QTCREATORBUG-12734
Task-number: QTCREATORBUG-19373
Change-Id: Iee79e39dd1eb5a986a7e27846991e0e01b2c3a2f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-09-03 14:32:47 +00:00
Christian Kandeler
f1062f1366 CPlusPlus: Dissolve some overloads of FindUsages::reportResult()
These overloads did not add any value, but were just confusing.

Change-Id: Icf3f69a30e2fccc4a4695e79bcf32457b2fb481b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-08-31 09:17:53 +00:00
The Qt Project
0e8f62d5f8 Merge "Merge remote-tracking branch 'origin/4.13' into master" 2020-08-10 13:59:18 +00:00
Christian Kandeler
7cd9699766 CppEditor: Fix following signals/slots in old-style connects
... if the first argument is a call to a function returning a pointer to
QObject.

Fixes: QTCREATORBUG-13265
Change-Id: I12c2d07331a0c6dca56ad55c518240fd74be3dca
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-08-10 12:30:28 +00:00
Christian Kandeler
df0ffd8bb8 CPlusPlus: Fix handling incomplete macro invocations
It looks very much as though the original author simply forgot to add
that return statement.

Fixes: QTCREATORBUG-23881
Change-Id: Ie93d2451bf1b491d01137285f983d657133c81c3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-17 14:40:08 +00:00
Christian Kandeler
538b097756 Lexer: Fine-tune recent crash fix
Use the original offset only in the one place where it is relevant.
This amends commit 8eac3fba80.

Fixes: QTCREATORBUG-24221
Change-Id: Idcfc5ecc8a76c875c4f2ca5890d0ba95ce52a6e9
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2020-06-24 08:42:39 +00:00
Volodymyr Zibarov
40173ad4ab C++: Fix auto variable resolving for template class constructor call
Code snippet:
template<class T> struct MyStruct { int value; };
int main() {
    auto s = MyStruct<int>();
    s.value;  // "value" is not found
}

This fixes find usages for unique_ptr declared as auto like this:
auto ptr = std::unique_ptr<MyStruct>(new MyStruct());
ptr->value;

Also fixes in-place constructors:
std::unique_ptr<MyStruct>(new MyStruct())->value;

Fixes: QTCREATORBUG-15364
Change-Id: I8d452a77fe85e63665ec8d4c4afbcf8aad063121
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-06-22 14:27:49 +00:00
Christian Kandeler
8eac3fba80 CPlusPlus: Fix lexer crash
At some point in the preprocessing stage, some tokens get "squeezed", so
their associated string no longer refers to the document content, but
only to their own symbol. However, there is at least one context that
operated under the assumption that the token's offset still pointed into
the "global" string. As the token's offset is zero after parsing, this
lead to the same piece of code being preprocessed in an infinite loop.

Fixes: QTCREATORBUG-19525
Change-Id: I231ba51811cfa0b5c6dfe7f75fe0384472252c6f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-18 07:52:02 +00:00
Volodymyr Zibarov
9be4a5f839 C++: Fix Find Usages false positive results for function arguments
Code snippet:
void bar();         // call find usages for bar from here
void foo(int bar);  // bar from here should not be in results

Add test for member function false positives, that is part of
QTCREATORBUG-2176. That was already fixed before.

Fixes: QTCREATORBUG-2176
Change-Id: I9a079caa83bbaea1edb7ba6aeb151d4d4c77952f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-06-15 13:19:51 +00:00
Christian Kandeler
a9c497e9a4 CPlusPlus: Fix overload resolution involving default arguments
If one of the overloads had additional default arguments, then for each
of these, its priority was increased, which does not appear to make any
sense.

Fixes: QTCREATORBUG-17807
Change-Id: Id5be81ce52c615a424fe4314d2e50385b3fb2b1c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-10 10:36:10 +00:00
Christian Kandeler
0d60ee3906 Fix clang warnings about unwanted copies in range loops
Change-Id: I11ae3317fd251a463809ee48917d2daf0f8b43d1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-04 07:16:57 +00:00
Volodymyr Zibarov
586ce5b472 C++: Print numeric template arguments in NamePrettyPrinter
Improve type printed for template specializations with numeric
or bool values.

Code example:
template<bool B, class T> struct enable_if{};
template<class T> struct enable_if<true, T>{ typedef T type; };

In outline: "enable_if<_Tp1, T> <T>" becomes "enable_if<true, T> <T>"

TemplateArgument class holds pointer to numeric literal owned
by CppDocument, so remove Control::squeeze() to not release
numericLiterals in CppDocument::releaseSourceAndAST()

This based on TemplateArgument class introduced in commit
9ee693ee22

Change-Id: Ib787a5e402c3e8d8467b520347a26afa6087d4bd
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-06-03 12:11:15 +00:00
Volodymyr Zibarov
9ee693ee22 C++: fix built-in code model to work with shared_ptr on MSVC 2017
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>
2020-05-29 12:39:28 +00:00
Eike Ziller
42f02fae03 Merge remote-tracking branch 'origin/4.11'
Change-Id: Ie1c4de44aa1af20dfb67e20607b9fb4e71445cbe
2020-02-12 08:04:14 +01:00
Leena Miettinen
770b2f1bc6 Doc: Fix PreprosessorClient docs
Fix values of \fn commands and document attributes.

Change-Id: Id09eb30e861289e9d982d7e0f914c68114ecf50c
Reviewed-by: hjk <hjk@qt.io>
2020-02-10 12:34:18 +00:00
Igor Sidorov
3449618a85 Change recursive to loop in allIncludesForDocument
Change-Id: I110294efa506b5a038cfc7f4202fab001e3eefd3
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-02-05 09:34:07 +00:00
Alessandro Portale
24a25eed14 Use isEmpty() instead of count() or size()
Change-Id: I0a89d2808c6d041da0dc41ea5aea58e6e8759bb4
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2020-01-20 20:56:57 +00:00
hjk
e109b731ad Utils: Rename FilePathList to simply FilePaths
The exact storage type does not really matter here.

Change-Id: Iefec40f0f5909c8e7ba3415db4a11962694e1b38
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-12-18 08:43:18 +00:00
hjk
cc85cdf8d1 CPlusPlus: Use a namespace instead a dummy class for functions
Change-Id: Iaa364ef5fcd6f635fa07f0c43719b7b8feb1a428
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-11-18 13:07:58 +00:00
Nikolai Kosjar
54fefd89b8 C++: Transfer noexcept specifier for refactoring actions
This applies for e.g.

* "Add Definition..." (on function decl)
* "Move Definition..." (on function decl)
* "Insert Virtual Functions of Base Class" (on class specifier)

Fixes: QTCREATORBUG-11849
Fixes: QTCREATORBUG-19699
Change-Id: I0d259bc1782470f3b3f19617230005a5594a5cca
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-10-08 09:20:10 +00:00