Commit Graph

918 Commits

Author SHA1 Message Date
Nikolai Kosjar
ae92b68154 Clang: Remove some needless bools
Change-Id: Ia845c803fce85ad0e29e2cf6b64820b86599bac6
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-05 07:25:45 +00:00
Marco Bubke
381bee1434 Clang: fix llvm lib linking on windows
If we use paths with spaces we cannot split them anymore so we have to
handle unix and windows differently.

Change-Id: Ibfc8c51cfe2ecd68e913ad84e0e1269eb7eeda02
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-09-19 15:27:25 +00:00
Marco Bubke
47c01daeb2 UnitTest: Cleanup
Improve naming and introduce googletest.h.

Change-Id: I445c13db4c23d6dd5682ce0db3b83055cc6b8a89
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-09-19 15:17:54 +00:00
Nikolai Kosjar
cb0e730bb5 Clang: Clean up exceptions
* Extract common stuff into the base class ClangException
* Remove unused exceptions TranslationUnitParseErrorException and
  TranslationUnitReparseErrorException
* Do not send error messages to the Qt Creator side. The messages were
  only generated when the backend crashed and while it was not yet fully
  re-initialized (e.g. do code completion right after crash where the
  document was not yet registered at the backend).

Change-Id: I91d98d5ef681ad487f7a2fd66f78fa7cd1e958df
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-09-14 13:08:08 +00:00
Nikolai Kosjar
26cb17bb65 Clang: More renaming fixes
Change-Id: If796869b26fc6faf5919041368fb26e8a42ae8a2
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-09-14 13:08:04 +00:00
Nikolai Kosjar
9606988989 Clang: Move exception classes into single header/source unit
Change-Id: I60b4ce61e46d6f4ba87a2be49e6bbc219508c471
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-09-14 13:07:56 +00:00
Nikolai Kosjar
985e4436f2 Clang: Rename TranslationUnitCore to TranslationUnit
Change-Id: I03a59ae5d5073c812ad40c7623cfb1fdb80aad80
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-09-07 13:36:43 +00:00
Nikolai Kosjar
14b27183ce Clang: Rename TranslationUnit(s) to Document(s)
The "TranslationUnit parts" moved already to TranslationUnitCore.

Change-Id: I2bea7847e2b3e84fbfacc3d2dc43f180873349ac
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-09-07 12:36:19 +00:00
Marco Bubke
2e062552eb Clang: Report an error if the unit test are linked with LLVM without RTTI
We don't want to disable RTTI in unittest so we require to compile them
with RTTI. You can disable yourself RTTI if you don't want them for some
reasons.

Change-Id: I76d05a36442305f379ce3d88b3f6ed4372127002
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-09-05 10:01:14 +00:00
Nikolai Kosjar
435d631266 Clang: Fixes for unittest.pro
Change-Id: I356ccdec0eaa403e5ec7364fb54de39f24695b4b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2016-08-31 13:43:05 +00:00
Marco Bubke
68aeff4b9f UnitTest: Break the dependency to LLVM
If you have no LLVM installed it was impossible to compile the unit test.
But some unit test don't depend on LLVM. With this change it is now
possible to compile them.

Change-Id: Iac0c1b3cdf6c317e6ba4755acd5f8458db5a7451
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-08-22 09:12:56 +00:00
Marco Bubke
d23c4985cb Utils: Fix unittest
Prevent operator selection to be ambiguous.

Change-Id: I1ff0d6aad8fe5ce24b0d1038c1b6121a595800fe
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-08-22 09:12:35 +00:00
Nikolai Kosjar
4372514e6b Clang: Remove unused arguments
Change-Id: I72e6df2e0e5b94addbca79bbca6bf2aa7cff2042
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-08-22 07:02:26 +00:00
Marco Bubke
678e6e4ddf Clang: Fix CodeCompletionsExtractor test crash
CXCodeComplete_IncludeBriefComments has to used if the translation unit
is using it too. Otherwise an assert is triggered.

Change-Id: Ia252ffd9c440144f21c2354c6885f7ae73de4b29
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-08-18 13:06:17 +00:00
Orgad Shaneh
c9956b9e05 Revert required C++ version to 11
It was bumped to 14 in merge commit 1853f01a, due to a conflict in
unittest.pro which I confused with qtcreator.pri.

Change-Id: I1ec15d9d20d90c38849eea799a724f4c85fe36b5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2016-08-15 09:45:46 +00:00
Marco Bubke
092df2edaa Clang: Smallstring should not depend on std::ostream
We move the io operators in an extra header file because if we would
include ostream in smallstring.h we would blow the compile time.

