Commit Graph

135 Commits

Author SHA1 Message Date
Christian Kandeler
f307c55eac ClangBackEnd: Fix mis-detection of operator<
Inside the body of a function template, clang reports a different cursor
type for operators in some cases. Make sure we don't mistake such
operator< or operator> as opening or closing a template, respectively.

Fixes: QTCREATORBUG-25596
Change-Id: Ifc357e199ea13e44ac501613639e667c333d48e3
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-04-19 07:51:24 +00:00
Christian Kandeler
c80c724b52 ClangCodeModel: Fix template highlighting bug
We need to take into account that the ">>" in constructs such as
std::vector<std::pair<int, int>> is only one token on the clang side.

Change-Id: I90f002ca56f236032f6d39c338593a2ff7590061
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-04-16 07:02:19 +00:00
Christian Kandeler
74177a559e clangbackend: Work around libclang cursor bug
... involving accessing the member of a nested anonymous union from
within the surrounding class. libclang reports a CXCursor_CXXThisExpr
for this location instead of a CXCursor_MemberRefExpr. However, the
latter is still locatable in the AST, so we can correct this.

Fixes: QTCREATORBUG-25342
Change-Id: I1eba13d5153205a52b3689d8ad52493a56b76c07
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-15 12:18:36 +00:00
Eike Ziller
aae3bf4ef7 Merge remote-tracking branch 'origin/4.14'
Change-Id: I516e87eed1b716ec085095c9dd4f47f04a99de7c
2021-01-25 09:06:36 +01:00
Christian Kandeler
bfb63acb09 clangbackend: Fix missing completion for private member functions
... when trying to complete the name of a function definition. libclang
tags such completions as "not accessible", even though we are not in a
call context.

Fixes: QTCREATORBUG-25244
Change-Id: I4b03b1a43be7a85c37c7d2b2bfe2d83112075674
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-01-22 14:49:54 +00:00
Björn Schäpers
8987996500 clang-tidy: Suppress clang warnings
Those warnings should be printed via the clang code model, which can be
fine tuned to (de-)activate warnings. The clang-diagnostic-* warnings
from clang-tidy are not shown in the dialog an thus can not be
selectivly activated by the user.

Change-Id: I80b2cad227a9fd8fa0de253c73c40abfa8076be6
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-12-15 19:38:30 +00:00
Christian Kandeler
aabdbb7d9e clangbackend: More libclang cursor adjustments
Fixes: QTCREATORBUG-21856
Change-Id: I034b463238b4b8da4c36f95cacab79adf94c11eb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-30 11:35:24 +00:00
Christian Kandeler
0d12c8cba8 clangbackend: More cursor adjustments
Fixes: QTCREATORBUG-21534
Change-Id: Ia8a6f277b186bd6decdfec26bfca30b36802c1c2
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-23 13:03:34 +00:00
Christian Kandeler
b0dd6b748f clangbackend: Try harder to get the proper cursor
... in cases where it appears that clang_annotateTokens() did not do
what we wanted.

Fixes: QTCREATORBUG-21522
Change-Id: I272061cb6c4b51a5d779ace5b4e06912c0a386e5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-23 09:59:27 +00:00
Christian Kandeler
2b32b2e440 clangbackend: Provide highlighting for structured bindings
These are reported by libclang as "unexposed declarations".

Fixes: QTCREATORBUG-24769
Change-Id: I7a74b707f4203becabaa74b90758a7b396ee23bd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-27 11:07:44 +00:00
Christian Kandeler
2287def85e clangbackend: Fix crash
We cannot assume that a Q_PROPERTY name is on the same line as the
keyword.

Fixes: QTCREATORBUG-24746
Change-Id: Ic2e02291e24c1abbaf72881b540a26c82899cb2c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-09 08:06:56 +00:00
Christian Kandeler
e162775bde C++ Unit test: Fix diagnostics export test on Windows
The file offsets are different because of CRLF line endings.

Change-Id: Ice859f3b279651b61d147bdd963f62897b090e47
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-09-21 09:23:18 +00:00
Christian Kandeler
d14be7493f ClangBackEnd: Support highlighting of alias templates
Fixes: QTCREATORBUG-24552
Change-Id: I80d2b16114234cf896173cd4104e6a5f12009f69
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-09-14 11:42:09 +00:00
Christian Kandeler
15a1266d50 clangbackend: Do not handle built-in types specially
... when collecing tooltips. The more general functions provide more
information, such as constness.

