Commit Graph

2343 Commits

Author SHA1 Message Date
Tobias Hunger
1df553a683 ProjectExplorer: Rename IncludePathType to HeaderPathType
It is the type used by the HeaderPath class, so reflect that in
the name.

I also considered to rename HeaderPath to IncludePath, but
that name is reflected in a lot of users, which would also need
to be adjusted for consistency. That would blow up the patch size
for little value IMHO.

Change-Id: I51421dbd3ab8b2874dc32fc82dc394c9b93ce5e9
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-13 11:32:31 +00:00
Marco Bubke
e0b7a28333 Clang: Add refactoring project updater
The project parts are now first used by the pch manager and then notified
by the pch manager to the refactoring plugin.

Change-Id: I88074d8891cd0de9721497bbafee0deffc0b6339
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-12 14:32:34 +00:00
Ivan Donchevskii
ca84a51f86 Clang: Use clang-format for indentation
This is the new experimental plugin based on LibFormat.

It replaces the default indenter for CppEditorDocument
and applies clang-format after the CR or the set of 'electric'
characters.

Uses the global .clang-format kept in QtC settings or
the one for current project. Both can be configured.

For indentation some style modifications and code manipulations
are done to prevent line shrinking when it's not expected.

Manual indentation uses unmodified style from .clang-format file.

Change-Id: I6279b805e418e1804b553efa615f5c843f395a58
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-12 07:59:30 +00:00
hjk
e7f649a194 CppToolsPlugin: Simplify setup code
Change-Id: I4d738638aa363f66b3bbfd44f866eb8fa48fa226
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-10 09:42:39 +00:00
Marco Bubke
3abaf647d0 Add system include path to HeaderPath and merge ProjectPartHeaderPath
System include paths are appended after other includes by the compiler. So
we should set them as system includes and not as normal includes. Otherwise
we change the include order. Headers in system include paths are not
cluttering the screen with unwanted warning and by the way improve
performance too.

ProjectPartHeaderPath was a dopperganger of HeaderPath, so we merged them.

Change-Id: I7c394b4098b697de79761499ffcd5913cc02d652
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-09-10 09:31:32 +00:00
Ivan Donchevskii
b23bb73bee CppTools: Do not auto-trigger completion after '{' and '(' in the new line
There's no token before the first symbol in the line.
With no information it's better to avoid triggering
automatic completion after the first token.

Change-Id: I9d3aca3bf72485c6eca6e03d9b8691abf0492bcc
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-03 08:30:24 +00:00
Ivan Donchevskii
8b6a16c95b Clang: Fix completion after '{'
Follow-up fix for 8d0391a4f9.

Do not complete after '{' coming not after an identifier.
Take constructor completions only for '{' and function
completions only for '('. Filter constructor completions by
class/struct type.

Task-number: QTCREATORBUG-21004
Change-Id: I7ae2d6bee23cf907648c42b93eb12742942833f6
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-30 13:36:52 +00:00
Ivan Donchevskii
efe7c56e62 Clang: Do not add -undef to ClangCodeModel arguments with clang-cl
Clang-cl behaves similar to MSVC and the parsing is more proper
without -undef specified.

Change-Id: Iee37fca3401000edb3e77e8a99dcb85ae6e70ab3
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-28 10:23:34 +00:00
Ivan Donchevskii
1b4f5c0670 Clang: Fix include paths order
C++ include paths should come before Clang include
folder. Therefore parse all options for include/c++/v1,
include/c++/{version}, include/g++ and /usr/local/include.

Task-number: QTCREATORBUG-20231
Change-Id: I22c41f07d241e1e564069bb192d4fe637ff05e87
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-27 11:35:02 +00:00
Ivan Donchevskii
6652d937aa Clang: Fix excluded Clang path regular expression
Cover cases like /usr/lib64/clang/6.0.0/include

Change-Id: I015ea3535637376eeab6f737752ad13d33887190
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-24 05:46:07 +00:00
Marco Bubke
7bae47642c Add optional system include to compiler option builder
System includes suppress warnings and prevent indexing of unwanted symbols.
Using system includes for all includes outside of the project can be
quite advantageous. The rootProjectDirectory() can be extended to be set
in the project settings. An automatic generation could be possible but
could create an unwanted path which includes files outside of the
perceived project.

