Commit Graph

74 Commits

Author SHA1 Message Date
Marco Bubke
56d611e0a3 ClangPchManager: Update PCHs if time stamps of dependencies changed
If there is a newer file than the last indexing or if a file is added or
removed from the project or system PCH we have to reindex the project and
maybe the system PCH.

Change-Id: Ibce2a244190a79b5c422c469c065ddc11e44b2cb
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2019-08-27 11:50:39 +00:00
Marco Bubke
f8aad27a88 Utils: Suppress warning in SmallString
Task-nubmer: QTCREATORBUG-20541
Change-Id: I7deb64f0f7c63c07641833408596ead0f4e087b8
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-01-14 13:02:29 +00:00
Marco Bubke
3d9974db95 Utils: Fix small string
Change-Id: I6a746eb28c6c803b9ade9f626a950cf93ba6fe99
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-03 14:26:05 +00:00
Orgad Shaneh
7cee991c70 Utils: Remove superfluous qualifications
Change-Id: I36e17dac0cff87f82f0ddaf97bc613389110f218
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-07-19 08:21:29 +00:00
Ivan Donchevskii
8ea31bb1e1 Utils: Fix unit-test failure caused by SmallString issue
Failing test:
SymbolsCollector.CollectUsedMacrosWithoutExternalDefine

std::stable_partition can move-assigne object to itself
which was not properly handled in SmallString.

Change-Id: I719f3cb78cdace5fdbd9fcac3f5f099baa58a8c2
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-05-24 09:44:39 +00:00
Marco Bubke
efd9b08eb4 Utils: Remove noexcept from SmallString::append
We want to get bad_alloc. ;-)

Change-Id: Icc7995405bfb96d3f709b80e30b13c5d81fb3979
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-04-04 13:36:51 +00:00
Marco Bubke
b6cb22899c Utils: Improve SmallString
The small string control block moved to the beginning, so it is more cache
local. The control block is cleanup too, so it should be easier to read.
The alignment is removed because it is creating to big holes.

Change-Id: I401aeb9d55455cbaa5e722dd8192e54b525ddc40
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-04-04 13:34:20 +00:00
Marco Bubke
07fcd6f362 Utils: Simplify clone
Change-Id: I8b39696eee2ba8e19d827160bb80bd896491e69c
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-15 09:58:42 +00:00
Marco Bubke
2f8c075a01 Utils: Make default constructor of SmallString constexpr
Change-Id: Ibf381c9f18de878b1f67e28498cd28270e9220c7
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 14:47:57 +00:00
Marco Bubke
a572b2db6a Utils: Change SmallString::toView to SmallString::toStringView
This improves the readability of the code.

Change-Id: Ifccbaaa6003636848ea48e00d92abc44f5c2e0f1
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-22 13:22:00 +00:00
Marco Bubke
b3bed4c306 Utils: Introduce flexible constructor for SmallString and SmallStringView
If a class has a data method that returns a char pointer it can be 
used to construct a SmallString and a SmallStringView.

Change-Id: I02dcba50babb3074b58998e5f907799e84361ed7
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-22 13:21:52 +00:00
Marco Bubke
ce4d7e9d0e Utils: Fix smallstring move assignment
Before the string was simply swapped with the other string which can lead
to an unexpected behavior for xvalues. Now the destructor of the source is
called and it is default initialized.

foo = std::move(bar);

bar would now hold the value of foo.

Change-Id: Ibea3f18333a168634b7faf2fdaf9b5b52c82d5cc
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-10-20 14:36:37 +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
fc231309e8 Utils: Fix reverse iterators in SmallString
Change-Id: I859c801fdb1ad68d5943b580f07a9e8260ae192a
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-09-21 12:35:10 +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
Robert Loehning
f4a8f52b0d Utils: Use ref instead of copying large object
Change-Id: I77ea6d1e9eaf16e92ce04cc59357b2c754d76e44
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-09-14 08:40:26 +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
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
d45cd9a35b Utils: Use C string functions
They are better optimized.

Change-Id: I6db1c94d283ee9f3f1555ce02b9b42d38003e2d0
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-28 13:46:28 +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
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
f6228cae22 Utils: Improve SmallString::operator<
Change-Id: I893634dd4e95b4103f0fc822e5268cc5f95d3d4b
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-04 09:55:48 +00:00
Marco Bubke
d54db53d2f Utils: Fix spacing
Change-Id: I3c3f4e22ad64144f7ea92e671b9f582fd434b491
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-04 09:48:15 +00:00
Marco Bubke
08711525ec Utils: Clone the capacity too
It has it's advantages if the text grows otherwise we maybe waste memory.

Change-Id: Ic76d25207c2ef18182069fbf64bc0fb955a85353
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-04 09:40:09 +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
18453deafb Utils: Cleanup SmallString::replace
Improve the naming of the variables.

Change-Id: I125f3451e0e6a7437909067e9bff06cbeac111a0
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-04 09:22:04 +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
Marco Bubke
a279b55415 Utils: Fix missing initialization in SmallString
Change-Id: I9f8d7aee15c1908f89c6208390cc46d737789144
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-02 11:50:00 +00:00
Marco Bubke
1727e64349 Utils: Use string view instead of a string
This is preventing unneeded mallocs.

Change-Id: Ia1f9b1be90635e7aa8b4b6f6e6705e5671f946c5
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-01 12:40:33 +00:00
Marco Bubke
01e1f13bb9 Utils: Add + operator to SmallString
It should not be used for chained concatenation. Use initializer list
instead.

auto text = in + 'x';

auto text = Utils::SmallString{in, "x", other, ", "};

