Commit Graph

99 Commits

Author SHA1 Message Date
Jarek Kobus
c7b60e7d6b ClangToolRunner: Flatten the class hierarchy
Instead of creating subclasses of ClangToolRunner configure
the base class according to the tool specifics.

Change-Id: I51b611b2375571453c7f9690499d744582f035c1
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-01-11 09:15:28 +00:00
Jarek Kobus
bf864ff371 ClangTools: Get rid of OutputFileFormat enum
This enum contains only one value now, so it's no-op.

Amends 9fc2fda07e

Change-Id: Ifa144dafb6155db93c06e3faecc40e38e464dac0
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2023-01-09 12:14:28 +00:00
Kai Köhne
56baf8c058 Remove GPL-3.0+ from license identifiers
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...

While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only

Change was done by running

  find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;

Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 11:15:13 +00:00
Jarek Kobus
2a2455a6fa Don't call FutureProgress::setKeepOnFinish(HideOnFinish)
This is the default behavior so no need to set it explicitly.

Change-Id: I7248a7a3890fa7fd947b8e42fccc70383d46ca3a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-05 14:26:03 +00:00
Christian Kandeler
8b49b091f7 ClangTools: Run clang-tidy and clazy separately
They are two different tools and should not have been merged into a
single runner in the first place.
People can now actively decide to run clazy if they really want to,
rather than getting confronted with its increasingly irrelevant
complaints by default.
We keep the common settings widget for now.

Change-Id: I3c2b1db8c07ff5c128700d4a1deefd710967568a
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-12-15 14:22:30 +00:00
Marc Mutz
8eb4d52342 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.

Task-number: QTBUG-99313
Change-Id: I88edd91395849574436299b8badda21bb93bea39
Reviewed-by: hjk <hjk@qt.io>
2022-10-07 13:47:53 +00:00
Eike Ziller
57745407de Clang/C++: Use qtcEnvironmentVariable* instead of qEnvironmentVariable*
And instead of qgetenv.
Takes Qt Creator's setting at "Environment > System > Environment" into
account, which makes it easier on some platforms to set them (e.g.
macOS), can be configured differently in different settings paths, and
potentially can be changed at runtime (depending on usage).

Change-Id: I7678b8e429b5eff79f87eb637f6f2131be43d904
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-08-29 09:12:20 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
Jarek Kobus
3071524607 ClangToolRunWorker: Avoid using sender()
Change-Id: I299fa6464b77aed3852d3b5a7ce4817678d5f369
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-07-22 10:56:59 +00:00
Jarek Kobus
683ad910b8 Drop Qt5: Clang, QBS & Valgrind: Get rid of QOverload
Change-Id: I86697f07a8dce5674d6e748bce807df59b773227
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-07-20 13:13:27 +00:00
hjk
17ee387756 ProjectExplorer: Dissolve a few uses of Runnable
Change-Id: I71b8f1b00e488360e7f9c136912bc64b5a76609a
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-05-30 14:10:59 +00:00
Christian Kandeler
ad8db12de9 CppEditor: Make CompilerOptionsBuilder take the actual clang include dir
This is more clear than passing in version and fallback path and
calculating the real path from them somewhere down the line.
No functional changes for now.

Change-Id: Iae2fc8015c778d787ed6e0ce898f41a7a05b2607
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-10 10:41:50 +00:00
Christian Kandeler
284817fae6 Merge CppTools into CppEditor
There was no proper separation of responsibilities between these
plugins. In particular, CppTools had lots of editor-related
functionality, so it's not clear why it was separated out in the first
place.
In fact, for a lot of code, it seemed quite arbitrary where it was put
(just one example: switchHeaderSource() was in CppTools, wheras
switchDeclarationDefinition() was in CppEditor).
Merging the plugins will enable us to get rid of various convoluted
pseudo-abstractions that were only introduced to keep up the artificial
separation.

