Commit Graph

626 Commits

Author SHA1 Message Date
Christian Kandeler
33531b130b CppEditor: Fix leaks
Change-Id: Ica249743391739b3cc75023dc4c1ad72ab73bd45
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2024-11-06 08:41:07 +00:00
Christian Kandeler
80fdc9eb93 CPlusPlus: Fix pragma parsing
Trailing comments were not handled properly.
Amends ccae4fc93c.

Fixes: QTCREATORBUG-31611
Change-Id: I9ec57e4b90faa6a5097f1bfdcaff20531b3dc589
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2024-09-25 11:40:03 +00:00
Eike Ziller
281f9c28d6 Merge remote-tracking branch 'origin/14.0'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs

Change-Id: I00c2cdccf7f2fa9203d1018e90511133b2e08310
2024-08-09 15:11:49 +02:00
Christian Kandeler
9a8cba372b CPlusPlus: Allow empty initializer lists in placement new
Fixes: QTCREATORBUG-30798
Change-Id: Ib9945e4e721aca5f88665bd8a289ae3c54c69e65
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2024-08-08 13:17:34 +00:00
Christian Kandeler
dceabc0e0a CPlusPlus: Allow empty argument list in member initialization
Fixes: QTCREATORBUG-30797
Change-Id: I6de0f05e071a5e73317d7a8e3d035e23e23a41aa
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2024-08-07 14:24:28 +00:00
Christian Kandeler
9926de01c1 CPlusPlus: Add parser support for declarations of user-defined literals
... without a space before the identifier.

Change-Id: I977ffae82eb86f5ae6ea594cba17cc486e63bf6c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2024-08-07 10:55:43 +00:00
hjk
f49523029a Remove #include <utils/fileutils.h> from most header files
It has some platform specific warts, filepath.h is somewhat
cheaper and less ugly overall.

Partially clean up surroundings

Change-Id: Ida1fd470ec020f69c446109427f92a08e879789f
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2024-07-26 10:41:16 +00:00
Christian Kandeler
ccae4fc93c CppEditor: Consider #pragma once when inserting includes
Fixes: QTCREATORBUG-30808
Change-Id: Ib9f2ed1e428abfaa608b9dc42bc09dd2d403ee56
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2024-06-13 13:03:08 +00:00
Christian Kandeler
812326eadc CppEditor: Support try/catch in built-in indenter
Fixes: QTCREATORBUG-29452
Change-Id: Icf3d86a6080aeb741436800ae77af7c8bec3155c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-03-15 14:18:30 +00:00
Christian Kandeler
2524e2adb3 CppEditor: Let users provide statement macros
Like ClangFormat has.

Fixes: QTCREATORBUG-15069
Fixes: QTCREATORBUG-18789
Change-Id: I0ffb70be502d1c73aaaf436484ddc6704f152621
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-03-07 13:45:31 +00:00
Eike Ziller
a8414effd8 Merge remote-tracking branch 'origin/13.0'
Change-Id: If752e3383b35873b696e8beca27d8838a4096c8a
2024-02-27 09:04:51 +01:00
Christian Kandeler
e43fde322e CppEditor: Fix indentation of function call arguments
... following an argument with an array subscript operator.

Fixes: QTCREATORBUG-29225
Change-Id: Iba38043d94be718efee30ce50f5b55aac4ba6ecd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2024-02-26 14:53:24 +00:00
Christian Kandeler
c0bbf285a7 CppEditor: Fix indentation with inline namespaces
After encountering the namespace keyword, we have to backtrack the state
change introduced by the inline keyword.

Fixes: QTCREATORBUG-22071
Change-Id: I543976622d1a56b2c61d68da6ec3eee8b6d0d5b3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-02-23 13:46:04 +00:00
Christian Kandeler
e930b29d66 CppEditor: Do not access document manager when gathering local symbols
As it turns out, that code runs in a dedicated thread.

