Commit Graph

827 Commits

Author SHA1 Message Date
Marco Bubke
a83d038208 Sqlite: Improve exception handling
Introducing different exceptions for different error cases.

Change-Id: I4371d1e64d9dca2a9f68dcbaa4a891c55879c1f5
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-09-20 10:43:59 +00:00
Eike Ziller
3d9cf954e2 Merge remote-tracking branch 'origin/4.4'
Conflicts:
	src/plugins/debugger/debuggerdialogs.cpp
	src/plugins/debugger/gdb/remotegdbserveradapter.cpp

Change-Id: I1ae77869887a8d9ef2a33439f2733315db9e0cf0
2017-09-19 12:10:26 +02:00
Marco Bubke
382c9647e8 Sqlite: Remove the Sqlite Prefix
We use a name space now, so the prefix is not of much use.

Change-Id: I2b077576f94dab778add6ab2e54870f7ca18da78
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-09-18 13:37:11 +00:00
Marco Bubke
76a7dff82b Utils: Simplify SmallString reserve
The reserve function is quite complicated because it is implementing a
grow pattern. Something we seldom need. So we now align to the next cache
line size.

Change-Id: I14bb88c12bd740a7afa7cd08969a4e07fb0f9add
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-09-18 10:17:11 +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
Ivan Donchevskii
a137b08eaa CppEditor: refactor FollowSymbol
Create an interface to get the ability to use
another FollowSymbol implementation

Change-Id: I5802f62523ff3ee47b8a14e487adf43edcb6c9b1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-15 14:14:01 +00:00
Ivan Donchevskii
76d12dc2d5 CppEditor: add default RefactoringEngine
..and use it when we don't have refactoring plug-in

Change-Id: Ibe317a9728d439b9c5e05271d92a330d22eaacb9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-15 14:13:48 +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
Nikolai Kosjar
f2e5e22009 Clang: Avoid waiting plugin side if (re)parse fails
If a parse or reparse operation fails, the corresponding translation
unit is "not intact" anymore and further job requests for that
translation unit will be silently discarded without notifying the
plugin. This is especially problematic when the plugin expects/waits
(for) a certain message.

A parse/reparse can fail due to e.g. an invalid commandline or an
internal crash.

In such a case, ensure to send some dummy results.

Task-number: QTCREATORBUG-18864
Change-Id: Ida9b8066fd55e64027a9b0d8bd5cf365b16a7356
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-09-12 06:46:29 +00:00
Eike Ziller
a9aac73e37 Merge remote-tracking branch 'origin/4.4'
Change-Id: I53a31b3463b2bd8efffb1c00e5d172854d8ff5e5
2017-09-08 13:06:07 +02: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
d809e3fb8f Clang: send function name position for completion
... to reuse this position in backend (instead of
searching the function start again)

Change-Id: I02818dce4fc37ed6e7ecfb533191dbfe60610204
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-08 07:37:06 +00:00
Nikolai Kosjar
88e7af8a21 UnitTests: Disable related tests if suspend-patch is missing
Change-Id: Ifdccf2e5842aff13528e52caa4dfd3288214d723
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-09-07 08:59:40 +00:00
Ivan Donchevskii
82d0650b11 Clang: fix findStartOfName handling
... of templates and qualified names

Change-Id: Ic8c2dec35cb74484f474c0c608857e7cf48c7468
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-05 14:16:04 +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
890e2bd517 Clang: Fix tests
Change-Id: Ic6e8da5c7db0cfa325774640fe1202845d7b3e00
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-30 08:56:10 +00:00
Orgad Shaneh
139792ee25 Merge remote-tracking branch 'origin/4.4'
Change-Id: I9ab2c68d2bd07b0dd89051a2f5f6fa51676d8594
2017-08-30 01:24:11 +03:00
Marco Bubke
efcfb5ee15 Clang: Improve file path caching
The old algorithm was comparing the string two times. One timer for smaller
and one for larger. And memcmp on a long string still costs. The new one
has a three state so it can compare smaller, greater and equal in one.
There is a reverse version too which has big advantage for file paths.

Change-Id: Ica4024f0a071803c697e2c1f26edd3eb1b203f9f
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-29 16:37:43 +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
Marco Bubke
8640ef1927 Utils: Convert to SmallStringView for comparison
Change-Id: I38d9716225b81091e8e75b26c9c2258a2aefa987
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-29 16:36:57 +00:00
Marco Bubke
7c0331ab93 Clang: Rename library clangbackendipc to clangsupport
We already share same classes there which has nothing to do with IPC and
I want to more for sharing. So we should use a name which fits better.

Change-Id: Idfb12b6de714206117b92634ad719c6a0e290e78
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-29 16:36:35 +00:00
Marco Bubke
1a25b61576 Sqlite: Improve Sqlite wrapper
It is now possible to read values at once.

for (auto [name, value] : statement.tupleValues<String, int>(1000, "foo", 20))
   ....

Change-Id: I3d4bc5218810b4620e1df625126aa490f30bbc71
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-28 14:50:33 +00:00
Marco Bubke
8617f497bc Utils: Cleanup StringCache
There is now a forward header and it is possible template the string type.

Change-Id: Ibebd32c475a2d89a90da7190e77d44278eb43740
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-28 13:47:26 +00:00
Marco Bubke
381b51c012 Utils: Add toView to SmallString
Change-Id: I242a3a8e8411dfca19e50279928f97a5623e55d4
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-28 13:46:48 +00:00
Marco Bubke
24e5dd0556 Utils: Add compare function for string views
It is more efficient to use compare instead of less and equal together.