Change-Id: Iea61ceedbbbcdd2adc6dc149794dab6e743084f8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-08-08 15:01:53 +00:00
Marco Bubke
f56ec53fa1 Clang: Test for file path RequestSourceLocationsForRenamingMessage
Change-Id: Ia384deb60e644d8894d7c56f81b3deb8b7706c11
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-08-08 14:19:02 +00:00
Marco Bubke
98a167c0d5 Clang: Fix template renaming
Change-Id: I8040fe8dfc99d66e242ce2ff8589aa914838bfc9
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-08-08 13:50:25 +00:00
Marco Bubke
ec06fd0e84 Clang: Use std::replace instead of std::transform
Change-Id: I60e42577631dee5cf05b1129a49ea36c391e8923
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-08-08 13:27:38 +00:00
Orgad Shaneh
1853f01a5b Merge remote-tracking branch 'origin/4.1'
Change-Id: Ia442f30f387fe9292217582260bbe79e54608810
2016-08-05 11:40:07 +02:00
Marco Bubke
4cdb5bab15 Clang: Add clang refactoring
Change-Id: I2e3f36f810276da3f8dc7dcc587b06f8edb586d3
GPush-Base: d02f51b48fc752fddcdef6dcb32b3f7f6c0195a3
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-08-04 14:37:19 +00:00
Marco Bubke
0549c6af97 Utils: Add std::string conversion constructor and operator to small string
Change-Id: Ia76d7647fc8d2c9b72bc5bce2e7a6e2c3fcc18cc
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-08-02 13:38:23 +00:00
Marco Bubke
390e2d164c Utils: Add iterator constructors to small string
Change-Id: Ib8fcacd5dc520842cf5cee73ea21c021221158ca
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-08-02 13:38:19 +00:00
Marco Bubke
7610e48716 Utils: Fix smallstring
Change-Id: I681df8c3fd9aa84f14d5d581633894605f56b71a
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-08-02 13:38:14 +00:00
Oswald Buddenhagen
45b854dbd5 enable c++11 really globally
... and remove all instances that became redundant now.
this excludes everything that comes from outside qtc, or looks like it
could "leave" it.

Change-Id: Idc8baad17cd1ffdc5e160ec48ea3292d633a2562
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-08-02 07:52:38 +00:00
Nikolai Kosjar
38f72855b6 Clang: Process distinct documents concurrently
Speed ups the typical use cases that can profit from this:
 * Change a header file and switch then to source file
 * Open documents one after the other (Follow Symbol)
 * Change documents visible in splits (e.g. by refactoring action)
 * Restore a session with multiple splits

Fixes the test ClangIpcServer.GetCodeCompletionDependingOnArgumets.

Change-Id: Ia575bd59780df14146dfc091a4d48794e4a0543d
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-07-28 09:42:31 +00:00
Nikolai Kosjar
90f94363db Clang: Extract TranslationUnitCore and (re)parse explicitly
Extract TranslationUnitCore, which is the API for the high-level
operations we need. TranslationUnit does not call any clang_* functions
anymore, except the one needed for disposing the CXTranslationUnit - for
now, we keep TranslationUnit the owner of TranslationUnitCore.

TranslationUnitCore will be passed on to the worker threads.

With this, the current "TranslationUnit" looses its meaning. We will
rename it to "Document" in a follow-up change.

                            ***

TranslationUnit::cxTranslationUnit does not implicitly
creates/parses/reparses anymore. We use more verbose update operations
now.

The test ClangIpcServer.GetCodeCompletionDependingOnArgumets fails now
because of this - CodeCompleter::completeHelper() does not recreate the
translation unit anymore, thus working on the old data.

This will be addressed in a follow-up change.

Change-Id: I6213d6f1609cd3c9a54666c84cb8b623b2fefe1c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-07-28 09:42:24 +00:00
Nikolai Kosjar
dc734f45fd Clang: Extract TranslationUnitUpdater
...in preparation for concurrent processing of documents.

Parsing and reparsing is handled by TranslationUnit. Since we will do
this in a different thread, extract the core logic into the new class
TranslationUnitUpdater, so that we can prepare the necessary data for
the run and then later incorporate the results of the parse/reparse.

Change-Id: Ic9d936d193ee6795a755f0cfc38c0b2a7bd402cc
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-07-28 09:42:18 +00:00
Nikolai Kosjar
606d41187c Clang: Prepare for multi-threading
* Make the necessary data implicitly shared since it might get
  accessed/modified from two different threads with follow-up changes.
  This applies for UnsavedFiles/UnsavedFile and ProjectPart::arguments().

* Avoid returning references.