Change-Id: I453d986913eae89fd5e1f525b9f4e0c4bd089467
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-01 12:40:08 +00:00
Marco Bubke
1b14ec5056 Utils: Add number to string conversion
We use std::to_string except for integer where we want a low overhead
solution.

Change-Id: I16ce7d575d83ff56e61a5038aa7f9a1febfaf34f
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2017-08-01 12:40:02 +00:00
Marco Bubke
48b17e341c Utils: Use replace instead of transform
Change-Id: I7399308b93280d1150a24e5729aefc60e1826ea6
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-07-19 11:24:54 +00:00
Marco Bubke
1a75db12f4 Clang: Improve speed by content generation
The argument parsing has some considerable overhead. We try to avoid that
with merging all content together in one file.

Change-Id: Icf426bb5d6a5569d59c180f94c7eab66a22a251c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-02-16 17:39:05 +00:00
Marco Bubke
79e73ea4ee Fix spelling of unitttest_public
Change-Id: Id90dbfe30bb1f1c147299c4ac8cd210dbe7d8b82
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-02-03 15:35:44 +00:00
Marco Bubke
bdfb466cd2 Utils: Add replace for characters
It is much more performant to have a overload of char instead of providing
a string all the time.

Change-Id: I1a4ed82bf056f6af0c1f91c236b3fc30afa7f5d8
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-02-02 12:46:14 +00:00
Marco Bubke
a0c69c517c Utils: Fix long small string
We used only 6 bit to save the short size but for SmallString with a size
over 64 it is not enough. So we have now to use a uint16 instead of a
uint8 if the size if over 64.

Change-Id: I53558e492b6cb40b739b23a8af83d192a2e11bd2
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-31 16:12:18 +00:00
Marco Bubke
729c535376 Utils: Add intializer_list constructor in SmallString
You can now write

SmallString text = {"Oh ", women[4], " how much I miss you"};

if it can be casted to SmallStringView.

Change-Id: I86b69ee8d735017cac4391e7c4e68355eb5f227b
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-31 16:06:33 +00:00
Marco Bubke
9b4afa01a1 Utils: Improve and fix operators in SmallString
Change-Id: I51f4e647cbd3ada0c3a86d16f40fd8044acead33
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-31 16:06:28 +00:00
Marco Bubke
c02df443a2 Utils: Change SmallString::at from const reference to value
A char is smaller than a pointer.

Change-Id: Icc34b4cb3ccd4bad22e944d1e236d60f51086cfa
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-31 16:06:21 +00:00
Eike Ziller
63f66f28ac Use _t versions of various type traits
Available now after switching to C++14 and GCC>=4.9

Change-Id: I44e9859a6abe66db16d77b228466b65eadced8ae
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-30 10:46:22 +00:00
Robert Loehning
eeb0b8fd21 Revert "Revert "Utils: Remove old compiler support code""
Thomas provided a smaller fix.
This reverts commit 78fb7f44bf.

Change-Id: I1edff6477526fe4ce29df38852f47fe49117561e
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2017-01-19 12:21:43 +00:00
Alessandro Portale
78fb7f44bf Revert "Utils: Remove old compiler support code"
This reverts commit 8a32bcc5e7.

Broke build with MSVC 2015, update 3

Change-Id: Icb59b70fb00ea2a2ecc8d26c8177d21d82aaccf2
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2017-01-19 11:47:26 +00:00
Marco Bubke
8a32bcc5e7 Utils: Remove old compiler support code
We now support constexpr, noexcept and alignas on all compilers. Next will
be C++ 14 constexpr support.

Change-Id: I254049c60dcd82fc373ec907cbb5702a4b344978
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-19 10:59:40 +00:00
Marco Bubke
0011d81817 Utils: Activate copy constructor and assignment
The move only patter is quite powerful but has the drawback that some
STL algorithms get quite complicated. For short string or const references
should be not difference to a move. So we activate them for all cases.

Change-Id: I959c13796e69c45f31bb0ecbbe64a70d39961e3f
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-09 13:45:08 +00:00
Marco Bubke
023e1fa610 Utils: Add PathString to improve memory usage for longer paths
Change-Id: I90bca7eddfc4823406f1320a7f6e7836d53c3425
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-09 13:21:08 +00:00
Marco Bubke
7b6e671809 Utils: Change of less operator for SmallString
Comparing file paths can be quite expensive because the start very likely
with the same string. Sorting for size and only compare the string is less
expensive. For many algorithm we need a sort order, so making the less
operator cheaper is quite desirable.

Change-Id: I33e7abc7a65264e80376f445f8b6dcada0625ab9
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-09 13:20:40 +00:00
Marco Bubke
8088923f2f Utils: Add SmallStringView constructor to BasicSmallString
Change-Id: Ib8b92f9d39f342680f62433f8cc67d2adf1f6eb2
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-09 13:20:29 +00:00
Tim Jenssen
c191672013 Utils: Change UNIT_TEST_PUBLIC in unitttest_public
Change-Id: If60f24e3b055d543ba7864d4eb7e8287721d1012
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-09 13:20:17 +00:00
Marco Bubke
28a120b2e2 Utils: Workaround missing __cpp_noexcept in clang
Clang is not defining __cpp_noexcept.

Change-Id: Icb4e2dabb413e676614a9dd478e996d587c7f5d2
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-12-07 15:25:58 +00:00
Marco Bubke
b8e391e5f0 Utils: Fix SmallString reserve for read only references
The capacity of a real only reference is zero but the size is larger than
zero. So if we reserve memory the new capacity has to be bigger than the
size and the capacity.

Change-Id: I8b423da7e7c1cf7cee081d1b3f3464b6fb3f67cf
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-12-05 13:59:56 +00:00