Change-Id: Ib9d3158f14f41efe1f6657f962d5c4437bb324b2
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-14 15:03:51 +00:00
Ivan Donchevskii
f60b035295 Clang: Add button to generate compile_commands.json
Change-Id: Iaabdcfc8d1b3463c3f6e5ce47536f9c52556eac0
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-13 13:24:12 +00:00
Ivan Donchevskii
62e776aa8e Clang: Provide include directory only for libclang
Only libclang has issues with the include directory
search therefore undefining include folders makes sense
only for libclang options builder.

Change-Id: Ie3f62f5f3a89503e6e0ab59e18889e92425c3abc
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-08 14:07:13 +00:00
Eike Ziller
847787f146 Merge remote-tracking branch 'origin/4.7'
Conflicts:
	src/plugins/debugger/debuggerruncontrol.cpp

Change-Id: I72882df605bc3fc8a8d20118fd4e49207ac92664
2018-08-07 09:42:02 +02:00
David Schulz
141f19a652 Utils: move code model icons to utils
In preperation for the language server protocol support.

Change-Id: Iee4ccd53a86d9afdb357972ea62b75ace2edcb1d
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2018-08-06 13:22:47 +00:00
Ivan Donchevskii
344cbb3a1b Clang: Move clang paths helper functions to Core plugin
These functions require core plugin so they can't go
to utils library. At the same time to use them in
ProjectExplorer plugin there are not too many choices
where to put them without introducing new dependencies.

Change-Id: I3cccccffaae8ac4bbce924fd809b5423da5dc503
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-06 12:38:52 +00:00
David Schulz
e3a0a710c6 TextEditor: fix crash while request follow symbol and typing on mac
Use a qobject_cast to prevent accessing a not available function.

Task-number: QTCREATORBUG-20910
Change-Id: If2aa6b7b120379681e9590db80904c45a6d9bd55
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-08-06 10:03:23 +00:00
Alessandro Portale
3d3f14e3fe Prefer using 'override' instead of 'virtual'
warning: prefer using 'override' or (rarely) 'final' instead of
'virtual' [modernize-use-override]

Change-Id: I6dac7a62b627fa1353b4455e1af92f869c2571cc
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
2018-07-11 16:31:35 +00:00
Eike Ziller
5c81a65422 Merge remote-tracking branch 'origin/4.7'
Conflicts:
	qbs/modules/qtc/qtc.qbs
	qtcreator.pri

Change-Id: I29916313f12e25f3942ac926f8e4d4490074978e
2018-07-05 11:14:33 +02:00
Ivan Donchevskii
ef9c68798d CppTools: Fix getting locator filters from the object pool
They are no longer inside the global object pool.
Get them from CppModelManager instead.

Task-number: QTCREATORBUG-20678
Change-Id: Ifb3221a812295e1dcfe8b59ea693a4b350cbcc2e
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-06-28 07:42:27 +00:00
Nikolai Kosjar
32614e9983 Clang: Avoid using -isystem include paths
...as this leads to file locking issues on Windows and pointless
diagnostics we currently ignore when opening files from -isystem include
paths.

The usage of -isystem suppressed warnings from system headers and
resulted in a performance boost. Nowadays we can preserve this
performance optimization by making use of the new
CXTranslationUnit_IgnoreWarningsFromIncludedFiles. This flag helps us
also to suppress diagnostics from clang tidy checks, which reported
diagnostics even for -isystem headers.

Change-Id: I33e1f7169e2ff9f17c811565a5324b9da4740701
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-06-27 12:57:57 +00:00
Eike Ziller
997f7166fd Merge remote-tracking branch 'origin/4.7'
Change-Id: Ifec1f8dc20a18f432ec6ccf68153f31fff3f8b29
2018-06-25 11:07:03 +02:00
Eike Ziller
a8c5af56a9 Remove unneeded checks for validity of mime types
mimeTypeForFile(...) is documented to never return an invalid mime type
(it will fall back to binary if everything else fails), so remove
unneeded checks.

This also removes fallback code that used text/plain in case of invalid
mime type, which is probably a relict from the old mime implementation.

Change-Id: I88ed41fa3b81704f110f9f481b0f01424a487cbb
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-06-25 08:08:14 +00:00
Ivan Donchevskii
b857762432 Clang: Remove redundant check
Excluding for __cplusplus macro is not required anymore
because we currently determine C and C++ files and do not
set this macro for C-files.

Does not break QTCREATORBUG-12818.

Change-Id: I40d5afcb9ef426a6469fb5134ec7d46438201d86
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-06-20 11:40:14 +00:00
Eike Ziller
bc02c97369 Fix that D source files should not open in C++ editor
The freedesktop.org specification for some reason makes it a subclass of
C sources, so override the MIME type as a workaround.