Fixes: QTCREATORBUG-14950
Change-Id: I6d0a890a695e19e9754b5538ba092a188a3bbbb0
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2020-07-06 06:32:33 +00:00
Christian Kandeler
11f7c4da9f clangbackend: Fix libclang's priority adjustments
... for member qualifiers.
For instance, when doing completion on a non-const object, non-const
member functions get a higher priority than const member functions. This
does not seem particularly sensible and can make our list of completions
appear unordered.
As each matching qualifier only increases the priority by one and the
base priorities are generally further apart, we can fix this problem by
considering two priorities as equal if they are sufficiently close.

Task-number: QTCREATORBUG-6242
Change-Id: I1d04fdf68869cf07cc00626aaac3030b360c2546
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-12 09:39:57 +00:00
Christian Kandeler
4fbd68183b clangbackend: Fix lexicographical sorting of completions
Utf8String has a weird operator<, so we did not get the expected results
from our string comparisons.

Task-number: QTCREATORBUG-6242
Change-Id: I0e94dc42d6e04ab833efcce41463b7024455b6d8
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-10 12:50:50 +00:00
Eike Ziller
c644e7c80a Merge remote-tracking branch 'origin/qds-1.59'
Conflicts:
	src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp
	src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp

Change-Id: Ifa7c66330c1995378280cdb4c57c30015dc11b68
2020-06-08 16:04:15 +02:00
Marco Bubke
a61eff0079 Sqlite: Add session support
Session are captured by hooking in the sqlite changes. They are saved in
blobs and containing inserts, update and deletes. Because the are
semantically coupled to translactions we add a

Change-Id: Ie095558ebc50601fcaae32958ebeeb98b72d73b9
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2020-06-05 09:52:42 +00:00
Christian Kandeler
949bb0e67b ClangCodeModel: Show value in tool tips, if possible
When hovering over a constant expression, it's probably helpful
to show that value to the user.
Requires clang 11 to fully work. For now, it only shows the value for
variable initializations.

Fixes: QTCREATORBUG-23967
Change-Id: I6b844231bac50993c2fa2fa82c552ad9cef590df
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2020-05-26 08:50:58 +00:00
Nikolai Kosjar
e6d16b6747 ClangTools: Support loading exported diagnostics
Add a new toolbar button to load diagnostics exported with

   $ clang-tidy -export-fixes=/path/to/file
   $ clazy-standalone -export-fixes=/path/to/file (master version)

Change-Id: I8316fe0706a18222e68220ef4fbfdc7ae8d09804
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-09-03 09:39:48 +00:00
Marco Bubke
9f805b7e8a ClangRefactoring: Improve follow symbol and usage
Change-Id: Idb42010443e4560489ef067e54d05b4e567598e9
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2019-08-27 11:53:45 +00:00
Marco Bubke
1841cb1fa5 ClangPchManager: Fix path for excluded include files
Still used the old approach but now it is using the new one.

Change-Id: I4bf4da3a5d41d46afff261f3d77bd9190737038a
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2019-07-11 09:03:01 +00:00
Marco Bubke
2d520140d0 Clang: Fix system pre include search path
We now get the resource path from creator. The -fPIC case is working now
too.

Change-Id: Id191e89e6d46706748d50440038a06a349972cc9
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-04-29 12:52:05 +00:00
Ivan Donchevskii
1b0cba38dd Clang: Fix access specifier for variables
Static members have a variable declaration kind so
we need to check their access specifiers in order to
provide proper information about tokens.

Fixes: QTCREATORBUG-22082
Change-Id: If455174bd346398a2df3499fa6cf1ea2b4e26965
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-12 14:19:48 +00:00
Ivan Donchevskii
29758d8364 ClangFormat: Add missing .clang-format file for tests
Change-Id: Ia15b4d7c4546be2375807b1d59b5e3d65b06ab4f
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-18 12:26:50 +00:00
Marco Bubke
c52c531c3f UnitTests: Move symbolscollector data to sub directory
Change-Id: Id1a123f745a0f092aeff9589aa146feb49d31661
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-12 14:01:50 +00:00
Marco Bubke
693c896e5a PchManager: Use Generated Files in BuildDependencyCollector
Task-number: QTCREATORBUG-21843
Change-Id: I33c29d50943a914313a4c2e577b0210460f663d8
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-01-24 12:47:30 +00:00
Ivan Donchevskii
020d1aab0a ClangFormat: Add unit-tests
Test reported cases from bugreports.

