Commit Graph

405 Commits

Author SHA1 Message Date
Cristian Adam
0dbc208a07 CMake: Add -fPIC also for OBJECT libraries
add_qtc_library would have set the POSITION_INDEPENDENT_CODE property
for STATIC libraries on UNIX based systems.

The OBJECT libraries need the same treatment.

Change-Id: Ia333a36ea0f35d7db3ed876cdde5b895b47644c7
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-05-12 12:49:05 +00:00
Christian Kandeler
b795b42980 CppEditor: More special rendering for string literals
Display prefixes and suffixes different from the actual string, like we
already did for raw string literals.
This uncovered some minor bugs in both lexer and highlighter:
  - Wrong length for a setFormat() call in highlightRawStringLiteral()
  - Missing check for user-defined literal in raw string literals
  - Missing check for user-defined literal in multi-line strings

Fixes: QTCREATORBUG-28869
Change-Id: I018717c50ddc1d09c609556161c85dfb0cc29fab
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-04-13 11:36:12 +00:00
hjk
884a1d6f94 Replace a few \returns by Returns
Change-Id: I09c633e610421f5cc8257b15de60ffa98d890ee0
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-03-24 14:51:55 +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
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
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
Eike Ziller
55fa109b59 CMake build: Use version-less Qt targets
Since we do not support Qt < 5.15 anymore, and as a first step
for getting rid of our special FindQt5.cmake.

Change-Id: Icc5dbaf9b0a3a622b1f609ff114b9decb6d2856c
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-01-05 10:13:16 +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
Eike Ziller
10dca6b37f Merge remote-tracking branch 'origin/9.0'
Change-Id: Ie069f3b2a1200b3e665341b1d56ce836024b0d29
2022-11-10 13:22:43 +01:00
Artem Sokolovskii
39d04fb9e7 QuickFix: Fix generate function definition with unsigned type
Fixes: QTCREATORBUG-28378
Change-Id: Ic94901e430d08aab22c8f4c394eda1f8a93398bc
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-11-10 09:04:09 +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
Christian Kandeler
f4e18967e2 CPlusPlus: Remove unused parser functions
It's unclear whether they should actually be used, but right now their
presence is confusing.

Change-Id: I15d8a7a2524c3abc668bcd0a4b3e0e956f68b065
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-10-21 12:10:53 +00:00
Marc Mutz
8eb4d52342 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.

Task-number: QTBUG-99313
Change-Id: I88edd91395849574436299b8badda21bb93bea39
Reviewed-by: hjk <hjk@qt.io>
2022-10-07 13:47:53 +00:00
Christian Kandeler
6abebbbe35 CppEditor: Remove extra CPlusPlus::Class member
Amends 0fab5956ea.
We want to avoid carrying these eight bytes ber Class instance around.
Instead, we now just replace the (anonymous) struct name with the
typedef'ed one.
Note that in C (but not C++), this is possible:
    struct S {};
    typedef struct {} S;
    struct S s1;
    S s2;
However, our code model has never respected the extra struct namespace,
so it can already not distinguish between occurrences of "S" and "struct
S".

Change-Id: I55feafea7d3a4a5848e10f7011f633a2ce0f626e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-16 07:31:22 +00:00
Christian Kandeler
0fab5956ea CppEditor: Store typedefed name for anonymous structs
... and use it as the struct display name in some places.

Fixes: QTCREATORBUG-26611
Change-Id: I1b127f5705307a0fabd2441ff871162c882927a5
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-15 15:08:20 +00:00
Christian Kandeler
d454184467 ClangCodeModel: Use central functions for getting token positions
Change-Id: I192e2807067467906b38e164933755f763133cb4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-08-26 07:44:21 +00:00
Christian Kandeler
fa13f48c2b CPlusPlus: Fix mis-parsing array-related constructs
... as structured bindings.
Also add a safety check to Bind that might be needed for invalid code.
Amends ca00b874a7.

Change-Id: I7b174b80ad97ed7424f1e369b876c99acf7e95d2
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>
2022-08-25 08:09:23 +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
Christian Kandeler
5817bdf87d CppEditor: Consider selection when requesting quickfixes
If the user has a token selected, prefer that to the actual cursor
position.

Fixes: QTCREATORBUG-27886
Change-Id: Ib32e24676510bff42292fe23e4962720fcbac4ed
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-08-23 08:37:07 +00:00
Marcus Tillmanns
3a53eebcfd cplusplus: Disable warning
Change-Id: I08f3b40afc50903304627aeb788c60fcbafdd288
Reviewed-by: hjk <hjk@qt.io>
2022-08-04 10:22: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
27d51e9804 CPlusPlus: Inline some Scope related simple functions
Change-Id: I23486fdfa749fe864c04d5c1a7cede21fb16005b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-28 11:02:06 +00:00
hjk
31db28601b CPlusPlus: Use a global variable for the undefined type instance
... and split the FullySpecifiedType in two overloads.