Change-Id: Iafc3bce625b4794f6d4aa03df6cddc7f2d26716a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-01 14:53:58 +00:00
hjk
f29bc8c787 ClangTools: Proliferate use of FilePath
Change-Id: I3eb16546a729ab01c10e37572adac9aef83f5cd4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-18 11:43:30 +00:00
hjk
52e5023bcc ProjectExplorer: Use Utils::CommandLine in ProjectExplorer::Runnable
Change-Id: Id965f1f9047dcbc3ea5c9ddaa550d12668cf8ae6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-13 15:04:30 +00:00
Christian Kandeler
33108795d6 CppTools: Turn some classes into pure value types
ProjectInfo, ProjectPart and ProjectUpdateInfo used to carry pointers
to Project and/or Toolchain, even though they were used in contexts
where these pointers were either unsafe to access or not guaranteed to
be valid anymore, which made their use difficult and error-prone.
We turn these classes into pure value types by copying in all relevant
information before the first async operation takes place.

Fixes: QTCREATORBUG-25678
Change-Id: I1914b0dbda6c7dfba6c95e5e92f2d69977755590
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-08-13 12:35:49 +00:00
Robert Löhning
cd0a140bde Improve translatable strings
Change-Id: I0104209bb0f865a48f9ca2524f62457f7524bba9
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2021-03-25 16:53:40 +00:00
Alessandro Portale
e4f260d544 ClangTools: Use qAsConst with non-const Qt containers in range-loops
Change-Id: Id9df0a27c4bcba57ee76574e32ca53cb6c28a43d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-02-17 11:19:15 +00:00
David Schulz
8f4be88eea ClangTools: prevent creating duplicated diagnostic marks
If we already have marks from the analysis for the open file we do not
need to create marks for the explicit analysis.

Fixes: QTCREATORBUG-24955
Change-Id: Id550566c6e9a2dbd4e4eb3e9b9460a7778e39a50
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-11-24 12:48:31 +00:00
Jarek Kobus
6b588d7227 Remove unused variables
Mark some of them with Q_UNUSED, since it looks like
sometimes the copy is done on purpose, to force detach
or used for some hack with memory management.
In one case make unused variable used again.

Change-Id: I3825cd3399fa63bf6e12173c64509287d4a125e5
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2020-11-20 13:58:46 +00:00
Christian Kandeler
7b6ab79f3e ClangTools: Do not include our wrapped Qt headers
These are only necessary for the code model and can prevent clazy from
finding certain issues.

Fixes: QTCREATORBUG-24845
Change-Id: I04ba6703812918c39ebbde1dbac5af85fe18622d
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-10-28 12:44:34 +00:00
David Schulz
e176958da1 ClangTools: Add automatic clang tool runner for open documents
Fixes: QTCREATORBUG-23349
Change-Id: I81197180c9d69c7df6184f8fcbf05f2256eaf7f6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2020-08-28 07:20:32 +00:00
Christian Kandeler
d65ef60ea2 clang: Fix include/resource dir confusion
The getClangResourceDirAndVersion() function in ClangTools could return
the actual resource dir or the include dir, depending on the input. This
mistake happened because of misleading names spread all around the code.
Now the function returns what it says, and the other names are accurate
as well.

Change-Id: I0a8600857ee7b9fafb16256e0d1ad203ac3273d2
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-08-24 10:18:30 +00:00
Nikolai Kosjar
8cb74f88f9 ClangTools: Use resource dir from tool instead of hard-coded one
This makes it more likely that using other clang-tidy and clazy binaries
than the ones shipped with Qt Creator will work.

Done-with: Nikolai Kosjar
Fixes: QTCREATORBUG-23672
Change-Id: I8c44e037ca8d50505fe10032034edaf4f408d52c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-19 13:11:53 +00:00
Eike Ziller
227904d4a6 Merge remote-tracking branch 'origin/4.12'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri

Change-Id: Ic39945a0e3e140a9467b4b4f572929257ff3a324
2020-05-26 09:00:05 +02:00
Nikolai Kosjar
aa1caac270 ClangTools: Fix referencing wrong counter for summary text
Fixes: QTCREATORBUG-23585
Change-Id: Icb3002434a728bd0d157190b7079b35bb639d0df
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-05-22 08:42:30 +00:00
Nikolai Kosjar
9fc2fda07e ClangTools: Remove dependency to libclang and custom clang binary
Before this change, we've invoked a custom clang binary that had clazy
statically compiled into it. The invocation also ensured that the
diagnostics were serialized to a file, so that libclang could be used
afterwards to read them.

