Commit Graph

87 Commits

Author SHA1 Message Date
Alessandro Portale
f96feadad0 Fix missing overrides and redundant virtual
Change-Id: Id2a247b6032602c2295d928067c2462d3f9b5221
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-11-14 14:27:45 +00:00
Kai Köhne
56baf8c058 Remove GPL-3.0+ from license identifiers
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...

While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only

Change was done by running

  find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;

Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 11:15:13 +00:00
Jarek Kobus
d2408fd389 Tests: Replace foreach with range-based for loops
Change-Id: If813702db78f05701f0ef9378843a474da0aae6a
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-11-24 16:03:04 +00:00
Christian Kandeler
bfecefabc0 CppEditor: Let users check for unused functions in (sub-)projects
Note that especially in C++, there can be a lot of false positives,
especially in template-heavy code bases. We filter out the most notorious
offenders, namely:
    - templates themselves
    - constructors and destructors
    - *begin() and *end()
    - qHash()
    - main()
Since the code model does not know about symbol visibility, the
functionality is quite useless for libraries, unless you want to check
your test coverage.
The procedure is rather slow, but that shouldn't matter so much, as it's
something you'll only run "once in a while".

Fixes: QTCREATORBUG-6772
Change-Id: If00a537b760a9b0babdda6c848133715c3240155
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-11-24 09:27:03 +00:00
Christian Kandeler
953000b981 CPlusPlus: Add new usage tag "Template"
For use in follow-up patch.

Change-Id: I49c057280be9b09862a89fa385a7396f1b1093bb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-11-17 15:02:09 +00:00
Christian Kandeler
3e3569f6dc CPlusPlus: Add more usage tags
To be used in subsequent patches.

Change-Id: Id7140aa39bb2adba343cc12b0273c90f3c12abeb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-11-07 13:24:58 +00:00
Christian Kandeler
d891e18edc CPlusPlus: Make Usage::Type QFlags-based
We want to extend the enum with more non-exclusive values.

Change-Id: I4d8ebe1f7327139c7817b9f621b4b74a883c5e09
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-11-07 11:33:33 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
Christian Kandeler
ca00b874a7 CPlusPlus: Support structured bindings
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>
2022-08-23 13:52:11 +00:00
hjk
e2bb204d4d CPlusPlus: Inline more simple Type related functions
Change-Id: I2103e8047b385b438e58072e8a2689f1889d2724
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-28 11:02:22 +00:00
Eike Ziller
9d8a419d10 Remove qmake build files
Removes qmake as a build system for building Qt Creator itself.
Keep them for some tests that are not completely moved to CMake yet.

Change-Id: I846c6ef65626b6dfae6375fdc85d00677aa8c2fb
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-01-20 12:18:15 +00:00
Christian Kandeler
f6c974fc1b CPlusPlus: Fix "Find references"
... for certain types of template/namespace combinations.
This essentially reverts 2798c11d1d.

Fixes: QTCREATORBUG-26520
Change-Id: I1ab0e4e19bd09695d1536bf6f10960107e9ecbc4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-11-09 08:51:31 +00:00
Christian Kandeler
284817fae6 Merge CppTools into CppEditor
There was no proper separation of responsibilities between these
plugins. In particular, CppTools had lots of editor-related
functionality, so it's not clear why it was separated out in the first
place.
In fact, for a lot of code, it seemed quite arbitrary where it was put
(just one example: switchHeaderSource() was in CppTools, wheras
switchDeclarationDefinition() was in CppEditor).
Merging the plugins will enable us to get rid of various convoluted
pseudo-abstractions that were only introduced to keep up the artificial
separation.

Change-Id: Iafc3bce625b4794f6d4aa03df6cddc7f2d26716a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-01 14:53:58 +00:00
Christian Kandeler
a5ba33cbeb CppEditor: Add second "Find References" Action
This one includes access type categorization, while the "normal" one
does not.
We need this now, because with clangd, the categorization is too slow to
enable it by default.

Change-Id: I2eb4608630d34452ae28f0836befd5d9053f42bf
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-07 08:28:49 +00:00
Christian Kandeler
a995a4633f CPlusPlus: Do not mis-classify bitfield declarations as initializations
Fixes: QTCREATORBUG-25390
Change-Id: I1976b7db2996f5a09db73adbd127aac9ab92d57d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-02-25 15:55:54 +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
59f8bd4702 CPlusPlus: Expose "static" specifier also for function declarations
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>
2020-11-11 15:41:27 +00: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
42d34015e2 CPlusPlus: Provide information about the "static" specifier
... to the function type.
This fixes the issue for function *definitions*. For function
*declarations*, we need to amend the parser.

