Commit Graph

120 Commits

Author SHA1 Message Date
Nikolai Kosjar
69dec8a9f8 Clang: Create preamble on first parse
...now that parsing and creating the preamble is faster due to the
skipped function bodies.

As a consequence, we can remove all the extra jobs that were needed to
get an initial AST faster.

Change-Id: I79a66b8a0e8a180850af6daf353d9a679089bbb1
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-24 12:33:55 +00:00
Marco Bubke
438b5736d5 UnitTests: fix spelling
Change-Id: Ib6a94c0fac5fe6ead62a440dbe8c6368cfd7dd57
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-04-12 14:38:51 +00:00
Marco Bubke
4b0bcbdcb6 Clang: Locator filter for the symbol database
There are no symbol queries for the locator filters. The signature
generation is still not implemented but for simple cases it should work.

Change-Id: Ic6b04fbe1e7e057892f194ac139615c47d6ec33f
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-04-12 13:12:24 +00:00
Marco Bubke
53454b0f79 Clang: Use PCHs for indexing
As generating the AST is quite expensive it would be very useful to cache
the not changed include. So we generate PCHs for include outside of a
project part. With this change this PCHs are used by the indexer.

For that they are save to the symbol database by the PCH manager and when
fetched by the symbol indexer.

Change-Id: I7a5b07cfb32d72d50dc52d2b108cd41727a7bfc7
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-03-22 13:26:24 +00:00
Marco Bubke
73963cc9c7 Clang: Add time stamp based filtering for project parts
The source ids are now filtered by the modified time. If the modified time
in the database is older than the modified time of the file it will be
parsed. If it is not newer it will be not parsed.

Change-Id: I4ade3443dd66573ac88053a2cafa600e54cfe973
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-22 10:24:59 +00:00
Marco Bubke
b5c3d5a40d Clang: Improve ProjectPartArtefact
Empty strings were only handled by accident and wrongly formatted ones
were never handled. Now we do nothing for empty strings and throw an
exception from wrongly formatted strings. The exceptions are very helpful
in the test code because the show errors the the testing data.

Change-Id: I87d1678eda7502fdc3f74f51fad491803d28582b
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-21 14:17:09 +00:00
Ivan Donchevskii
d01b474b46 Clang: Refactor TokenInfos
Remove code duplication.

Change-Id: Ib1859f2c3a04f66d0f0b669b4e93a7fc06ab8e61
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-02-12 08:03:47 +00:00
Marco Bubke
0f8befacd3 Clang: On the road to update and preprocessor support
This patch has grown in a quite big change set and it is really hard to
divide it in different parts.
V2::ProjectPartContainer is now using FileIds instead of file paths. This
cleans code up because it is a big step in the direction that internally
only file ids are used. But it is depending on the file cache, so the
file cache has to be provided as an argument. There is now an interface for
transactions too which are ease the testing of them and enables the support
of preprocessor. It adds macros as symbols and is saving used macros. The
used macro support is enabling update improvements because only if a
changed macro is used it needs to be recompiled. This is still in flux
and can be changed in later patches.

Change-Id: I492a2c9af1201d40fdd9f46a0045f7878bbbaa3d
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-29 13:47:09 +00:00
Ivan Donchevskii
92cdfc0c2a Clang: new empty locator filter classes
Introduce classes to replace builtin locator filters.

Change-Id: I5cc6f15fb0f59ea8a51b14a86301cf219cc0d6d6
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-01-24 11:48:42 +00:00
Eike Ziller
115afed94b Merge remote-tracking branch 'origin/4.6'
Conflicts:
	tests/unit/unittest/gtest-creator-printing.cpp
	tests/unit/unittest/gtest-creator-printing.h

Change-Id: I43d2571617bfbf41c0fcf23502ab77975540eba4
2018-01-17 09:30:57 +01:00
Nikolai Kosjar
76c25bcd6a Clang: Provide tooltips
This includes also the query data for the help system (F1) for an
identifier under cursor.