Task-number: QTCREATORBUG-30401
Change-Id: I66236fa00b8ddb55276d822357517fdccb0e61df
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-02-20 16:04:22 +00:00
Jarek Kobus
b6a6480084 LookupContext: Replace QSharedPointer with std::shared_ptr
According to https://wiki.qt.io/Things_To_Look_Out_For_In_Reviews
QSharedPointer impl is poor and it's going to be removed from Qt 7.

Change-Id: Ia7ec4b427c5971d6bd375659b291a9aad2ead253
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2024-02-06 11:03:16 +00:00
Jarek Kobus
f193aeed47 CPlusPlus: Replace QSharedPointer with std::shared_ptr
According to https://wiki.qt.io/Things_To_Look_Out_For_In_Reviews
QSharedPointer impl is poor and it's going to be removed from Qt 7.

Change-Id: Id3228355c2883f9229cff3f878655736cc47204a
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-02-02 15:56:25 +00:00
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
Christian Kandeler
0a058bb657 CppEditor: Consider symbol occurrences in comments
... when renaming.
For local renaming, we consider only function parameters.

Task-number: QTCREATORBUG-12051
Change-Id: I7948d69f11b97663c9bd747ae6241a82dd9bdd82
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-09-01 11:42:17 +00:00
David Schulz
5122d8addc Merge remote-tracking branch 'origin/11.0'
Change-Id: Idbf5f641aa9db7574cf2a4bd09adb8bcd03da894
2023-08-22 08:10:48 +02:00
Christian Kandeler
e9b3cd548c CPlusPlus: Fix crash on weird-looking construct
This was misparsed as a function with an initializer (e.g. "= default"),
and then the empty id caused trouble later on.

Fixes: QTCREATORBUG-29386
Change-Id: I85a35db544e11ad85f50e3a15b1a071b36e79cd0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-08-18 09:20:23 +00:00
Christian Kandeler
74a0313fcf CPlusPlus: Support associating comments with a declaration
This will serve as the basic building block for several comment-related
features.

Task-number: QTCREATORBUG-6934
Task-number: QTCREATORBUG-12051
Task-number: QTCREATORBUG-13877
Change-Id: Ic68587c0d7985dc731da9f539884590fcec764de
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-08-10 14:26:27 +00:00
Jarek Kobus
9680b8434e Tests: Simplify return statements
Change-Id: I9609609f0f880654b73e8930cd05818ddf9b7152
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-08-02 11:30:20 +00:00
Christian Kandeler
c8f29b9e01 CppEditor: Add support for init statements in if conditions
Fixes: QTCREATORBUG-29182
Change-Id: I9b7969da694b368236246123ad0028d8e754e903
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-05-25 12:37:26 +00:00
Christian Kandeler
81dcfd907b CPlusPlus: Add parser support for generic lambdas
Change-Id: Id17975a4296925c10b1b43f963412eea61ccfa5d
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-03-13 10:21:32 +00:00
Christian Kandeler
755d9769d8 CPlusPlus: Add support for coroutines
Also fix some concept-related bugs uncovered by the test case.

Change-Id: Ia67c971026bcd85d9cc252f46cd4f56c2865d432
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-03-06 13:20:04 +00:00
Christian Kandeler
47d375bbb4 CPlusPlus: Support requires clause in parser
Change-Id: Ice6a7a287453516a1cfc296e2c9f16160b3ea130
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-03-03 11:10:54 +00:00
Christian Kandeler
61de69ea90 CPlusPlus: Handle C++20 concepts in parser
Change-Id: I8c6b8b1ba3f36b83cd1d667bec9830271147b1ac
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-02-28 08:32:40 +00:00
Eike Ziller
2f5aed6c78 Merge remote-tracking branch 'origin/10.0'
Conflicts:
	src/plugins/clangcodemodel/clangdlocatorfilters.cpp

Change-Id: If91f26625ea9620fb9fdbf45705b32f37cb7f158
2023-02-10 10:43:06 +01:00
Christian Kandeler
207f2b216c CPlusPlus: Add lexer support for new C++20 keywords
Change-Id: I2b83deb0502ebf2cdca2af774fbb2ce26e947c11
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-02-09 13:19:53 +00:00
Christian Kandeler
bd2ca236e1 CPlusPlus: Check maximum include depth in lexer
We use a value of 200, which is also GCC's default.

