Commit Graph

853 Commits

Author SHA1 Message Date
Ivan Donchevskii
c5a58a9cb5 ClangFormat: Add more unit-tests for if conditions
Change-Id: I4ed68fc6260bfb4b058d5714d64dfec638ae1953
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-04-03 12:48:38 +00:00
Marco Bubke
56b01f7463 Clang: Minimize reindexing
We optimal indexer is only reindexing if the index would be changed. This
patch is a step in that direction. We only reindex now if the file or
project has changed. It fixes some typos too.

Task-number: QTCREATORBUG-21150
Change-Id: I6ea1c13282fbcd70253b9b2939aed37580dbd160
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-04-02 13:08:44 +00:00
Marco Bubke
7595c9f305 ClangPchManager: Handle non generated PCHs
Sometimes we start generation of PCHs but not finish it. In that case we
should redo it at the next start of the backend process. So we now
remove the old precompiled header if we add the task to the queue.
If we successfully generated the PCH it will be set again. But if we
did not it will be read from the database and set to false.

Task-number: QTCREATORBUG-22035
Change-Id: Id53c2b4e4f501fc5ef7830558085607baa6a49f1
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-04-02 12:38:12 +00:00
Ivan Donchevskii
01a528c77a ClangFormat: Fix indentation when empty lines are involved
Unify continuation and new statement to get less false indentations.
Handle one-statement if/else as a special case.
Properly handle empty lines after
 - includes
 - preprocessor directives
 - beginning of the file
 - if/else

Fixes: QTCREATORBUG-22238
Change-Id: Ic334eeca7de47d9fcb74963d2e31711838d04bde
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-04-02 11:32:39 +00:00
Marco Bubke
6effa1822b Clang: Improve project part updating
The project part ids are now already created very early in the database.
This removes some checks because we can assume that an id already exists.
The project part are now completely persistent, so we can read them from
the database and compare them with new generated from a new creator
session. This should help to not recreate the same PCH again and again.

Task-number: QTCREATORBUG-21151
Change-Id: Iced818ff9f7431eaed3e37978087cc0a43b9afda
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-04-01 10:31:38 +00:00
Ivan Donchevskii
1b0cba38dd Clang: Fix access specifier for variables
Static members have a variable declaration kind so
we need to check their access specifiers in order to
provide proper information about tokens.

Fixes: QTCREATORBUG-22082
Change-Id: If455174bd346398a2df3499fa6cf1ea2b4e26965
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-12 14:19:48 +00:00
Ivan Donchevskii
d7eeb0bd90 ClangFormat: Reduce dummy text to minimum size
... and tweak continuation dummy text to fix the indentation
for the line with existing text inside parenthesis.

Change-Id: Iaebd2f58823fcbeed24bb7e47769af53261c18ca
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-12 10:45:46 +00:00
Ivan Donchevskii
5333331362 ClangFormat: Tweak dummy text for consecutive empty lines
If empty lines follow each other it makes sense to use
the empty comment as dummy text for all but the last one of them.

This prevents increasing indentation lengths after if (foo) when
there are multiple new empty lines inserted.

Change-Id: I4c948161b674b3af0a131bfb85e7a45a80ed3fb0
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-12 10:11:12 +00:00
Ivan Donchevskii
cb3a553583 ClangFormat: Indent closing brace on the new line
Sometimes the curly brace also requires indentation.
These are the cases when it comes directly after the
comma, for example inside the initializer list.

Lets handle such cases in the similar way we do it for
the closing parenthesis.

Change-Id: Ia0d25fa08f7224567dd41dd17f9757d9d8b27362
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-12 10:10:28 +00:00
Ivan Donchevskii
5006bfb157 ClangFormat: Simplify the dummy text for empty line heuristics
The text to fill the empty line mostly depends not on the
fact of being inside parenthesis or not but rather on the
last preceding meaningful character.

Let's check for this character and sometimes for the following
one to better understand the current context and pick the
proper dummy text.