As the clazy-standalone executable supports exporting diagnostics to a
YAML file now (just as clang-tidy) and Qt Creator ships it already, rely
on that executable alone instead of the clang/libclang combo.

While we do not depend on any clang header or library at build-time now,
the CompilerOptionsBuilder constructor still needs the CLANG_VERSION and
CLANG_RESOURCE_DIR pieces from llvm-config. This dependency should be
removed as next.

Change-Id: I4fa5753ab09008fd24bc5247b28c4836b5e8ca45
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2020-05-19 12:28:49 +00:00
Eike Ziller
995ba78fae Merge remote-tracking branch 'origin/4.12'
Conflicts:
	src/plugins/cmakeprojectmanager/tealeafreader.cpp
	src/plugins/cmakeprojectmanager/tealeafreader.h
	src/plugins/projectexplorer/miniprojecttargetselector.cpp

Change-Id: I88d85be3903f57a55fddb7901e771a4822db1b85
2020-03-04 08:15:50 +01:00
Andre Hartmann
d76a2f4fcd Deduplicate elapsed time formatting
While it's nice to see my code spreading,
I still prefer to have it at one place.

Change-Id: I7bdb13c47ed7e96227deeb14b0a8070aa40148de
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2020-02-29 18:21:47 +00:00
hjk
3f68292dbe ProjectExplorer: Introduce ToolChainKitAspect::{c,cxx}ToolChain
Special accessors to the repeatedly used C and C++ cases to denoise
and slim down user code.  Plus some code cosmetics nearby.

Change-Id: Iba4662bd4731d8c4256e658529f39d5c995691ce
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-02-19 15:59:12 +00:00
Christian Kandeler
5cebf2a79a ProjectExplorer: Move some build-related code to BuildManager
The projectexplorer.cpp file is a huge mixed bag, which could use some
cleaning up. The queue() function is very much related to the
BuildManager, so move it there.

Change-Id: Ibc6425cc27d44514803a5e7c6139f83ddd760382
Reviewed-by: hjk <hjk@qt.io>
2019-12-19 17:35:46 +00:00
Nikolai Kosjar
07490e76de ClangTools: Print elapsed time on finish
...as this is useful to know for some bigger runs.

Change-Id: Ib4cc68ea4a3bed21ac7e632213e92e26be03d978
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2019-12-04 14:08:33 +00:00
Nikolai Kosjar
ab47d562a1 ClangTools: Provide more information if plugin tests fail
Print the error text we are showing in the info bar. For example:

  QWARN  : ...testProject(simple.pro) Error: Failed to build the project.
  FAIL!  : ...testProject(simple.pro) 'finishedSuccessfully' returned FALSE. ()

Change-Id: I7df91909dc4974a2c3aa9d44cb7511222517198c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-12-04 14:07:36 +00:00
Nikolai Kosjar
ccc81cc760 ClangTools: Clean up handling of output files
Do not remove the output files after the runner invocation since they
will be removed later anyway due to the use of a temporary dir.

For debugging, allow to prevent deleting the temporary dir. This allows
easier inspection of the actually generated output files and also
enables us to import the diagnostics again without actually running the
tools.

Change-Id: I39e04d6debc2ffa5c15e836729a4b7c7d8a3798c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2019-12-03 13:24:35 +00:00
Nikolai Kosjar
fbd350f31f ClangTools: Introduce an info bar
...displaying status information and errors.

Change-Id: I4f86b440b28e82786299700dee572e77de7334f3
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2019-12-03 13:24:24 +00:00
Nikolai Kosjar
7bb333f15a CppTools: Add convenience functions to ClangDiagnosticConfig
Change-Id: Iebf01e1ab71dc3500cc6e492c525735f300272ca
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2019-12-03 13:24:11 +00:00
Nikolai Kosjar
7d851c12ed ClangTools: Remove pointless "Disable" setting for clang-tidy
...as unchecking the root item in the tree has the same effect.