Change-Id: I98842c1cb90ae0d344a15c63b72cbc89568722d3
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-07-28 09:42:14 +00:00
Orgad Shaneh
1b34f2a4b8 Merge remote-tracking branch 'origin/4.1'
Change-Id: Ia90424d479936a898705c433e5810c77ae088b2c
2016-07-22 15:18:00 +03:00
David Schulz
16ca70994b Clang: Fix assert in code completion test
Assertion failed: IncludeBriefComments == this-
>IncludeBriefCommentsInCodeCompletion, file C:\dev\src\llvm-381\tools
\clang\lib\Frontend\ASTUnit.cpp, line 2337

Only occurs when linked again a debug llvm.

Change-Id: I6a37875fe95852ee2afcef7f6b6b38e9669a6584
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-07-22 06:35:46 +00:00
Marco Bubke
e08c1a39e7 UnitTests: Clean up line prefixer test
In TDD development is a standard advised that you setup you values in the
block, run what you want to test in the second and assert in third. We
should try to stick it because it makes reading the test easier.

It is advised too put the setup code after the test if possible.

I used const QList<QByteArray> inputChunks = {"hello\n"} instead of
const QList<QByteArray> inputChunks {"hello\n"} because it is always using
the initializer_list constructor.

Change-Id: I1573566efc1327a2d8681e9ae7bd0ad6ee182789
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-07-19 16:20:10 +00:00
Nikolai Kosjar
2647946231 Clang: Fix warning in unit test
warning: comparison between signed and unsigned integer expressions
[-Wsign-compare]

Change-Id: I8c6e2d8f6c536ec3c50293b6302ebb5b1d8313c1
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@theqtcompany.com>
2016-07-18 13:17:32 +00:00
Nikolai Kosjar
8f9c42c640 Clang: Merge highlighting/diagnostics messages
The messages

    RequestDiagnosticsMessage
    RequestHighlightingMessage

and

    DiagnosticsChangedMessage
    HighlightingChangedMessage

are always send/received together, so merge them into

    RequestDocumentAnnotationsMessage
    DocumentAnnotationsChangedMessage

Change-Id: I6a0b6281ed1e6efe6cb18386afe99b1d1fb58abf
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@theqtcompany.com>
2016-07-18 13:17:27 +00:00
Marco Bubke
ae9962c60c Clang: Remove ClangCodeModelClientDispatcher
We always use one client and the dispatching is removing to possibility
of moving commands. Moving the client to IpcServerInterface improves the
code sharing.

Change-Id: I5f102ab7907239572534b7d4c2848abbaade69b6
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
2016-07-12 09:08:28 +00:00
Marco Bubke
c5e79f6269 Clang: Decouple ConnectionClient and ClangCodeModel*
We want to reuse the connection client in other plugins. This is the first
step, the next step is refactoring the IPC mechanismn and move it up to
the IpcServer- and IpcClientInterface.

Change-Id: I6eb6db1e9bc18232c8df350a6303afd2edc68da8
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
2016-07-12 09:08:23 +00:00
Marco Bubke
cda6e3c15a Clang: Start ConnectionClient asynchronously
The connection client can block main thread at start up. This patch is
removing the wait functions and using signals instead.

Change-Id: I847c98b095752f6a875c0365bc27361bc5bdd051
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-07-12 09:07:39 +00:00
Eike Ziller
546df37c98 Merge remote-tracking branch 'origin/4.1'
Conflicts:
	README.md
	src/plugins/modeleditor/actionhandler.cpp

Change-Id: I65c2885593b881eda94872168a3891cab9cafe71
2016-07-11 10:46:05 +02:00
Nikolai Kosjar
ed8b910202 Clang: Honor fixits own locations in ClangFixItOperation
The fixits have own ranges/locations and thus might address more than
one file.

Change-Id: I5ee59944bef588e763a91f054a60823593373a0e
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-07-08 08:22:37 +00:00
Eike Ziller
070e6235fa Merge remote-tracking branch 'origin/4.1'
Change-Id: I35ef0d667c759c959edce91569f05ebc7a8ff4d8
2016-07-05 11:28:32 +02:00
David Schulz
de9f7a8978 Clang: Adjust mangled name test to accept any output.
We get different mangled names on windows and unix. As we do not
actually use the mangled names and to reduce the maintenance for this
test accept any mangled name, as long as it is not empty.

Change-Id: Id154da430db6958eb40e5b409e5fb186778d41c1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-07-05 06:00:11 +00:00
Nikolai Kosjar
36e7f4541f Clang: Pass on file paths with native separators
libclang 3.8 seems to be sensitive to file paths separators [1]. On Windows,
this led to not updated document annotations and/or crashes after reparsing.

When passing file paths to libclang, convert to native separators.
When getting file paths from libclang, convert back.