Regressions (libclang changes necessary):
 - Function signatures do not contain default values.
 - Aliases are not resolved for/at:
   - template types
   - qualified name of a type

Fixes/Improvements:
 - Resolve "auto"
 - On a template type, show also the template parameter.
 - For a typedef like
     typedef long long superlong;
   the tooltip was "long long superlong", which was confusing.
   Now, "long long" is shown.

New:
 - Show first or \brief paragraph of a documentation comment.
 - Show size of a class at definition.
 - Show size of a field member in class definition.

Task-number: QTCREATORBUG-11259
Change-Id: Ie1a07930d0e882015d07dc43e35bb81a685cdeb8
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-01-16 15:32:15 +00:00
Marco Bubke
640575640c UnitTests: Use MockFunction instead of home grown mock class
Change-Id: Ic0cd2fb7d073e8cf962d98b850719f4311e9f35a
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-16 14:00:34 +00:00
Marco Bubke
98fa7cbb3f Clang: Use FilePathId in ChangedFilePathCompressor
Change-Id: I622d9196ec12c6fe6e07ef9c953586f2f40b9a5c
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-10 12:37:37 +00:00
Ivan Donchevskii
affc652b7b Clang: Rename HighlightingMark to TokenInfo
Before adding additional members into that class it
makes sense to rename it to better represent its content.

Other classes serving the same purpose are also renamed
to keep the names consistent.

Change-Id: I3c8517e42aae29779d71ec9c85b713cff581a473
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-12-11 15:00:24 +00:00
Marco Bubke
b5fdfe46c5 UnitTests: Cleanup Diagnostic test
Change-Id: Idf7d50ad15862508c2d57167f2147389e3bacba4
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-12-05 10:26:18 +00:00
Marco Bubke
409fecd3a0 UnitTests: Cleanup SupportiveTranslationUnitInitializer test
Change-Id: I0c43baeb13fe2a1004622267deb4e588f941d254
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-12-05 10:26:06 +00:00
Marco Bubke
f70bf3d2d1 Clang: Move QLocalServer in ConnectionClient
Before the QLocalServer was in the ConnectionServer so more than one
client could connect to the server. But we never used that possibility
which made the hand shaking much more difficult. It is now moved
in the client, so that there is always a QLocalServer.

Change-Id: Ifa357074b0c0809434c49d23b1cee38496f72f43
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-11-28 15:08:58 +00:00
Marco Bubke
3f12a33bcb UnitTests: Remove duplicate
Change-Id: I5c409cce070a9f02515750139fd87b44d734979f
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-11-23 12:45:31 +00:00
Marco Bubke
a15250051d Clang: Handle native file in the file cache
Different types are introduced for normalized and native file path. So the
compiler is warning you if you try the wrong format.

Change-Id: I1da0686b142cbf9bb7578468c2b50f90a94cebf9
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-11-23 11:55:15 +00:00
Eike Ziller
7f626b1182 Merge remote-tracking branch 'origin/4.5'
Change-Id: Iceaa4ca40b5318744bde8a76c6d3ccca08df71bb
2017-10-25 16:07:21 +02:00
Marco Bubke
68589a3fbc Disable GCC warning for noexcept
GCC >= 6.4 is generating warnings for function signature with noexcept. In
C++ 17 noexcept is part of the function signature. But the warning is
catching cases where a changed signature is not a problem, because it is
a template it self.

Task-number: QTCREATORBUG-18959
Change-Id: Ia6fa79c10e16d8c96a53c849ea15dcec94538fbe
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-10-24 14:24:08 +00:00
Ivan Donchevskii
050b4dd2f5 Clang: implement findUsages with existing index
Functionality is limited to the abilities of
current index which is not updated and is
generated only at project open.
Search box temporarily doesn't allow to "Search again".

Change-Id: Id1047f27ad0aafc901f06aa51ad38ceab95eaebb
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-10-24 10:46:52 +00:00
Marco Bubke
b9d268977e Clang: Add usage functions to symbol query
Change-Id: If68a5119c863e616fea40275136d028abcf441f3
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-10-23 18:13:44 +00:00
Marco Bubke
2a41031273 UnitTests: Add utility functions for test
Having a global temporaryDirPath makes changes much easier.