Change-Id: I9aeb42dc476cbfe98abb837f2e941d8e2685235a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-01-24 08:35:51 +00:00
Ivan Donchevskii
d7058e1afe ClangFormat: Refactor indenter to allow ClangFormat unit-tests
We do not build texteditor files in unit-tests so some tricks
were required to make ClangFormatIndenter available.

First simple unit-test proofs it builds and runs.

Change-Id: I81d5ea099bd27fd1c1ed8b5b7877299dcc62a67f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-01-22 09:52:15 +00:00
Ivan Donchevskii
ca24877c93 Clang: Improve anonymous cursors support
With the recent libclang fix the anonymous cursors
are reported properly. So we can use that information
instead of some of our workarounds.

Change-Id: I94401f33e671e6dd08ac7d850c8d5c3dbdd062cc
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-01-18 09:09:58 +00:00
Eike Ziller
e5c2ee922a Merge remote-tracking branch 'origin/4.8'
Conflicts:
	src/plugins/cpptools/compileroptionsbuilder.cpp

Change-Id: I743ea39480cc5c7b6febcd2e93713d15a3ae6d9c
2018-12-07 08:53:11 +01:00
Nikolai Kosjar
6889f4df80 Clang: Fix tooltip for pointer to class
Detect and dereference pointer to get to the correct class.

Fixes: QTCREATORBUG-21523
Change-Id: I679778b2cfbbce4466294dabdee096686f53f095
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-12-06 08:55:28 +00:00
Eike Ziller
29c9f8080d Merge remote-tracking branch 'origin/4.8'
Conflicts:
	src/plugins/android/androidrunnerworker.cpp

Change-Id: Ibd8b99435365fb7e7d488313fd1d2b3a75adad1b
2018-11-29 13:36:14 +01:00
Marco Bubke
15df73a8ba Clang: Fix output arguments highlighting for constructor parameters
The are not any more shown but they are still not shown for constructor
arguments because libClang is providing the wrong argument count.

Task-number: QTCREATORBUG-21543
Change-Id: If9b6140ed4b2dedf71bd94aae0a97669cdd04e67
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-11-27 08:51:35 +00:00
Nikolai Kosjar
f56ec051b0 Clang: Fix TokenProcessor.Qt* tests
With the upgrade to clang 7 these started to fail on Linux.

Something changed in clang regarding the processing of our
wrappedQtHeaders/QtCore/qobjectdefs.h. Since we can't rely on the
include paths of Qt in the tests anyway, inline the relevant
preprocessor directives into the test file to make the tests
independent of that.

Change-Id: Iba5cdc5483c3007346346d294374598a75fcb5a1
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-11-27 07:34:10 +00:00
Orgad Shaneh
5170dd0858 Merge remote-tracking branch 'origin/4.8'
Change-Id: Ia8bf92c8effdee0e1085730cb975ff88c8ad85fc
2018-11-20 19:13:13 +02:00
Marco Bubke
2a65be107b ClangPchManager: Filter missing includes recursively
Missing includes prevent the creation of PCHs. So removing includes which
directly or indirectly point to missing includes is a requirement for
working PCHs.

Task-number: QTCREATORBUG-21529
Change-Id: Id55be164df590149fe1ab55c2a3a90b8b5e3bfa7
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-11-20 14:25:08 +00:00
Marco Bubke
64a3a130ac Clang: Add BuildDependencyCollector
IncludeCollector is renamed to BuildDependencyCollector. It is now
returning a BuildDependency instead of individual getter. The test coverage
is improved too.

Task-number: QTCREATORBUG-21379
Change-Id: Ifc2d1c40c85772cf498c21968de526f4408b6023
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-11-20 14:24:03 +00:00
Eike Ziller
3d1d9aae2e Merge remote-tracking branch 'origin/4.8'
Conflicts:
	src/plugins/winrt/winrtdevicefactory.cpp