With this behavior improvement we can better indent empty lines
inside initializer lists with empty lines inside.

Change-Id: Id2f27454ef56dfdf8c15b5efb14c4d09242908a9
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-11 10:32:23 +00:00
Ivan Donchevskii
df23fbdc89 ClangFormat: Improve dummy text guessing for empty lines
Improve detection of the cases when the empty line is inside
the parenthesis to get more proper indentation.

Change-Id: I4aa37c29b17bedcd0e4a781d12c7066e818a07f3
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-07 14:03:36 +00:00
Ivan Donchevskii
7e5e99d551 ClangFormat: Add whitespace unit-tests and fix bugs
Check that extra whitespace does not prevent the indentation
and that indentation is the same for the consecutive empty lines.

Change-Id: I04aa12c4cd31aaf07daf9320c98d2eea7afcc9a8
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-06 14:24:07 +00:00
Ivan Donchevskii
35b0b44b21 ClangFormat: Enable includes sorting
Sort includes only in modes when all replacements are
used (manual indentation with "Format instead of indent" selected
and saving with "Format on save" activated).

Change-Id: I73dfa1d3211760269fe7d33a141f4d831ff65c15
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-06 14:23:55 +00:00
Marco Bubke
70d4e46552 Clang: Rename ProjectParts in ProjectPartsManager
Change-Id: Ia60d78e34a296b0b379339ebc14efd0e81dc8989
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-03-06 11:27:27 +00:00
Marco Bubke
e7fd132d47 Clang: Disable warnings in CommandLineBuilder
Change-Id: I7597d57a0bb97facefb08c9c1bbe6e909c146080
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-03-06 11:24:45 +00:00
Marco Bubke
3e1faec230 Clang: Don't filter source with missing includes
We do now tag and save them. So we can reliably track them.

Task-number: QTCREATORBUG-22035
Change-Id: I49aaeeb76150b7e2d77b863eeb0aedefc9ab50f4
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-03-06 11:24:28 +00:00
Marco Bubke
1a63297d9b Clang: Improve dependency building
We want to use the cached values in the database because it is faster than
to parse the the files again.

Task-number: QTCREATORBUG-22035
Change-Id: I7ada7073887b1d89a06332fdb617701cb69ccd68
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-03-06 11:24:20 +00:00
Ivan Donchevskii
ad8cabdf45 ClangFormat: Do not remove empty lines while only indenting
Insert dummy text into empty lines also for the electic characters
not to remove empty lines when only indentation is intended.

Fixes: QTCREATORBUG-22050
Change-Id: Ife5374459feb510a0587880a6772c90a2d68d70e
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-06 08:44:22 +00:00
Ivan Donchevskii
2484a5e209 ClangFormat: Do not apply "smart" formatting before new lines
In the concept that behavior seemed fine but in practive it
looks quite strange.

Add comma to the dummy text inserted into the empty line to have
a proper indentation for the following empty lines.

Change-Id: I770af02a475e6489bdc8f44d9f84eb3c5e7398d7
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-05 13:06:30 +00:00
Orgad Shaneh
495f98b256 UnitTest: Add missing enum
Amends commit f009dad9ef.

Change-Id: I5288297525edc153c1aea81d2cabb1f230a8fcce
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-05 12:19:35 +00:00
Marco Bubke
0c177cd0d1 Add ICore::cacheResourcePath()
We need some directory where we save the index database and the precompiled
headers. This files should be persistent but the user can delete them
if he wants because we will rebuild them.

Task-number: QTCREATORBUG-22012
Change-Id: I9f25eb48a9992d6385a96427ef9c10bc739a3567
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-03-04 16:43:09 +00:00
Marco Bubke
2358415b58 Clang: Move fetchPrecompiledHeader to PrecompiledHeaderStorage
It went for historical reasons in the symbol storage.

