Commit Graph

13 Commits

Author SHA1 Message Date
Christian Kandeler
569d5ca4da C++ unit test: Another clang 11 adaptation
This was probably a bug in clang 10: The amount of whitespace after the
operator should not matter.

Change-Id: If161a7b2f60ee932bef19edb9fe71aac31be3c8b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-09-23 10:28:48 +00:00
Christian Kandeler
aaacfb4945 Fix a clang unit test
This particular test was apparently supposed to check that the two
occurrences of "foo" (one const, one non-const) appear next to each
other in the list of completions. However, there is only one occurrence
of "foo" and the test only succeeded because it happens to be at index 0
and -1 is returned for the second lookup, resulting in a absolute
difference of 1.
So let's explicitly check for that instead.

Change-Id: I6049689911decc114239f2be7e63b091a4a18226
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-11 15:24:07 +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
Nikolai Kosjar
8df8502090 Clang: Disable a completion test for LLVM/Clang 10
For the case

  struct Foo;
  void f(Foo *foo) { foo->/*COMPLETE-HERE*/ }

no completions are expected as "Foo" is only forward declared.

This seems to be handled correctly in current LLVM/Clang master
(upcoming version 11), but wasn't with previous versions as pointless
non-member-completions were returned.

As our workaround is not applicable anymore with LLVM/Clang 10, disable
the corresponding test for that version as we cannot do anything about
it.

Change-Id: Ia02696175d0d532e16bc16a1010821b4aed20f8b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-05-22 08:42:09 +00: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
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
Nikolai Kosjar
aa290912b8 Clang: Remove project tracking on clangbackend side
...as it is not needed. Just provide the compilation arguments as part
of the Document.

As a side effect, re-initializing the backend after a crash is cheaper
and will not freeze the UI anymore (referenced bug).

Task-number: QTCREATORBUG-21097
Change-Id: I866e25ef1fd5e4d318df16612a7564469e6baa11
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-26 10:45:41 +00:00
Ivan Donchevskii
da4be3fdb7 Clang: Use new libclang code completion fix-its feature
Each completion coming from libclang now has it's own
list of fix-its which are required to be applied before
completion itself.

This saves one extra reparse cycle and gives an ability
to provide both kinds of completion (initial and corrected
one) for cases like shared_ptr, unique_ptr or any other
class with overloaded arrow operator.

Each of these extra fix-its is applied together with
corresponding completion dircetly before completion itself.

Change-Id: Ide37e45bb15fa2f1375cd6b86ecd43ced3593046
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-07-27 07:34:44 +00:00
hjk
cf4dbb4bb6 ClangSupport: Use simpler structures in some cases
The patch is mostly mechanical, but contains also a few spurious changes
from values references for some local variables, foreach -> ranged for
etc that I coulnd't resist.

Change-Id: I58f0bd972546895eb318607cbfbd7ac35caf3f23
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-04-06 12:55:23 +00:00
Ivan Donchevskii
79e94ddae8 Clang: Workaround completion for make_unique/shared
Change unsaved file to provide constructor overloads
for std::make_unique, std::make_shared and
QSharedPointer::create

Example:
// Provide Foo constructor signatures at <Cursor>
std::make_unique<Foo>(<Cursor>

Task-number: QTCREATORBUG-18615
Change-Id: I87dd17085adf99ee498db969a3cdda5ebd973476
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-08 10:13:08 +00:00
Ivan Donchevskii
9a0eca15c5 Clang: fix completion after forward-declared class
Do not complete -> and . with global completions if
foo is a ptr/ref to forward-declared class.

Change-Id: I41e6745ffb07be1d973fe6a8132824f1b3bf7fb1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-06-09 07:05:25 +00:00
Marco Bubke
ada5ea1952 UnitTests: Fix names and disable slow tests by default
Slow and very slow tests have now their own test category. We add SlowTest
for tests which are slower than ~5ms and VerySlowTest if they are slower
than ~100ms. They are disabled them by "-*SlowTest.*". If you have a faster
machine than most developers simply try lower values. The aim is that most
developers can execute the tests in under ~2s.

In the long run we should use dependency breaking and data sharing to
reduce the count of the slow tests.

Change-Id: I8578071258d7f89b2052709f3dd526ced811483f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-01-04 12:35:52 +00:00