Task-number: QTCREATORBUG-24894
Change-Id: I02043d8b974c2c64dcd739c7e05ce44fd277b5d3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-09 10:55:38 +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
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
d54f7b0eb2 Fix building tests with Qt6
Task-number: QTCREATORBUG-24098
Change-Id: I192245125f04f8350597bbe481d80d3f8ba0cae0
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-10-30 15:15:25 +00: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
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 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
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
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
Volodymyr Zibarov
7d82741602 C++: Fix find usage to see Catch test functions bodies
Catch test functions defined with function-like macros.
To speed-up semantic analysis, find usages does not expand function-like
macros.
Semantic fails with "expected a function declarator" on such functions
and skips function body.
To avoid that, we create dummy function type specifically for this case

Change-Id: Ie2f2464ee57aa4dc86eed07b8b699458f95c0266
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-06-15 10:16:06 +00:00
Volodymyr Zibarov
3ad203b56e C++: Fix variable template parsing in expression
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>
2020-06-04 08:18:40 +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
hjk
7ab6783e24 Standardize on int for line and column values
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>
2019-07-26 09:23:48 +00:00
Cristian Adam
d855b84c5d Qt Creator CMake port
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>
2019-05-17 13:33:28 +00:00
Tobias Hunger
954569387c Update License according to agreement with Free Qt Foundation
* Update license information in tests directory

Change-Id: I311441dd37d053ca3175e44b284258e232ee93e0
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-01-19 16:01:06 +00:00
kai666_73
b30b69bbf3 C++: Find template member access in find usages
Example:
struct Foo {};
struct Bar {
  template <typename T>
  T *templateFunc() { return 0; }
};
struct Test {
  Bar member;
  void testFunc();
};
void Test::testFunc() {
  member.templateFunc<Foo>();   // "templateFunc" and "Foo" outside of FindUsages
}

Change-Id: I0c5109d00c67054fe15b3fb98cf8cbca69123d8b
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2015-04-22 13:17:15 +00:00
Eike Ziller
3c85058694 Update License
Change-Id: I711d5fb475ef814a1dc9d2822740e827f3f67125
Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
2015-01-16 12:37:56 +01:00
Eike Ziller
8295b503be License update
Change-Id: I3c22ef2685d7aa589f5d0ab74d693653a4c32082
Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
2014-10-09 11:41:44 +02:00
Erik Verbruggen
45b1169d06 C++: Support alignas in C++11 mode.
Change-Id: Ifa81a481bf92b5b71495a105ae292f3e9895f704
Task-number: QTCREATORBUG-9279
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-07-22 16:43:51 +02:00
Nikolai Kosjar
655470cc0c C++: Tests: Fix unicode tests with MSVC
Change-Id: I5575826558bf60982ecc964e4dd85a3f4e920197
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
2014-06-05 08:14:57 +02:00
Nikolai Kosjar
bea8fc8e6a Cpp{Tools,Editor}: Expect UTF-8 encoded literals
Change-Id: I9843c4163aad3fa3f1bfa33060c76328fc2dc25a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:24:23 +02:00
Przemyslaw Gorszkowski
5416557a0b C++: fix findusage for member of typedefed anonymous struct
Task-number: QTCREATORBUG-11859
Task-number: QTCREATORBUG-11860
Change-Id: I7484b3b88daefbb3c76bb86a9b573e8291072872
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-03-31 18:16:52 +02:00
Robert Loehning
746c5d8863 Incremented year in copyright info
Change-Id: Ib5423fdd064e4546f848c0b640b0ed0514c26d3a
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
2014-01-08 08:29:47 +01:00
Christian Kandeler
698144e32e Add qbs project files for autotests.
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>
2013-09-09 12:16:09 +02:00
Przemyslaw Gorszkowski
3256b7b2ef C++: fix matching type with using from other namespace
example code:
struct S { int s; };

namespace std
{
    template <typename T>
    struct shared_ptr
    {
        T* operator->();
    };
}

namespace NS
{
    using std::shared_ptr;
}

int main()
{
    NS::shared_ptr<S> p;// for this shared_ptr
    return 0;
}

Fixes:
* find usages
* follow symbol
* highlighting
* marking

Task-number: QTCREATORBUG-7978
Change-Id: I28994c960b87ddd400e1d7b860fca6c6683bbb5a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-08-20 14:13:19 +02:00
Erik Verbruggen
fa1647d880 C++: add utility method to dump usages.
Change-Id: Icff6e9310a45e66b573fb2a6623a10e025c43539
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-07-11 14:09:03 +02:00
Erik Verbruggen
3563b4167f C++: Fix test failure after merging 2.8.
Change-Id: Iac4156b872fe81c1714857c24363bf171e7d61cd
Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-07-11 13:58:16 +02:00