Change-Id: If05edb868901884f3951d0eb2f152566e99b4d1a
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-03-04 13:40:39 +00:00
Ivan Donchevskii
8a93074d0e ClangFormat: Fix the indentation for lines starting with ')'
Fix the insetred text position for such cases.
In the 'smart indentation mode" do not indent empty lines above
the current one but apply the formatting for them instead.

Change-Id: I4cfe7f9778bac5e311aa339e2fcfc717f436cb20
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-22 13:05:18 +00:00
Marco Bubke
f009dad9ef ClangPchManager: Show extra progress for dependency building
Task-number: QTCREATORBUG-21956
Change-Id: Id244c9ef9fc7825489daa143b21fcca78164d8c7
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-22 12:09:09 +00:00
Marco Bubke
8c781f7e6a Clang: Fix progress bar
Sometimes the messages are not send immediately, so we force it.

Task-number: QTCREATORBUG-21957
Change-Id: I9526cb4b4e3dd8b7a02e15f77bffdc51917d47c8
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-22 12:09:00 +00:00
Nikolai Kosjar
61775a844e Clang: Build clangformat only if clang/Format/Format.h exists
...in the LLVM_INSTALL_DIR.

Change-Id: I974f32759bca7fb467524bf61ff7967098748f0e
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-21 09:10:03 +00:00
Nikolai Kosjar
56584b1dde Clang: Fix unit test build without QTC_ENABLE_CLANG_LIBTOOLING
Change-Id: Ifa6588d1427489e8ae98ea8093d5d94049c270ee
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-20 13:20:56 +00:00
Ivan Donchevskii
2c6bda5950 ClangRefactoring: Map unsaved files with non-native paths in ClangTool
Otherwise the ClangTool complains that it does not see them.

Change-Id: Ib616058584f8f95229213224cec98fa6b6f7522b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-20 13:20:31 +00:00
Ivan Donchevskii
d3ceb9ce62 Unit-tests: Fix the debug build with MSVC
Change-Id: I99fd6db6406b088cab0538b07cd20ca1427a5f71
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-19 15:22:04 +00:00
Nikolai Kosjar
0f8612f20f Clang: Move unexported classes to Internal
Change-Id: I3ea197b734f146d4b11431aaf927aed9be7d8756
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-19 14:09:43 +00:00
Ivan Donchevskii
be65a57935 ClangFormat: Fix unit-tests
Amends dcf763c7ee.
Change the logic in empty lines modification to properly
indent all empty lines.

Change-Id: Id945cf66915dfd192216660543594a7905426761
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-19 12:47:22 +00:00
Ivan Donchevskii
29492ecf24 ClangPchManager: Do not build pch and index inactive project parts
Some project parts should not be built as well as some files
can be inactive inside project part.
We should not try to build pch-s or index them.

Change-Id: I8e62365b817a424ae38a0df94b6703820a4cde9d
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-19 07:34:19 +00:00
Ivan Donchevskii
7f461b2e22 ClangFormat: Clean up some code and and few unit-tests
Check the context related stuff and remove the restriction
to format after the stream operator.

Change-Id: Iaa2d32c9bffe7a0eeb7e8ade39f109b529e1eab0
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-19 07:33:20 +00:00
Ivan Donchevskii
9bcc871ece ClangFormat: Format multiple text ranges at once
'reformat' function in LibFormat accepts mutilple ranges.
Let's provide the ranges for the same file together when
formatting on save and formatting after fix-its.

Change-Id: I27789da83a1efc27beb57acf238508a191562bb9
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-19 07:33:13 +00:00
Marco Bubke
1ce0db8270 ClangPchManager: Filter system include search paths
We want the include paths from outside the project handled as system
include paths. This is speeding up the PCH creation.

Task-number: QTCREATORBUG-21955
Change-Id: Ic80102f46f5a14897c7ef43da5efd4c0f88abbbc
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-18 14:30:15 +00:00
Marco Bubke
337155a648 CppTools: Add project directory filter to HeaderPathFilter
For the indexer we want to filter every not builtin include search path to
as system include search path which is not inside of the project or build
directory.

