aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/clangcodemodel/clangutils.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Use QString::size() instead QString::length()hjk2025-11-131-2/+2
| | | | | | | Minor gain in debug builds and when stepping. Change-Id: I2540d309661e4babfd7331b068c17657ded2a098 Reviewed-by: David Schulz <david.schulz@qt.io>
* Replace most expected_str by Utils::Resulthjk2025-04-111-1/+1
| | | | | | | | Keep it in Axivion dto, which is generated. Change-Id: I83a12de6234ac7b0218b369875bdc72d25dbadfb Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* ProjectExplorer: Dissolve kitaspects.{h,cpp}Christian Kandeler2024-11-201-1/+1
| | | | | | | Move the remaining classes into their own files. Change-Id: I301e72004c21446fa9b8f15942bb042218b0ecef Reviewed-by: hjk <hjk@qt.io>
* ClangCodeModel: Fix displaying diagnostics containing array operatorsChristian Kandeler2024-10-091-1/+8
| | | | | | Fixes: QTCREATORBUG-31670 Change-Id: Ib0fa824d46d3e4297a0bdcfb66aef94e6e510a54 Reviewed-by: David Schulz <david.schulz@qt.io>
* ClangCodeModel: Move compilation database creation to CppEditorChristian Kandeler2024-09-021-175/+5
| | | | | | | | We'd like to re-use it elsewhere. Task-number: QTCREATORBUG-29529 Change-Id: Idafd53308218932f596d57ed5c8786720c6c0314 Reviewed-by: David Schulz <david.schulz@qt.io>
* Merge remote-tracking branch 'origin/14.0'Eike Ziller2024-07-081-2/+0
|\ | | | | | | Change-Id: Ic3c53630e16712b6493873d21485b726f0d06574
| * ClangCodeModel: Allow empty project info listChristian Kandeler2024-07-051-2/+0
| | | | | | | | | | | | | | | | | | ... when generating compilation database. This can happen in session mode. Fixes: QTCREATORBUG-31186 Change-Id: Ieb081932ac2c562bacae995c7d05a3e0e96c9153 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* | Editor: remove TextDocumentManipulatorDavid Schulz2024-07-011-36/+1
| | | | | | | | | | Change-Id: Iacd7cd40ace77c79eecca3e4e699eb308d0c27de Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Editor: Simplify TextDocumentManipulatorDavid Schulz2024-06-271-4/+3
| | | | | | | | | | | | | | | | | | | | | | The TextDocumentManipulatorInterface was introduced to decouple modification operations from QTextDocument. But nowadays all tests and production code usages are backed by a QTextDocument, so we can remove this abstraction layer again. The first step is to merge the interface and all manipulator implementations. Change-Id: Idd1609df549d3b120dd516d5161af9aa8aa571ca Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | CppEditor: Clean up cpptoolsreuse.{h,cpp}Christian Kandeler2024-06-241-0/+1
|/ | | | | | | | A lot of code had a more suitable place to live in, some was even unused. Change-Id: I36478ef473aa14395a182c9ac5e3738fc93134b6 Reviewed-by: David Schulz <david.schulz@qt.io>
* ClangUtils: Get rid of GenerateCompilationDbResult structJarek Kobus2024-05-271-13/+17
| | | | | | | | | | | | | | Replace it with expected_str<FilePath>. Check periodically for cancel request inside generateCompilationDB() body. Cancel the possibly running task on ClangCodeModelPlugin destruction. Handle the cancellation. Change-Id: I8bcb956bc03627b4a17a3510a76810e66c82815d Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* CppEditor: Move ClangdSettings into a dedicated set of filesChristian Kandeler2024-03-281-1/+1
| | | | | | | | | | They were originally put alongside the CppCodeModelSettings for simplicity, but there is no coupling (anymore?) between these two classes. Change-Id: Ic24df109b74a5b5c39de073c938c6de12f4aa319 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
* CppEditor: Introduce per-project code model settingsChristian Kandeler2024-03-151-4/+9
| | | | | | Change-Id: I325cc39e60d4b1f0fba1651502d772bfb9c6a91c Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
* CppEditor: Move some convenience functions to CppCodeModelSettings classChristian Kandeler2024-03-121-1/+1
| | | | | | Change-Id: I0af8560c23374ce4f6c46f98d498d44f7cb50db3 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
* All: More ToolChain->Toolchain renamingshjk2024-01-191-3/+3
| | | | | | | | And removal of one unused function declaration. Change-Id: I594e23401d8f247d3be081ce850005574951899d Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* ProjectExplorer: Rename kitinformation.{h,cpp} to kitaspects.{h,cpp}hjk2023-08-151-1/+1
| | | | | Change-Id: I069bddeb457366210d339edcbb8ffb359a40fab8 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* More deprecation induced busyworkhjk2023-06-081-1/+1
| | | | | | | QString::count() will vanish. Change-Id: I65672fa648c0969930e9398ec4e541a0771c8a57 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Translations: Fix stray QApplication::translate() callsAlessandro Portale2023-02-081-3/+2
| | | | | | | | | For references to the module-own context, use Tr::tr(). For references to other modules, use the right context name (with "::" prefix). Change-Id: I6dce8f1ceccb23c44d93f1826402cd3be8e98e5a Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* ClangCodeModel: Tr::trhjk2023-01-191-2/+4
| | | | | Change-Id: I60aeadd38471cc65de250f66f0f09ba2931b3da2 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* CppEditor: Use FilePath for ProjectPath::m_sourceFileshjk2023-01-111-4/+4
| | | | | | | ... and update using code. Change-Id: I682727a4b2982dba388e7cc7b9488225748d591f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Remove GPL-3.0+ from license identifiersKai Köhne2023-01-061-1/+1
| | | | | | | | | | | | | | | 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>
* CppEditor: Convert parts of ModelManagerInterface to FilePathhjk2022-11-291-6/+5
| | | | | Change-Id: If7503b6d6732e1735eb8d48ece6e80886d10c647 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* CppEditor: Prevent /TC and /TP with Objective-C filesChristian Kandeler2022-11-281-4/+6
| | | | | | | | | | This is relevant when clang-cl is used to compile Objective-C projects. Task-number: QTCREATORBUG-28369 Change-Id: If8ae4dfaa07bf2ec81fbbec358663617c430b9e2 Reviewed-by: Frederik Seiffert <frederik@algoriddim.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Consider project part languageChristian Kandeler2022-10-281-1/+1
| | | | | | | | | | | | ... when creating compiler command line for header files. In particular, make sure we do not use "objective-c++-header" for Objective-C headers in a C project part. Fixes: QTCREATORBUG-28368 Change-Id: I1e5067a939e037df53a318af2b15dec7295fcd46 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* ClangCodeModel: Set actual fileKind in clangOptionsForFileAlessandro Portale2022-10-211-1/+1
| | | | | Change-Id: Iff9ad3a6135d73359d6d5cc841f23b2ec5fe332c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* ClangCodeModel: fix null pointer accessDavid Schulz2022-10-191-1/+2
| | | | | Change-Id: I2c9e4dc04b7b27986eb0a3a74d8fa6879715df87 Reviewed-by: David Schulz <david.schulz@qt.io>
* C++ support: Consider project-specific target tripleChristian Kandeler2022-10-141-3/+2
| | | | | | | | | | | | | | ... before creating project parts. Otherwise we can get wrong includes and defines from the compiler. Amends 9c86e6746fb82d6244cc2fc565d5f730c67f8106. Also do not add -m32 or -m64 for non-x86 targets. Task-number: QTCREATORBUG-25615 Change-Id: I02da9251c77d45fc8827990a2d59c3ae2c262591 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Clang: Fix compile_commands path setupMarcus Tillmanns2022-10-141-1/+1
| | | | | Change-Id: I2af0935ad022714f8e929c483455a8800e9f7cca Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-071-1/+1
| | | | | | | | | | | | | | 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>
* ClangCodeModel: Save some disk space and unneeded allocationsChristian Kandeler2022-10-071-2/+2
| | | | | | | ... when writing out compile_commands.json files. Change-Id: I8b2298eee87609a90ebb4dbd58b38bd6f36c5a7b Reviewed-by: hjk <hjk@qt.io>
* ClangCodeModel: Support setting additional preprocessor directivesChristian Kandeler2022-09-131-3/+6
| | | | | | | | | | ... for a document. This was only ever implemented for the built-in code model. Fixes: QTCREATORBUG-20423 Change-Id: Ia99d0136e9995a5626058ad06173ea077be024d8 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
* ClangCodeModel: Implement per-session mode for clangdChristian Kandeler2022-09-051-24/+28
| | | | | | | Fixes: QTCREATORBUG-26526 Change-Id: If9e018475b4e2f0557d9bf64ad9a7921c9dd6046 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
* Use SPDX license identifiersLucie Gérard2022-08-261-24/+2
| | | | | | | | | 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>
* ClangCodemodel: Avoid repeated construction of category prefixeshjk2022-08-041-7/+6
| | | | | Change-Id: I0166010a17f1f37855862f28cc9e2472b638c9de Reviewed-by: David Schulz <david.schulz@qt.io>
* ClangCodeModel: Use the correct language type options for MSVCChristian Kandeler2022-07-061-4/+8
| | | | | | | | | | This was broken by our compiler command line optimizations, resulting in "-x" rather than "/T" appearing for MSVC/clang-cl toolchains and causing clangd to assume C instead of C++ for some files. Change-Id: Ib98db88ac90e4e45a7016a7edcb80a279df372aa Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
* ClangCodeModel: Switch to LSP-based UI header approachChristian Kandeler2022-06-021-8/+0
| | | | | | | | | | | | | | | | | Generating ui headers in a well-known path and then including that one in the compilation database does not work in the presence of multiple ui files with the same name. As it turns out, we don't have to generate any files at all; instead, we pass the file contents directly to clangd, which then uses them when parsing includes of the respective header. User-visible behavior change apart from the abovementioned bug fix: Tooltips and "follow symbol" on the include directive now always use the actual location of the header provided by the build system. Fixes: QTCREATORBUG-27584 Change-Id: I6b13e12cb3a365199567b0bc824d12b373117697 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
* Move clang diagnostics config settings to clangd settings pageChristian Kandeler2022-05-231-31/+4
| | | | | | | | | | | It was confusing to have both "Clang Code Model" and "clangd" project settings pages, so we merge them. Along the way, a lot of code dropped off. Change-Id: I780850b716195c3729403ae59f0794c11b5c556d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
* ClangCodeModel: Use Utils::runAsync instead of QtConcurrent::runEike Ziller2022-05-121-8/+8
| | | | | | | | | | That works the same with Qt 5 and Qt 6. This reverts commit c1fcaa28775240af47c62c479918d6f08e74617d. Change-Id: I603e50c793c2477454253a57bfe01eb25ecab6e3 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* ClangCodeModel: Fix build with Qt 5.15Christian Kandeler2022-05-111-8/+8
| | | | | | | | | | Artificially lower the number of function parameters in generateCompilationDB(), to accommodate Qt5's QtConcurrent::run(). Change-Id: Ide88925deb443378b9308d924406ec6f6f90e8aa Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* ClangCodeModel: Use clangd's include pathChristian Kandeler2022-05-101-6/+6
| | | | | | | | | ... rather than the one from the LLVM that Qt Creator was compiled against. Task-number: QTCREATORBUG-27120 Change-Id: I4f211345ed547cd13f0b0774b99bc0f199a9cd44 Reviewed-by: David Schulz <david.schulz@qt.io>
* CppEditor: Make CompilerOptionsBuilder take the actual clang include dirChristian Kandeler2022-05-101-2/+3
| | | | | | | | | | 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>
* ClangCodeModel: Remove some unused functionsChristian Kandeler2022-05-091-54/+0
| | | | | | Change-Id: Ibaab69aaab66998d1975663d1a1824d89aaa23a6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Schulz <david.schulz@qt.io>
* ClangCodeModel: Minimize QStringList -> QJsonArray conversionsChristian Kandeler2022-05-061-14/+49
| | | | | | | | | | | | ... when setting up the compilation database. As it turns out, these conversions were the most expensive part of creating the JSON file. We now build the JSON arrays incrementally instead of setting them up from scratch for every source file. Change-Id: I1e664a6320d5b3c49b31366c58aa14f63818e008 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* ClangCodeModel: Move another call out of a tight loopChristian Kandeler2022-05-061-8/+10
| | | | | | | | | ... when creating a compilation db. Change-Id: I4d392587f13214042b449a450ef1d4ae1c283ecb Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* ClangCodeModel: Do not re-classify source files for compilation dbChristian Kandeler2022-05-061-6/+5
| | | | | | | | This information is already present in the project part. Change-Id: I797b6f573e7fb434b323efa4219dab54103aecaa Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* ClangCodeModel: Speed up compilation db generationChristian Kandeler2022-05-061-164/+64
| | | | | | | | | | | We needlessly re-evaluated the same compiler options again and again for all files in a project part. Now we only do the actual file-related work per file. Along the way, we dissolved some unneeded classes and made CompilerOptionsBuilder non- polymorphic. Change-Id: I9710d641a57032936cc0812515974dbc91676c8c Reviewed-by: David Schulz <david.schulz@qt.io>
* Remove clangsupport dependency from pluginsChristian Kandeler2022-05-061-105/+0
| | | | | | | Change-Id: Ifd4215a590d32cd04fab720d0d8d5e746e81c6e8 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Schulz <david.schulz@qt.io>
* ClangCodeModel: prevent crash on null project infoDavid Schulz2022-03-141-0/+2
| | | | | | Change-Id: Iff0c0413aa52821dc883b7f42b04bc8ca5dd4a29 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* ClangCodeModel: Fix build with MSVC 2022Christian Kandeler2021-12-171-4/+4
| | | | | | | Change-Id: Ifd0e1e67057e57e4c978784e9634f987edb9dfe4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* ClangCodeModel: Prevent duplicate "/Tx" optionsChristian Kandeler2021-12-071-1/+9
| | | | | | | | | Those trigger code model warnings. Fixes: QTCREATORBUG-26664 Change-Id: I0ed6b9edeeb94c8597b30c0be514d2b34dbedc49 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>