Initially:

        29 [1]  FullySpecifiedType::FullySpecifiedType(Type *type) :
                <+   24>        41 54                 push   %r12
                <+   26>        55                    push   %rbp
        34 [1]          static UndefinedType t;
                <+   27>        48 8b 2d 26 68 13 00  mov    0x136826(%rip),%rbp
        29 [1]  FullySpecifiedType::FullySpecifiedType(Type *type) :
                <+   34>        53                    push   %rbx
                <+   35>        48 89 fb              mov    %rdi,%rbx
        34 [1]          static UndefinedType t;
                <+   38>        0f b6 45 00           movzbl 0x0(%rbp),%eax
                <+   42>        84 c0                 test   %al,%al
                <+   44>        74 12                 je     0x7fffc135c620 <_ZN9CPlusPlus18FullySpecifiedTypeC2EPNS_4TypeE+64>
                <+   46>        4c 8b 25 5b 66 13 00  mov    0x13665b(%rip),%r12
        35 [1]          return &t;
                <+   53>        4c 89 23              mov    %r12,(%rbx)
        34 [1]  }
                <+   56>        5b                    pop    %rbx
                <+   57>        5d                    pop    %rbp
                <+   58>        41 5c                 pop    %r12
                <+   60>        c3                    ret

After making it a global variable:

        29 [1]  FullySpecifiedType::FullySpecifiedType(Type *type) :
                                f3 0f 1e fa           endbr64
        30 [1]      _type(type), _flags(0)
                <+    4>        c7 47 08 00 00 00 00  movl   $0x0,0x8(%rdi)
        32 [1]      if (! type)
                <+   11>        48 85 f6              test   %rsi,%rsi
                <+   14>        74 08                 je     0x7fffc14675f8 <_ZN9CPlusPlus18FullySpecifiedTypeC2EPNS_4TypeE+24>
                <+   16>        48 89 37              mov    %rsi,(%rdi)
        34 [1]  }
                <+   19>        c3                    ret
                <+   20>        0f 1f 40 00           nopl   0x0(%rax)
        33 [1]          _type = &UndefinedType::instance;
                <+   24>        48 8b 35 49 67 13 00  mov    0x136749(%rip),%rsi        # 0x7fffc159dd48
                <+   31>        48 89 37              mov    %rsi,(%rdi)
        34 [1]  }
                <+   34>        c3                    ret

The no-parameters branch after splitting:

        29 [1]  FullySpecifiedType::FullySpecifiedType() :
                                f3 0f 1e fa           endbr64
        30 [1]      _type(&UndefinedType::instance), _flags(0)
                <+    4>        48 8b 05 5d 67 13 00  mov    0x13675d(%rip),%rax        # 0x7fffc159dd48
                <+   11>        c7 47 08 00 00 00 00  movl   $0x0,0x8(%rdi)
                <+   18>        48 89 07              mov    %rax,(%rdi)
        31 [1]  {}
                <+   21>        c3                    ret

Change-Id: I61439d68921cf9fa422304033b75de16bb4aa0d5
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-24 14:44:06 +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
Cristian Adam
88781a003f CMake: Qt Creator Static build support
This adds the build system feature that allows Qt Creator's libraries
and plugins to be compiled statically.

Fixes some symbol clashes when all plugins are linked into the same
executable.

Support for actually loading static plugins will be added in a separate
commit.

The feature is controlled by QTC_STATIC_BUILD which by default is OFF.

Change-Id: I1fab7953c43e42dc75619e35660029ee067106df
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-04-29 07:16:53 +00:00
Christian Kandeler
cb86ca547a CppEditor: Fix "move function definition"
... for member functions with exception specification and/or reference
qualifiers.
The FunctionDeclaratorAST::cv_qualifier_list member can contain both the
proper qualifiers "const" and "volatile" as well as the pseudo-qualifiers
"override" and "final". The problem is that the former appear before
exception specification and reference qualifiers, whereas the latter come
afterwards. Therefore, when calculating the declarator's first and last
tokens, we can't just mechanically check the different declarator members
in order. Instead, we need to compare the token values to see which
comes first.

Task-number: QTCREATORBUG-27132
Change-Id: I924f9afe49453fa51b4a2fe010d1cc00c9defad1
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>
2022-04-05 11:38:46 +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
a3af941adf CppEditor: Fix highlighting of raw string literals
... with the built-in highlighter.
Pass the necessary context information in and out of the SimpleLexer.

Task-number: QTCREATORBUG-26211
Fixes: QTCREATORBUG-26425
Fixes: QTCREATORBUG-26615
Change-Id: Id72f743e07ae117ca51b0d5e527b208dda133b7e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-12-10 13:36:21 +00:00
Christian Kandeler
6077bde638 CPlusPlus: Allow numeric literals with single quotes
... also in macro expansions.
Amends 8c437362bc. Just like in that patch, we don't prevent trailing
quotes, even though they are not allowed. Unlike in that patch, we don't
check the language version, as it is not set during preprocessor mode
(for whatever reason).