Change-Id: I33b8697e2ebf2bea051d7f1144449e0743ee16a5
2018-11-19 10:00:18 +01:00
Nikolai Kosjar
5b12ada2dc Clang: Fix completion icon for members in member init list
Change-Id: Ib02320dcf4de7cbb8ac6fbf29d1929edae77591a
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-11-14 07:38:19 +00:00
Eike Ziller
1473bc5891 Merge remote-tracking branch 'origin/4.8'
Conflicts:
	src/plugins/debugger/debuggermainwindow.cpp
	src/plugins/qbsprojectmanager/qbsbuildstep.cpp
	src/plugins/winrt/winrtdevicefactory.cpp
	tests/unit/unittest/gtest-creator-printing.cpp
	tests/unit/unittest/gtest-creator-printing.h
	tests/unit/unittest/unittest.pro

Change-Id: Ie9b80b87a8a4fa81baf72a2daa7919b21371c15e
2018-11-06 09:20:00 +01:00
Nikolai Kosjar
d52ac9a708 Clang: Fix unresolved #includes for ui_*.h headers
...with an extra parse.

Previously, the creation of an e.g. "Qt Widgets Application" from the
wizard could show code model errors in mainwindow.cpp. Depending on
timing issues, the first error is either

  1. 'ui_mainwindow.h' file not found (QTCREATORBUG-15187)
    The parse happened before the in-memory ui_mainwindow.h was
    generated by uic. The file system watcher can't help here as the
    #include was not resolved successfully. And libclang's reparse does
    not handle this case (it would need to remember all failed #include
    stats...).
    ==> Detect this case with the help of the include paths and trigger
    a full parse.

  2. or: allocation of incomplete type... (QTCREATORBUG-15187)
    The parse happened after the generation of the in-memory
    ui_mainwindow.h, but before the clangbackend received the unsaved
    file.
    ==> Fix this by also writing the content of the unsaved file to our
    behind-the-scenes-created ui_mainwindow.h.

Fixes: QTCREATORBUG-15187
Fixes: QTCREATORBUG-17002
Change-Id: I4f3a81adaa3d604746977a402c29f83fbc5b0e44
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-31 10:38:27 +00:00
Ivan Donchevskii
93269f3ecd Clang: Add unit-tests for function overloads completion order
Make sure that the same function overloads with different priorities
come together in the completions list.

Fixes the case when we complete the method without '.' or '->'.

Change-Id: Icaf7ea47f5e58b3ae5cc9764ad79c857f6f6e231
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-10-26 07:22:24 +00:00
Marco Bubke
e571220663 Clang: Add top system includes to include collector
If we want to split the project part we have to filter out the top system
includes.

Task-number: QTCREATORBUG-21345
Change-Id: I258fa33ac39bd94b4699f4f39923d6ad274c1dc7
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-25 13:34:52 +00:00
Eike Ziller
95db30bd3a Merge remote-tracking branch 'origin/4.8'
Conflicts:
	src/plugins/debugger/debuggeritem.cpp
	tests/unit/unittest/unittest.pro

Change-Id: Id2e4e9c2bc87b2556d7c2845aea3fe2fa11b630b
2018-10-22 09:53:54 +02:00
Ivan Donchevskii
78211741c8 Clang: Make SourceLocation lazily calculate its fields
Trigger path, line, column and offset evaluation only if one
of them is accessed.

Change-Id: Ib2f8b06ece94a3b7424db28523b5796628865202
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-10-17 05:56:39 +00:00
Eike Ziller
8fa37a17c1 Merge remote-tracking branch 'origin/4.8'
Change-Id: I74268f767e2fc7dae5db390a0348095ef220abd2
2018-10-05 13:11:02 +02:00
Ivan Donchevskii
f6e5202b80 CompilerOptionsBuilder unit-tests
Bonus: minor compiler options builder issues fixed.

Change-Id: Ie25f8fad6729339de05f2bf9b614ceac873e2634
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-10-04 10:24:13 +00:00
Eike Ziller
f8ffe14b82 Merge remote-tracking branch 'origin/4.8'
Change-Id: Ife02e25f89a601e066851cddf0e000ac9491fc35
2018-10-04 09:39:10 +02:00
Ivan Donchevskii
efc39304a1 Clang: Move the majority of completion items sorting to ClangBackend
With this change ClangCodeModel only needs to sort completions by prefix.

Also some other optimization have become possible and are implemented here:
1. Getting completions after '{' for constructor overloads by replacing
   it with '(' inside usaved file.
2. Checking for all overloads requires only previous item check because
   all Class completions are already sorted to go before all CXXConstructor
   completions. Since they are not mixed no extra search is required.

Change-Id: Ie0187ad96a20857a63c1d71ddec74606b803f572
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-10-02 12:29:23 +00:00