Change-Id: I33663a1f3eb53ec39d5b16a8ca64b57d1b57bd9c
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-18 14:30:02 +00:00
Marco Bubke
35c9e65d3e Clang: Disable min and max macros
Change-Id: I75f930053ca514dbd32366c628e7e4916ba8550a
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-18 12:42:00 +00:00
Marco Bubke
2bd0c7c276 ClangPchManager: Don't watch generated files
Task-number: QTCREATORBUG-21983
Change-Id: I80af39278140c48c8740c83af85596d3ee9bf2da
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-18 12:41:40 +00:00
Marco Bubke
3154002fb6 ClangPchManager: Fix PchTaskMerger
We forgot to remove the duplicates for used macros.

Task-number: QTCREATORBUG-21955
Change-Id: I051b8199ba5dd0a173d80c9e526bf745d3bcd777
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-18 12:41:28 +00:00
Marco Bubke
716a96a55b ClangPchManager: Add dependency building to progress counter
Task-number: QTCREATORBUG-21950
Change-Id: I409b03d53b374c5bf66ba6c7c9e50e98a7b239c4
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-18 12:40:58 +00:00
Ivan Donchevskii
29758d8364 ClangFormat: Add missing .clang-format file for tests
Change-Id: Ia15b4d7c4546be2375807b1d59b5e3d65b06ab4f
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-18 12:26:50 +00:00
Marco Bubke
a33bce9e91 Clang: Fix command line builder
Add "-nostdinc++" only for C++.

Change-Id: I21228fca80045b040877328f41ca0edb4f227fcc
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-14 10:09:38 +00:00
Christian Stenger
5e1167facd Tests: Fix contradicting declarations
Change-Id: I684bad06ff0f1dbc6375da96457135d6f7287120
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-13 13:58:40 +00:00
Marco Bubke
44d5e10185 ClangRefactoring: Fix progress counter
We use threads now and the code had to be adapted.

Task-number: QTCREATORBUG-21950
Change-Id: Ie96c5bea1fa045588d0c5a8b18bfd1ccb5d9fdd9
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-12 14:02:12 +00:00
Marco Bubke
97ec6b9ad2 ClangRefactoring: Don't update the database if something went wrong
We can get an compile error. In that case we should not update the
database. In the future we should have a mechanism to report about the
database state.

Task-number: QTCREATORBUG-21949
Change-Id: I203346d536b007171f7bf255047409431c44a85a
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-12 14:02:02 +00:00
Marco Bubke
c52c531c3f UnitTests: Move symbolscollector data to sub directory
Change-Id: Id1a123f745a0f092aeff9589aa146feb49d31661
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-12 14:01:50 +00:00
Marco Bubke
ffa043fb99 Clang: Improve performance by reducing parsing
We generate one big file per project part so the preprocessor is skipping
the recurring includes.

This generated many errors about missing macros but we don't care
much about them during dependency collection step so we just
silence these errors with ignoring diagnostics consumer.

Change-Id: I5581d623b5d5f9995496252735577ea6b54790d9
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-11 15:23:26 +00:00
Ivan Donchevskii
7fe65851d9 Clang: Extend ClangTool and CommandLineBuilder
We now support source file and not only header files and the file path is
now automatically added to the end. This removes quite some clutter.

Change-Id: I74eabd262e6c7e5f4d523e3a3cd194bd3efe1ef3
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-11 15:22:58 +00:00
Ivan Donchevskii
1f804e7fc7 ProjectExplorer: Add MSVC2019 flavor support
It is promised to be compatible with prior versions.

Change-Id: I85e433382a66c82e9880401c3a983fef06c03606
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-02-08 14:04:06 +00:00
Ivan Donchevskii
dd778bcb23 Clang: Use full paths in compilation database for symbol collector
We we FilePath and NativeFilePath so that compiler warns us if we mix them
up.

Change-Id: I33d7abc7e4e724dff2a9b2b9b23deea8b358ccfd
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-07 15:03:39 +00:00