Change-Id: Iec92bba7b7eca5b0e893ebee9f457734deba8cc8
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-10-21 13:39:31 +00:00
Marco Bubke
d2e15e5f1e Clang: Add file cache
The database is using file path integer ids to handle file paths because
otherwise we would save many redundant data. This patch is improving it
further with the introduction of a database based file path cache. The
entries are now divided in a directory path and file name. This is quite
handy for directory based file watching.

Change-Id: I03f2e388e43f3d521d6bf8e39dfb95eb2309dc73
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-10-05 17:36:37 +00:00
Marco Bubke
2df9a99cac Clang: Add RefactoringDatabaseInitializer
We moved the creation of the tables and indices to an extra class which can
be called from other places. So you can be sure that a database is
initialized.

Change-Id: Ief5b30ced7b9011ca94367aa2578098423dcecd9
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-09-20 10:45:07 +00:00
Marco Bubke
623135592c Sqlite: Add locking for sqlite transactions
If you use the database in a multi-threaded environment, you must always
your statements in transactions.

For read-only statements, you use DeferredTransaction and write statements
you use ImmediateTransaction. If you mix read and write statements you have
to use ImmediateTransaction. Don't use DeferredTransaction because it leads
to undefined behavior.

Change-Id: Ida298a20f33423c8da09e768a7b658dd8e918f46
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-09-20 10:44:37 +00:00
Marco Bubke
c870199823 Sqlite: Don't use the lower level interface of the statements
We now have the very powerful write and read methods, so using the low
level interface leads only to stupid errors and prevents optimizations.

Change-Id: If2340833977935cb2d319735dee96b0bac33142b
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-09-20 10:44:15 +00:00
Marco Bubke
53f68fd86f ProjectExplorer: Remove test for Macro
Under windows the signature for private and public member are different. So
the hack to make private members public is not working. The other method
to use a macro project macro header is not wanted.