Fixes: QTCREATORBUG-26484
Change-Id: I8737724208802ed9a9005af538cf13fbfd2efd42
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-11-08 09:32:45 +00:00
Christian Kandeler
0814af1503 CPlusPlus: Fix build
Amends 05e698a478.

Change-Id: Ie33c233b89cad40f7e6a29a26582990ba9029f44
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-10-27 13:28:25 +00:00
Christian Kandeler
05e698a478 CppEditor: Fix "insert def from decl" for template return types
Fixes: QTCREATORBUG-26397
Change-Id: Ia215f2c2b5da708b0fd7c894987683b305f4ccec
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-10-27 11:23:36 +00:00
Christian Kandeler
d7717f1eca CppEditor: Fix "insert definition" for templates with value parameters
Fixes: QTCREATORBUG-26113
Change-Id: I2d2a1c1bdcffd67072bbda99dabbbfbfafe115c5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-17 08:35:35 +00:00
Eike Ziller
6bc9cddb9e Merge remote-tracking branch 'origin/4.15' into 5.0
Conflicts:
	src/plugins/cmakeprojectmanager/projecttreehelper.cpp
	src/plugins/coreplugin/mainwindow.cpp

Change-Id: Ie3a281b8635e79ca5fa794a127ed0039f33fe2ee
2021-06-24 10:43:10 +02:00
Eike Ziller
4290c26414 CMake build: Force optimization of CPlusPlus lib
Even in the debug build, as done for the qmake build system. This is for
performance optimization of this critical part for C++ parsing even in
debug / developer builds.

Change-Id: I9552ba9fc44e213f2df1d2d2a64a126af3603fd1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-06-22 10:10:14 +00:00
Cristian Adam
df571577b6 CPlusPlus: Fix MSVC Debug build
Amends 011f62dfc255b73e9fc952fa35abbb8219856f8d

Change-Id: I33aea095341ee5e1cb38763cde04b567ea030986
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-04 07:13:36 +00:00
Cristian Adam
c956d02200 CPlusPlus: Fix build with clang-cl
llvm-link is picky regarding missing dllimport symbols.

Change-Id: I189ddaa0962ded9ebe16d60bae568979a35403a3
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-06-03 10:03:24 +00:00
Christian Stenger
73c2a98b39 Utils: Make Link a class
Change-Id: Ia2f1c9589f65064eca2416b093b3fecf568058d2
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-05-31 06:45:03 +00:00
David Schulz
356bfcc9fd Utils: filepathify Link
Change-Id: Ie62500bde139158e776f9698ee0ea00c2a113f93
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-25 17:32:18 +00:00
Christian Kandeler
f31d583081 CPlusPlus: Increase maximum statement depth
We're hitting the limit in a real-world project.
(Of course, it's pretty horrific that we unconditionally access pointers
that can legally be null, but that's difficult to change now.)

Fixes: QTCREATORBUG-25606
Change-Id: I1d8c883550e8968bbfa6ce26965573697774361f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-20 09:57:13 +00:00
Andre Hartmann
2df71c5798 Lexer: Support the integer suffixes LU and LLU also
Before we only supported UL and ULL.

And add tests for all variants of allowed integer suffixes.

Fixes: QTCREATORBUG-25604
Change-Id: Id92f371d2effa7456d2d50891a6c29810c5c4c75
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-04-19 09:16:55 +00:00
hjk
a5b93b54c8 CPlusPlus: Add missing line and column info for lambda functions
Task-number: QTCREATORBUG-25242
Change-Id: I5032bb04879e30f5516471e2038dc4b6bb3477f8
Reviewed-by: hjk <hjk@qt.io>
2021-02-05 08:51:09 +00:00
Leander Schulten
29207e3eeb CppEditor: Add Base Class Support for Generate Constructor QuickFix
Change-Id: Idd92229134609c0ac87aad030a6bb645ff4cce1b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-02-04 11:40:05 +00:00
Jarek Kobus
cdbeb591ca Add missing includes
Amends 675abca1ca

Change-Id: I88d48fad84043bfea5310f8aad5d77cf550be2d9
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-01-13 12:18:34 +00:00
Jarek Kobus
627a96d991 Compile fix
Amends 675abca1ca

Change-Id: I958c6b43631d287e6973abb0c61a5c381766adb3
Reviewed-by: hjk <hjk@qt.io>
2021-01-13 11:11:47 +00:00
Jarek Kobus
675abca1ca Use std::unordered_map instead of std::map
In theory it should be faster.

Change-Id: Ibf6ce8c5dced5a075b57f89ce6e2d5ed1c5d6be7
Reviewed-by: hjk <hjk@qt.io>
2021-01-13 07:28:47 +00:00
Eike Ziller
7ce3ceabe9 Merge remote-tracking branch 'origin/4.14'
Change-Id: I26a53ef81a54a2f7aa482448118298895b712941
2021-01-12 14:14:41 +01:00
Leander Schulten
c960f279e6 CppEditor: Add QuickFix to generate a constructor
Change-Id: Iba2ce3bfa1a1d1a325626a21f46b485d12cbb060
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-01-11 14:59:40 +00:00