Change-Id: I772b03ba02509c0ebc5d5d770be14cf7d5bd431e
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-28 13:46:38 +00:00
Nikolai Kosjar
f07bc467a3 Clang: Tests: Improve DocumentSuspenderResumer
* Use IsEmpty()
* Set up proper error printer

Change-Id: I9d4750f8e69e0660ece33015d439c796077d1727
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-08-24 12:52:10 +00:00
Eike Ziller
df796e2aa5 Merge remote-tracking branch 'origin/4.4'
Change-Id: Id525d68a899f2db14c2d52c200a3a2a8a4e81590
2017-08-24 13:23:04 +02:00
Nikolai Kosjar
024cfda06c Clang: Ensure that an unparsed translation unit is not suspended
Currently this might happen when registerTranslationUnitsForEditor is
called with visible documents that are not the ones that are registered.

Change-Id: I9ae5f75c8bbff6a11161a3387633726066001062
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-08-23 14:54:45 +00:00
Marco Bubke
af73f6e572 UnitTests: Add a header to import matcher in the global scope
Change-Id: If4fad39753dc5341a82f118fcd4b8d63ea5879b7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-08-21 09:57:04 +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
Eike Ziller
d8fd5292f1 Merge remote-tracking branch 'origin/4.4'
Conflicts:
	src/tools/clangbackend/ipcsource/clangiasyncjob.cpp
	src/tools/clangbackend/ipcsource/clangjobrequest.cpp
	src/tools/clangbackend/ipcsource/clangjobrequest.h

Change-Id: Ib8602530663813ade418f995dfd2a736908cfe75
2017-08-15 10:07:51 +02:00
Ivan Donchevskii
4ad0e5295c Clang: add follow symbol infrastructure
Add messages and jobs

Change-Id: I875280216da40ce08d972024789c060205746421
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-08-15 07:32:03 +00:00
Nikolai Kosjar
c0364564a4 Clang: Fix highlighting of template function in using declaration
This completes

    commit a3a62e78f7
    Clang: Fix highlighting of function in using declaration

Change-Id: I3c163096374d7a1f45a590bb8ebfe5f5a1f8d417
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-08-14 12:46:43 +00:00
Marco Bubke
965379bc63 Utils: Don't touch the data if nothing is replace in SmallString
We called reserve for even if we do not found anything to replace.

Change-Id: I01dfbb9e8152605c01fa007eb93586f9a30cf56e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-08-08 12:30:59 +00:00
Nikolai Kosjar
9092ef7992 C++: Do not insert matching } within string
Regression from

    commit a6aa287720
    C++: Fine-tune auto insertion of '}'

Change-Id: I3ede8c7a1e3c73708d5d5a59c314e4b4596976b2
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-08-07 13:01:30 +00:00
Marco Bubke
4ae0c6782f Utils: Fix replace function in SmallString
You need to allocate the memory before you replace a smaller text with
a larger one. It has some overhead because you go two times over the text
but it is anyway not designed for a large text.

Change-Id: I2f56f1300a5daf9e26632b5b0667023a09ff4bd2
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-04 10:33:03 +00:00
Marco Bubke
45dbc743b0 Clang: Fix formatting
Change-Id: I2181639ea0725708a005898d20b74560439d4e2c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-04 10:05:26 +00:00
Marco Bubke
4c7cc99375 Utils: Fix short string capacity
The short string capacity is the data area size minus the size of \0.

Change-Id: Iffb4428bb81fc78bdc4c00218cf9f2c9ac8c25e5
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-04 09:47:59 +00:00
Marco Bubke
4cc89b97de Utils: Don't allocate new memory if it is fitting in the short string
If you call reserve on a read only reference we always allocated on the
heap which is not that smart.

Change-Id: Ib9653c6fc87bc65716a966545c13f7ecb3712039
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-04 09:32:21 +00:00
Marco Bubke
0e3dc045a1 Utils: Fix replace crash
The bug was that we returned the new end() but not the old reallocated
after a reallocation of the memory. The return value is used to move the
string after the found sub string to the next found sub string to the
new position of after the replaced sub string. Because the new end moved
more to the right we moved a much bigger chunk of memory. So we
accessed memory outside of the allocated memory.

Change-Id: I9ac276e201eabee896190da0cf0ee1d86860777d
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-04 09:05:33 +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
c2cfc62f08 Clang: Use document visibility as jobrequest conditions
This is in preparation for a follow-up change that will add jobs that
also operate on invisible documents.

Change-Id: I2a0fc3b95cc5ab2e267429134a534df64c901376
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-08-03 08:26:53 +00:00
Nikolai Kosjar
643854cb8b Clang: Fix incomplete JobRequest in tests
Change-Id: Ibbe8f2722c81393d997efb33e6b29e01fde5eee7
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-08-03 08:26:49 +00:00
Marco Bubke
98035954c9 Sqlite: Add Read and ReadWrite mode to database
We want open databases in read only mode too.

Change-Id: I3b20602d4bd7841c9fca3260edce082d21022052
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-02 11:50:26 +00:00
Marco Bubke
52a911b972 Sqlite: Cleanup table and column handling
Using values instead of pointers makes the handling much easier. We can
remove ColumnDefinition too, and use SqliteColumn instead.

Change-Id: I224db9cc569c4dfb6e2746179b02096904bfbccb
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-02 11:50:18 +00:00