Change-Id: I25a3f4a8645394ba6b49a7d4778adab90155f892
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-09-18 09:38:08 +00:00
Nikolai Kosjar
d1799b9aa1 UnitTests: Fix build with QTC_NO_CLANG_LIBTOOLING
Change-Id: Ia2c5b9cf617e56f09bf334bdd57e58bf96c838b1
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-09-15 09:59:46 +00:00
Marco Bubke
b6e12f4a1c Convert macros from plain QByteArray to a vector of structs
The old code model expected the macros as C++ formatted text
("#define Foo 42) but newer targets like the Clang codemodel expect key
value arguments like "-DFoo=42". So instead of parsing the text again and
again we use an abstract data description.

Task-number: QTCREATORBUG-17915
Change-Id: I0179fd13c48a581e91ee79bba9d42d501c26f19f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-09-14 15:23:56 +00:00
Marco Bubke
3adb71d45e Clang: Add Symbol Indexing
It is a first step and now a database is generated if you start QtCreator.
Some code is now shared with the PchManager which can be improved in the
future.

Change-Id: Ic267fe7960f6c455d91832859a673ce98f269aa2
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-09-14 13:39:55 +00:00
Marco Bubke
07f9f8da9d UnitTests: Fix wrong file name in pro file
Change-Id: Ibef9b5010815409e4a82453175c63c48dd3a2f15
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2017-08-30 19:59:32 +00:00
Marco Bubke
a307ee7444 Clang: Add SymbolQuery
Change-Id: I5cb81dffd6f1fda6bdcba0eedaf79f0bc91348b5
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-29 16:37:37 +00:00
Marco Bubke
f49a1d721c Clang: Add symbol storage
Extend file path cache to 64 bit integer.

Change-Id: I5627f13d59a3214f389087038482cbcc8d0eb484
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-29 16:37:24 +00:00
Marco Bubke
81d43b8a11 Clang: Add symbol indexer
Change-Id: I8ff879631ae022bc870431628be002903360369c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-29 16:37:17 +00:00
Marco Bubke
f0e00a8c25 Clang: Add symbols collector
Change-Id: I64c25eef8eaa6cc6c3ff09d41866972b6c7248d0
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-29 16:37:09 +00:00
Ivan Donchevskii
9c9baaac04 Clang: add unit-tests for follow symbol
Change-Id: I336fe29052237ede6f5c578daf01557400d9027c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-08-18 12:10:02 +00:00
Nikolai Kosjar
2d27c55310 Clang: Suspend least recently used translation units
...to free some memory.

The translation units of the 7 most recently used documents ("hot
documents", tracked by document visibility) are kept in memory.
Translation units of other documents are suspended and will be resumed
once they become visible again.

The resumption of a translation unit needs the same time as reparse
(since it is a reparse effectively).

The number of hot documents can be modified by the run time environment
variable QTC_CLANG_HOT_DOCUMENTS=N. Visible documents are always hot.

Task-number: QTCREATORBUG-11640
Change-Id: I68ecd2b1373e303372300203e42d90f65a4b39b3
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-08-03 08:27:32 +00:00
Nikolai Kosjar
8ca2f9d3fa Clang: Tests: Sort files in unittest.pro
Change-Id: I5473230ba9bc1b6c1a9520971d66918d545c9e5b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-07-24 15:58:38 +00:00
Nikolai Kosjar
2c9feb1f4b C++: Add tests for MatchingText::contextAllowsAutoParentheses
Change-Id: I4c2bdf55112f473770db1515bd412215685bfe04
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-07-21 11:39:32 +00:00
Marco Bubke
a31eae4d0a Clang: Add clang query pane
We now support highlighting for an example text and for the query.

Change-Id: I88c415ff871cf3e4c2d4fc83d60a8555bf0ce08a
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-07-20 13:32:39 +00:00
Tim Jenssen
72d2003082 Clang: fix double file entry
Change-Id: I3add0999df472c09a96db929fab25c1e1201d6f7
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-07-03 18:17:45 +00:00
Tim Jenssen
23cae9a9e0 Clang: Filter duplicates in clang query output
Because we can visit headers many times, we get results many times too.

Change-Id: I3bbe7d7a5d01c2580a4569bfe115f14a69edc8a7
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-07-03 09:57:57 +00:00
Tim Jenssen
dae4477cd3 Clang: Make file ids unique
Clang file ids are only unique for one query. Because we query in parallel
we have to manage our own unique ids.

Change-Id: I67d57d8b1766cab75ad252a14e57bbf9dc5fdb79
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-07-03 09:27:05 +00:00
Nikolai Kosjar
202d4a52a0 Clang: Fix build with QTC_NO_CLANG_LIBTOOLING
...caused by

  commit f5d68398d5
  Clang: Fix canceling of clang query

Change-Id: Ic48485aed1d23e1ddd2f7bc1e37a797d2c2498c6
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-06-29 09:00:07 +00:00
Marco Bubke
f5d68398d5 Clang: Fix canceling of clang query
Every AST unit is created and queried asynchronously, like before, but
we don't wait anymore but use a timer to process new sources. So the server
will not be blocked and can process other messages like cancel.

Change-Id: If0e69466c78f628190f59fd32a03cab1c3a4d0a3
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-06-28 09:15:51 +00:00
Nikolai Kosjar
a570614f3c Clang: Fix test file name
Change-Id: I27b25e4b8521aabab804812c4cc27cd41c23b46e
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-06-15 08:00:34 +00:00
Nikolai Kosjar
ca72c29462 Clang: Provide highlighting for identifier under cursor
Change-Id: I80ffe23cbcc84ab7323124581d9dd6afbe974fd0
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-06-14 12:49:05 +00:00
Tim Jenssen
681daa0d69 UnitTest: fix no "-fno-omit-frame-pointer" argument
Change-Id: I356fee73b2b50301d4cc857704a90c6dd2eddc18
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-03-06 09:34:29 +00:00