Change-Id: I960ea2c09a71dad3b0ba3dfb38a19055653354cd
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2019-12-03 13:23:26 +00:00
Tim Jenssen
0be200e44e improve code
Change-Id: I06c7274c39f7e369d4cd9bed0c1ef77e4bc08b35
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-11-12 12:22:15 +00:00
Nikolai Kosjar
abb0babc58 ClangTools: Fix using correct run settings
Change-Id: Ibf545719bb67857c3ecaaedf2435caa15d592e03
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-10-31 14:07:53 +00:00
Leena Miettinen
3ffee8213d Clang Tools: Fix UI text
Change-Id: Ib2f6f548bbd778e585385315174f5fecb60b7f5a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-10-28 15:21:09 +00:00
Nikolai Kosjar
9fd4b25638 ClangTools: State diagnostic config on start
...in application output pane.

Change-Id: I3c630494b3e1283a2455d241cda048a89a02e9ab
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2019-10-01 14:40:56 +00:00
Nikolai Kosjar
b895dfa382 Clang/ClangTools: Separate custom diagnostic configs
Add a separate pool of custom diagnostic configs for the
ClangTools plugin. That is, the diagnostic configs in

  Menu: Tools > C++ > Code Model

are not shared anymore with the configs at

  Menu: Tools > Analyzer > ClangTools

On plugin initialization of ClangTools, move tidy/clazy related configs
to ClangTools.

Change-Id: Id06087a58b53e466a3d7bbac669550c5fbe9899d
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-10-01 14:10:28 +00:00
Nikolai Kosjar
d5bae3c1eb ClangTools: Merge ClangTidyClazyTool into ClangTool
Change-Id: Ieb6c4994ddcff9339a9cfb25c82e23dd2d2e8912
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-09-27 11:56:42 +00:00
Nikolai Kosjar
4750969c2b ClangTools: Move run settings to projects mode
Make the global run settings available per project in project mode and
thus remove the diagnostic config selection from the
selectable-files-dialog:

 * Extract the classes RunSettings and RunSettingsWidget instead of
   duplicating stuff.
 * Ensure to pick up the old settings
 * Add some convenience buttons/links in projects mode allowing to
   restore the global settings, to open the global settings and to
   navigate (back) to the analyzer mode.

Change-Id: I1b91b6f8e58a87a025774e4643c46e176b2a8885
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-09-27 11:46:35 +00:00
hjk
bcaeb73e68 ProjectExplorer: Store parts of active build config in runcontrol
... on runcontrol creation to prevent later access. Adapt some users.
There are more to come.

Change-Id: I2a3fe5eea0ada4eff7d08b79a6f49694e6962c8a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-09-24 11:20:51 +00:00
Nikolai Kosjar
1e0523423a ClangTools: Fix saving files before analyzing
...in current file mode.

Change-Id: Iae2ca9dc0ba5325f485943deb7fd93b3e9b419fe
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-09-12 13:37:19 +00:00
Nikolai Kosjar
1fad60153e ClangTools: Remove BasicSettingsWidget
This removes the

  [ ] Build the project before Analysis

from the run dialog as it seems unlikely that this option is useful per
project.

Change-Id: I65f2ae8d1e936883f27c360d5b7b518fd31cdf07
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-09-12 13:36:57 +00:00
Nikolai Kosjar
58a724b489 ClangTools: Merge ClangTidyClazyRunControl into ClangToolsRunControl
Change-Id: I162bbb9374fda0bbfc7f3db8fa245f3b5d6e73ad
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-09-12 13:36:33 +00:00
Nikolai Kosjar
342679292c ClangTools: Clean up ClangToolRunner
Change-Id: Icf0b8910ed236e48cfa775983e181491e6e9b6b0
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-09-12 13:36:01 +00:00
Nikolai Kosjar
04f9c41432 ClangTools: Add action for running on current file
Ideally, we would build the particular file before running the analyzer,
but not every project manager supports that.

For now, skip building the project for this action.

Change-Id: Ibc516c41dd0dbeb7b17b44c0ac35ae4b46ae801d
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-09-12 13:35:43 +00:00