Fixes: QTCREATORBUG-28770
Change-Id: Id02b324cd2ffa81a709441a5d93856bcd06501c3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-02-08 12:53:31 +00:00
David Schulz
4e8b7eee9d Cpp: support space ship operator in lexer
Fixes: QTCREATORBUG-27503
Change-Id: Idbff5a9b5b2e6e841e298ca6f706ef3c6aa1622b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-01-30 05:47:41 +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
Artem Sokolovskii
a5bee6e3ae tests: Remove foreach usage
Task-number: QTCREATORBUG-27464
Change-Id: I0e42da9b04793be959ad050fdecc0c78c98d9fcd
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-01-03 10:53:15 +00:00
hjk
4159c4b5d5 CppEditor: More migration to FilePath
Change-Id: I261b713671e00bb567f61b4ee5ecf6fa83473bff
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-12-14 09:14:12 +00:00
hjk
9a8d34ecf8 CplusPlus: Pass FilePath to Preprocessor::run()
... and update caller sides.

Change-Id: I6a107e4a7fd9f7123cdc6f141da202845bcbbb66
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-12-07 12:58:31 +00:00
hjk
39ffdb416f CPlusPlus: Use FilePath for resolved include paths
... and fix fallout.

Change-Id: I66886e91ff476eff15db51cc024a8021e952d44d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-11-30 17:27:56 +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
hjk
9d80e23256 CppEditor: Proliferate FilePath use
This includes one functional change: It drops some cleaning
of the path used to create the CppDocument, which is now
assumed to be done on the caller side.

Change-Id: I5e2a182028e4d5b56282ad85f4a5c665f081754f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-11-24 15:54:33 +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
hjk
fa1adf4d40 CPlusPlus: Proliferate FilePath use
The starts with CppDocument::filePath(), plus a bit of the fallout

This is one patch of potentially many. It is hard to draw the
line where to stop this kind of chunk, this here converts a few
additional functions for which including it in the patch looked
like less churn than without.

Converting is mostly fromString/toString, with a few exceptions
for "already seem" like caches, that use cheaper "path()" to
avoid likely performance regressions (on Windows FilePath
comparison is currently case-insenstive, and more expensive).

There should be no difference for local operation with this patch.

Change-Id: I7b35f98a0a6f0bfed4ea0f8f987faf586f7a8f2b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-11-22 15:30:00 +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
Christian Kandeler
8662470aba CPlusPlus: Allow " = default" also on function implementations
Note that we only make sure not to trip over valid code; we make no
effort to check whether default/delete is actually allowed at this
type of declaration.

Fixes: QTCREATORBUG-28102
Change-Id: Ic693319b9dfaf8652cf4cae9cd907a6e258ad773
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-10-24 11:43:21 +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
2361353289 CPlusPlus: Remove Rreprocessor::run overload for QStrings
The preprocessor operates on QByteArray, making it less
convenient to use strings helps preventing accidental
conversion roundtrips.

Change-Id: Ifb2068a8fed137c52b05f2979b99cbce3462151e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-08-01 12:18:06 +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
hjk
ffa3aad576 CPlusPlus: Inline some simple central functions
Depending on context, callgrind sees contributions of >8% to
the total cost of project parsing for these functions. The
functional are actualy executed executed out-of-line, often
for a function body of one "payload" instruction only.

Inlining removes the call/endbr64/ret overhead.

Change-Id: I6886f08e322fcaa4e0f54d424279e0a8c24e4718
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-24 11:49:41 +00:00
Eike Ziller
737877984d Use QTEST_GUILESS_MAIN where applicable
instead of QTEST_MAIN. Reduces the initialization that is done by the Qt
test applications, and can also reduce interference with normal OS
operations like the current window loosing focus.

Change-Id: If88f289281aa1c8703ac7d4dbe0799d067c16588
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-13 06:06:44 +00:00