This handles:
 * main file path
 * file paths of the unsaved files
 * -I<DIR> arguments, the resource path (for builtins) and the paths to the
   wrapped qt headers
 * included header files from libclang
 * source locations from libclang

Also, minimize the conversion in SourceLocation to a minimum by making
filePath() lazy.

[1] https://llvm.org/bugs/show_bug.cgi?id=28381

Change-Id: If5866f34a6fdc6b34b16c022d3988e8e6eae2a0a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-07-04 13:08:03 +00:00
Marco Bubke
d027cab44e Clang: Rename Ipc* in ClangCodeModel*
We want to share more functionality of the IPC mechanism and for what we
need more interface classes. But we use this names already for the
ClangCodeModel implementation. So we rename the them to ClangCodeModel*.

Change-Id: Ie320e0d3b993586a9bcc6a5aa0d32427af41202e
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-06-30 09:28:56 +00:00
Eike Ziller
69fa7a8ffb Merge remote-tracking branch 'origin/4.0' into 4.1
Conflicts:
	src/plugins/projectexplorer/runconfiguration.h
	tests/unit/unittest/unittest.pro

Change-Id: I3d327b1198df2a7e9268916af9624ce5d21195df
2016-06-28 11:42:03 +02:00
Nikolai Kosjar
05c1efd8ef Clang: Fix dot-arrow-correction for not-yet-parsed unsaved content
The issue was re-producible with e.g.:

    void g()
    {
        // Type 'foo.' as fast as possible in the next line

    }

This led to "foo->" with completion results as if there was no "foo." at
all in that line.

We relied on a correct position for
translationUnit.sourceLocationAtWithoutReparsing(), but the just typed
characters were not yet reparsed. And we do not want to reparse at that
point since takes too long. We already determine the utf8 position for
the dot character, so simply use that instead.

This completes commit 17c1325cc4.

Change-Id: I669888b5c17ee63b2aec7b16c9921f9d79e281f9
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-06-24 08:31:28 +00:00
Marco Bubke
cc804d542d UnitTests: Disable small string test
Change-Id: I508e43923efc065fce9a79edebeff79606069abd
(cherry picked from commit 505c9be9af)
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2016-06-23 12:39:14 +00:00
Nikolai Kosjar
438bd85b84 Clang: Fix updating revision number for all translation units
Change-Id: I1ad305ed081aecadde968e041f7b99a24a1c4784
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-06-23 06:29:14 +00:00
Nikolai Kosjar
b032038781 Clang: Tests: Use test data working with clang 3.6 *and* clang 3.8
The test data produces different results when it is run with libclang
3.6 and libclang 3.8. (lib)clang 3.8 will generate an error instead of a
warning and suppress further diagnostics. See below.

Use simpler test data that is agnostic to the different clang versions.

$ cat input.cpp
    class X {
	X(X&&) noexcept;
    };

    X::X(X&&) = default;

    int function()
    {
    }

$ clang++-3.6 -fsyntax-only -std=c++11 input.cpp
    input.cpp:5:4: warning: 'X' is missing exception specification 'noexcept'
    X::X(X&&) = default;
       ^
	      noexcept
    input.cpp:2:5: note: previous declaration is here
	X(X&&) noexcept;
	^
    input.cpp:9:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    2 warnings generated.

$ clang++-3.8 -fsyntax-only -std=c++11 input.cpp
    input.cpp:5:4: error: 'X' is missing exception specification 'noexcept'
    X::X(X&&) = default;
       ^
	      noexcept
    input.cpp:2:5: note: previous declaration is here
	X(X&&) noexcept;
	^
    1 error generated.

Change-Id: I6d786a8b87eb4438fa8db36540db9358181b9a5b
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-06-22 12:39:39 +00:00
Eike Ziller
4f9016e03f Merge remote-tracking branch 'origin/4.0' into 4.1
Conflicts:
	qtcreator.pri
	qtcreator.qbs
	src/plugins/android/android.qbs
	src/plugins/android/androiddevice.cpp
	src/plugins/autotest/testcodeparser.cpp
	src/plugins/debugger/analyzer/analyzerstartparameters.h
	src/plugins/projectexplorer/devicesupport/desktopdevice.cpp
	src/plugins/projectexplorer/devicesupport/idevice.cpp
	src/plugins/projectexplorer/runconfiguration.h

Change-Id: I2474d06f2309fa71210a8401846bc2ef85bebf1d
2016-06-22 11:09:32 +02:00
David Schulz
8c7913e0ba Clang: Fix compiling unittest on windows.
Change-Id: Id48d494510ee53a9e888e22a752e8210f3d4ae2d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2016-06-21 13:37:35 +00:00