Task-number: QTCREATORBUG-20539
Change-Id: Ie822fd796c8b3b570ecb840412d74a12b3c1d5a7
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-06-20 07:26:59 +00:00
Ivan Donchevskii
840ab99115 Clang: Add default diagnostic configuration for Clazy
... and Clang-Tidy + Clazy.

Use stable 'level0' checks.

Change-Id: Icdcbb8807f7925bf93f8b4e11a00c2710d6693cd
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2018-06-20 07:00:23 +00:00
Ivan Donchevskii
6575cfc674 Clang: Add default configurations with Clang-Tidy checks
The first configuration contains most of checks
which make sense for most of generic projects.

The second configuration is extremely slow but plays
the role of Clang static analyzer.

For the sake of viewing these checks Clang-Tidy checks tree
is modified to be expandable in read-only mode.

Change-Id: I41c4ee26bcdf05384507427b842d61e255d59bf7
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2018-06-20 07:00:16 +00:00
Eike Ziller
3bbe535b95 Merge remote-tracking branch 'origin/4.7'
Change-Id: I3c5d7e9e8c589ad4425cd89d61e1f572f5cb7997
2018-06-19 10:03:28 +02:00
Ivan Donchevskii
e1111d4570 Clang: Use built-in follow symbol for virtual methods
ClangCodeModel currently does not provide a list of overrides.
Therefore it makes sense to use ClangCodeModel result for
virtual method only if built-in code model does not find anything.

Task-number: QTCREATORBUG-20584
Change-Id: I5b4fac7974f990e741d3438ab61827670a8ce8d8
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-15 12:15:22 +00:00
Ivan Donchevskii
75cda95039 Clang: Add option 'Build before analysis' to project settings
Diagnostic configuration Id was already there but
not the checkbox whether to build project or not.

Change-Id: Icb5fc15bda5eed5e375cd90df1a96060b30bf57e
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-15 12:14:44 +00:00
Eike Ziller
9b43b55dc0 Merge remote-tracking branch 'origin/4.7'
Change-Id: I762dbddb0f337e9a5fc4b113c7876813e9f45c9c
2018-06-11 16:01:18 +02:00
Orgad Shaneh
c62daf9cda CppTools: Do not use -isystem for header paths in the repository
Clang uses mmap for system headers. This locks the header files on Windows.

If the project file is not in the root directory of the repository, and it
uses header files that are outside its directory, but in the repository,
Git operations like checkout, rebase etc. can fail because the header files
are locked.

Change-Id: If8a258234479fc70ca0a8384bf24c68d767dbeaa
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-11 11:38:10 +00:00
Hannes Domani
168e89e0a2 CppTools: Fix memory leak of QFutureWatcher when canceled
Change-Id: Ia9cd428e3bed193167903b6ffa080e4886193789
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-08 15:48:21 +00:00
Eike Ziller
f8e88e8ce4 Fix compilation issues with C++17
Testable on Linux/macOS by changing c++14 to c++1z in qtcreator.pri.
Testable with latest MSVC2017 by setting _CL_=/std:c++17.

unary_function, binary_function, and a few other things that were
deprecated are removed in C++17.
std::string got a non-const overload for its "data" member function,
so we cannot create a function pointer on it without specifying its
type. Use std::declval instead (though it requires a default constructor
for the type).

MSVC seems to have an issue with Utils::transform for std::vector
(used in Nim plugin), but that looks like a compiler issue.

Change-Id: I94f9a93d591d55b610f86fabfc618158927d6221
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-06-05 12:04:59 +00:00
Ivan Donchevskii
4e4bd4909a Clang: Use follow symbol result from clang when global fails
When built-in code model fails to follow symbol under cursor
fall back to the clang result even if it only follows
to the decalration.

Change-Id: I22d8c5fee6ab7594b1d1b7ce8104414db28383c7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-04 08:48:33 +00:00
Ivan Donchevskii
b0c0119345 CppTools: Use cursor range for better outline navigation
Clang provides cursor range for each declaration in
symbol outline. Use that information to search for
more accurate correspondence between a cursor position
in editor and an entry in symbol outline.

For example skip indexes with not matching ranges to
prevent pure declarations from automatically become
parents of everything coming after them.

Change-Id: I0ef95c26772050cd6655e830288c46118aba38bb
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-04 08:43:44 +00:00
Ivan Donchevskii
95aa52707d Clang: Add links to web pages in Clang-Tidy configuration
Each Clang-Tidy check get the separate link except
clang-analyzer which has only a whole group page.

Change-Id: I0b63cce8475109812280d9d44ac2d36aaa66e03b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-05-31 12:43:45 +00:00
Nikolai Kosjar
89c42161fa Clang: Add "Clang Code Model" group box to code model settings page
...and move existing widgets (hints about enabled/disabled plugin,
diagnostic config chooser).

Change-Id: I3097fad30d5bbe578f0a822f6f5615e48c1595b1
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-30 14:18:03 +00:00
Nikolai Kosjar
a741b7300f Clang: Avoid diagnostics about unknown qdoc commands
Task-number: QTCREATORBUG-20512
Change-Id: Icbdcf7871738c9900544516467154ef73c595e1b
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-29 10:28:16 +00:00
Ivan Donchevskii
150d53e041 Clang: Use QFileInfo instead of QDir for clang executable path
QDir::exists() returns false for files which is not the
intended behavior.

Change-Id: I768432df93e10b3f8f570da4d94035038ff52e06
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-05-25 12:48:30 +00:00
Ivan Donchevskii
bc458c7b5f Clang: Use the tree instead of the list for Clang-Tidy settings
List of checks does not give enough flexibility to
select/unselect specific checks. The tree fixes that.

Also remove Clang-Tidy checks line edit because it is
now integrated into the tree mode as an alternative way
of providing checks by pressing "Plain text edit" button.

'cpptools_clangtidychecks.h' is generated using python
script 'generateClangTidyChecks.py' and clang-tidy
from our LLVM/Clang 6.0 build.

Change-Id: I2ed1738cb2cbbf8dac6aba563469f06f69b11593
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2018-05-25 09:59:20 +00:00
Nikolai Kosjar
90d377bee9 ClangTools: Preselect current diagnostic config
...in ClangDiagnosticConfigsWidget when clicking on the "Manage..."
button. This allows to inspect the current diagnostic configuration
without further interaction steps.

Change-Id: I732445b33f4f194c9b9b60e184d970420ab55ec8
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-23 10:48:14 +00:00
Nikolai Kosjar
a809462c91 ClangTools: Avoid warnings from Q_OBJECT, too
Change-Id: I4540c1e2d9123af12e9f96976d6e37fe25aaf728
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-23 10:48:06 +00:00
Nikolai Kosjar
7d97f4ce2d ClangTools: Make diagnostic config combo box use full width
Change-Id: Id3cca8f93e9abe74ce959d8c443cbb8840ba5866
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-16 07:20:47 +00:00
Nikolai Kosjar
e287a7c6dd CppTools: Remove unused function
Change-Id: Ida0def5702bf17551f6e51e2715cee36c768683e
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-16 07:16:43 +00:00
Nikolai Kosjar
9b74948a61 ClangTools: Allow selecting diagnostic config for project
When starting the Clazy/Tidy tool, allow to select the diagnostic
configuration for the run.

As a side effect, fix a race condition where the runner could end up
with no diagnostic config (removed during run) - copy the diagnostic
config instead of referencing/querying it by the id.

Change-Id: Iedafa8f31a3bbd233d65818fe8de16add1e4d443
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-15 07:26:22 +00:00
Ivan Donchevskii
53d7906061 CppTools: Merge diagnostic selection widgets together
QComboBox, QLabel and QPushButton are always used
together. Therefore it makes sense to put them in one
custom widget.

Change-Id: Ie21675530fbadd7071f2a362567dadb6f09bb68d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-05-14 09:05:37 +00:00
Eike Ziller
e7123b140e Merge remote-tracking branch 'origin/4.7'
Change-Id: I9d433fa6ce4f60a2acfbdb21da9f727cac8d7526
2018-05-14 09:52:58 +02:00
Eike Ziller
2278ebed1e Merge remote-tracking branch 'origin/4.6' into 4.7
Conflicts:
	qbs/modules/qtc/qtc.qbs
	qtcreator.pri
	src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp

Change-Id: I873a2fa112321225e7b478739fc017b01d24ce18
2018-05-14 09:44:43 +02:00
Ivan Donchevskii
f6d1d5b41e CppTools: Change QComboBox in diagnostic settings to QListWidget
ComboBox gives an impression of selecting one of
the entries which is not the case for this widget.

Change-Id: I83f94def7553d4ceaec5ba957765f4494dc3d610
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-05-14 07:03:29 +00:00