summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/compileroptionsbuilder.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge CppTools into CppEditorChristian Kandeler2021-09-011-127/+0
| | | | | | | | | | | | | | | | 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>
* ClangTools: Proliferate use of FilePathhjk2021-08-181-3/+3
| | | | | Change-Id: I3eb16546a729ab01c10e37572adac9aef83f5cd4 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* ClangCodeModel: Prefer ui headers from ExtraCompilersChristian Kandeler2021-07-021-0/+1
| | | | | | | | | ... to the ones from the actual build. The former are generally more up- to-date. Fixes: QTCREATORBUG-25937 Change-Id: I20859de9816457c340d9e1ec6a3008c536537d8b Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* CMakeProjectManager: Fix issues with precompiled headersCristian Adam2021-01-141-2/+1
| | | | | | | | | | | | | | | Clang code model can break if CMake project uses precompiled headers. QtCreator will make a copy of the precompiled header, this way it will not conflict with the build system one. Ammends 888ea6bbbb0f4c6bb6b5616046e600b9520e4faf Fixes: QTCREATORBUG-24945 Fixes: QTCREATORBUG-25213 Change-Id: I149fc416cd047683d095758a024de47c7baf681c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* CppTools: Take "-include" files into accountNikolai Kosjar2020-11-051-0/+1
| | | | | | Fixes: QTCREATORBUG-20602 Change-Id: Ibfc518fc64ed75f93265db800558ec1d2e424bb4 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* ClangTools: Do not include our wrapped Qt headersChristian Kandeler2020-10-281-1/+1
| | | | | | | | | 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>
* Merge remote-tracking branch 'origin/4.13' into masterEike Ziller2020-09-031-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | Conflicts: share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ListViewSpecifics.qml share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/MouseAreaSpecifics.qml share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/RowSpecifics.qml share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/FlickableSection.qml share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/FontSection.qml share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/StandardTextSection.qml Change-Id: Ie5deacd39ae4f3c0966e7cb41a8fd832dcefbb09
| * Clang: Add conditions for adding exceptions flagOrgad Shaneh2020-09-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | For GCC it can be deduced from the compiler flags, so no correction is needed. For MSVC it can be deduced from the detected defines. Amends 26693e82126de15145a04c3428a10f6c15120532. Change-Id: Ie4850f328a2afdb3e5158c58f8c30a2644d9c592 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | clang: Fix include/resource dir confusionChristian Kandeler2020-08-241-4/+3
|/ | | | | | | | | | | 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>
* Clang: Fix error when including float.h with mingwChristian Kandeler2020-07-091-1/+4
| | | | | | | | | | | Prevent mingw from trying to #include_next a private header from a path we cannot add to our list of includes. Fixes: QTCREATORBUG-24251 Task-number: QTCREATORBUG-24027 Change-Id: I18a9db130b9c2265cd208c3506d08d2e1c4cee45 Reviewed-by: Marco Bubke <marco.bubke@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Revert "Clang: Stop enabling exceptions explicitly"Nikolai Kosjar2019-12-201-0/+1
| | | | | | | | | This reverts commit b114f77d8a633341b617a5cadd04e5977beae65d as "--driver-mode=cl" apparently still disables exceptions. Task-number: QTCREATORBUG-23000 Change-Id: I9c49d971fafda5e1aca8445f8921e50f323d368f Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* CppTools: Do not use PCH when build PCH artifacts exist closebyCristian Adam2019-09-301-0/+2
| | | | | | | | | Clang cannot handle gcc pch files which are close to the forced include header. Fixes: QTCREATORBUG-22888 Change-Id: I0d678a889d1fb62bf3c6850277e13271efb91eea Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Clang: Improve compilation database generationIvan Donchevskii2019-03-131-0/+1
| | | | | | | | | | Do not use CompilerOptionsBuilder anymore because we don't need much tweaking for projectPart data and can do it better specifically for the generator. Fixes: QTCREATORBUG-21936 Change-Id: I00ad872c703598a9a88af29399b428520dd5cb3b Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* Clang: Allow to forward warnings flags from build systemNikolai Kosjar2019-02-051-6/+10
| | | | | | Change-Id: I47ebb1ce4f3b5544408eb1d0f891ed5090394282 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* Clang: Fix how tweaked header paths workIvan Donchevskii2019-01-231-1/+1
| | | | | | | | | | We need to provide built-in includes only when we use tweaked headers. Also let's require Clang resource directory because it has to be placed on the specific position inside the built-in header paths. Change-Id: Id581238660c680725201de759216cf33f69f6cc7 Reviewed-by: Marco Bubke <marco.bubke@qt.io> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* PchManager: Split pch tasks in project and system pch tasksMarco Bubke2019-01-211-0/+1
| | | | | | | | | | | | | | | | | | | Like you can see in the task numbers this patch is touching many different areas. So I will only touch the main parts. It is using a clang action instead of an extra process which will be enabling the handling of generated files in PCHs. The flags from the project part are now not anymore transformed in a command line but they are saved in the container semantically aware so that they can later be merged. Most of this patch is simply polishing of other patches. Task-number: QTCREATORBUG-21346 Task-number: QTCREATORBUG-21380 Task-number: QTCREATORBUG-21382 Task-number: QTCREATORBUG-21383 Task-number: QTCREATORBUG-21693 Task-number: QTCREATORBUG-21778 Change-Id: I9b0c02d8149b554254e819448fbc61eeaa5b7494 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* Clang: Never use toolchain definesIvan Donchevskii2019-01-161-4/+1
| | | | | | | | The known cases provide enough flags not to require toolchain defines. Change-Id: Ia7e08a90eca6ea9474db40683ac1e63236f8643d Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Clang: Support MSVC style of compiler flagsIvan Donchevskii2019-01-161-5/+11
| | | | | | | | | | | | | Clang has MSVC compatible mode which works with MSVC style command line flags. When possible use the same flags (-I, -D, -U, etc.) and in other cases either replace by MSVC analog (for example use /FI instead of -include) or pass the argument with '/clang:' prefix (requires https://reviews.llvm.org/D53457). Change-Id: I95f33bed5dc8d9493895ed8d4359cdd70fc774b8 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Clang: Forward compiler options for gcc/clangNikolai Kosjar2019-01-161-1/+8
| | | | | | | Rely on clang to do the "right thing" with them. Change-Id: I44adf2cd5c61549896da3fc9b7c35c2fb0142060 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* Merge remote-tracking branch 'origin/4.8'Eike Ziller2019-01-151-0/+2
|\ | | | | | | | | | | | | Conflicts: src/plugins/cpptools/compileroptionsbuilder.cpp Change-Id: I522f91de70aff28692d7c3a050e8d52df0b82a76
| * Clang: Fix parsing boost headersIvan Donchevskii2019-01-141-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | The fix for MSVC2013 undefined clang macros to fix some internal Qt stuff failing in Qt 5.7. Now we know exactly which MSVC version is used and can ignore this fix for newer versions. Fixes: QTCREATORBUG-16439 Fixes: QTCREATORBUG-21685 Change-Id: Ie2844428c39d72d212198ee2dd6841420a464974 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* | Clang: Minor cleanups in CompilerOptionsBuilderNikolai Kosjar2019-01-111-2/+2
| | | | | | | | | | Change-Id: Iaf5af70136bceed52d19622c01d9d7147e5abeea Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* | Clang: Stop enabling exceptions explicitlyNikolai Kosjar2019-01-091-1/+0
| | | | | | | | | | | | | | | | According to commit e2e3be09e36f89f4db92c443ec9f7fb1dab70624 this was needed for clang 3.8.0 on Windows. Change-Id: I4f2c2bf31449d9613607e57524c7ff6e4577812a Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* | CppTools: Add reset function to CompilerOptionsBuilderMarco Bubke2018-12-201-0/+1
| | | | | | | | | | | | | | | | It makes it easier two get different options. Task-number: QTCREATORBUG-21693 Change-Id: Ibcfa52d8bbbdf971a38fb6102a6b79e037a9cf02 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* | CppTools: Adapt CompilerOptionsBuilder to HeaderPathFilterMarco Bubke2018-12-201-0/+1
| | | | | | | | | | | | | | | | | | After we moved some of the code to HeaderPathFilter we now use it in CompilerOptionsBuilder. Task-number: QTCREATORBUG-21693 Change-Id: Iea3569465bbc135d72bd88f9c23026f2ace33aba Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* | Clang: Stop forwarding toolchain macrosNikolai Kosjar2018-12-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...for clang code model and clang tools use case. This means that compiler detection code will see clang now instead of the toolchain that is configured in the kit. While providing the toolchain macros worked fine for the general case, it always was problematic for compiler detection code. By not providing the toolchain macros we are more close to the real clang compiler invocation. That is, rely on clang to do the right thing. Allow to go back to old behavior with QTC_CLANG_USE_TOOLCHAIN_MACROS=1 as this will be useful checking differences for debugging. Fixes: QTCREATORBUG-19543 Change-Id: I23ffd761d83f35ca1a22269c3ef07a2dc62358bd Reviewed-by: Marco Bubke <marco.bubke@qt.io> Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* | CppTools: Split CppTools::UseBuiltin in two optionsNikolai Kosjar2018-12-041-3/+6
| | | | | | | | | | | | | | | | | | | | ...for clarity. No behavior change. Change-Id: Id0334bc79b97a8ff53b37089e337530c9a01b1d4 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io> Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* | Clang: Unify CompilerOptionsBuilder optionsNikolai Kosjar2018-12-031-6/+6
| | | | | | | | | | | | | | | | | | | | No behavior change. Sometimes we use "SkipX, sometimes "UseX". Unify to "UseX" as this is more natural to read. Change-Id: Ib08bdb4cde93ed55fdb9c855566b10a3933cae37 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* | Clang: Clean up CompilerOptionsBuilderNikolai Kosjar2018-12-031-50/+20
|/ | | | | | | | | | | | | | | No behavior change. * Remove virtual from methods that are not overridden * Move constant member functions that do no access any members into source file as static functions * Remove QLatin1String where possible * Make variable names a bit more consistent * Other minor stuff Change-Id: I34a582d5a468489e11365507b283e9aee157664f Reviewed-by: Marco Bubke <marco.bubke@qt.io> Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* Clang: Work around eating memory with gcc/clang/-fno-rtti/boostNikolai Kosjar2018-11-291-0/+1
| | | | | | | | | | | | | | | | | | Boost recognizes a misconfigured compiler in rtti emulation mode (-fno-rtti) as our libclang command line is special. Even worse, it does not seem to stop instantiating templates and allocating memory afterwards. For the former to fix, we need to rework our command line (in master). The latter can be work arounded by defining BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING with a value for gcc/clang. See also https://www.boost.org/doc/libs/1_64_0/doc/html/BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING.html Task-number: QTCREATORBUG-19543 Change-Id: Iddb5be2d1f1966018e5ab535a8f7475fe7911284 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* Don't remove __cplusplusMarco Bubke2018-10-101-3/+11
| | | | | | | | | | | For the indexing we need all tool chain macros. Originally it was a fix because the C++ version of the project part and __cplusplus could be different but now they should be the same. They will be now removed in the compiler options builder. Change-Id: I7ae8721a29632473e76ecedb411a6c9001e5e199 Task-number: QTCREATORBUG-21265 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* CompilerOptionsBuilder unit-testsIvan Donchevskii2018-10-041-16/+15
| | | | | | | Bonus: minor compiler options builder issues fixed. Change-Id: Ie25f8fad6729339de05f2bf9b614ceac873e2634 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* CppTools: Apply SkipBuiltIn also to toolchain definesOrgad Shaneh2018-09-251-3/+3
| | | | | | | | | | | | The only place where Yes is used is the compilation DB, which doesn't need these defines anyway. Also add -fPIC for Qt compatibility. This reduces the compile_commands.json file for Qt Creator from 180M to 33M. Change-Id: Idd3b363c3a143b1d79f97962c4ff9ee61d7767a4 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* Clang: Use built-in paths knowledge to better place clang include pathIvan Donchevskii2018-09-181-2/+1
| | | | | | | | Clang include folder should be a part of built-in includes and always come after user and system includes. Change-Id: I22961ea3bbb018f41b49f42c6ff7d22eb591ad01 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* Clang: Skip built-in includes when exporting the compilation databaseIvan Donchevskii2018-09-171-0/+9
| | | | | | | We don't want to have compiler-specific paths there. Change-Id: If26434ea3760d4f2ca4c25bbcf0340f4ea781072 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* Clang: Fix include paths orderIvan Donchevskii2018-08-271-2/+11
| | | | | | | | | | 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>
* Add optional system include to compiler option builderMarco Bubke2018-08-141-3/+10
| | | | | | | | | | | | 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>
* Clang: Add button to generate compile_commands.jsonIvan Donchevskii2018-08-131-1/+1
| | | | | Change-Id: Iaabdcfc8d1b3463c3f6e5ce47536f9c52556eac0 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* Clang: Provide include directory only for libclangIvan Donchevskii2018-08-081-6/+1
| | | | | | | | | 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>
* Clang: Move clang paths helper functions to Core pluginIvan Donchevskii2018-08-061-11/+0
| | | | | | | | | | 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>
* ClangTools: Remove clang executable settingsIvan Donchevskii2018-05-041-1/+5
| | | | | | | | We use custom clang executable and it does not make sense anymore to give a choice of changing it. Change-Id: Icf86042ac3fcd08c320ef2bbdaabef1102b023b5 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* ProjectPart: save codegen flags in project partIvan Donchevskii2018-01-101-0/+1
| | | | | | | | | | | And add them to other clang code model arguments. These flags provide architecture for cross-compilation when ios kit is selected. Task-number: QTCREATORBUG-19437 Task-number: QTCREATORBUG-19430 Change-Id: I7a485f49d637371bb28b2096086d7d8a4b0c404a Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
* Clang: StaticAnalyzer: use the default compiler options builderIvan Donchevskii2017-11-221-0/+7
| | | | | | | | Analyzer has clang path and can generate necessary header paths to be able to use default options builder. Change-Id: I9bb1fc158f045f6e099817c5557ee7d9e38416fb Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Merge remote-tracking branch 'origin/4.5'Eike Ziller2017-11-211-1/+2
|\ | | | | | | | | | | | | | | | | Conflicts: src/plugins/clangcodemodel/clangutils.cpp src/plugins/cpptools/clangcompileroptionsbuilder.cpp src/plugins/cpptools/compileroptionsbuilder.cpp Change-Id: I0728f08171103259407bbbb35f93b70c2f2e18d0
| * Clang: Define __FUNCSIG__ and others for msvc toolchainIvan Donchevskii2017-11-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Affects __FUNCSIG__, __FUNCTION__ and __FUNCDNAME__. By default Clang can't concatenate strings under those macros with other strings. Because of that we need to define them with empty strings to make clang compile such cases without errors. Task-number: QTCREATORBUG-19295 Change-Id: I9a3770ebe56b4b8a49ba9982c5a1ba90c8f0b304 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
| * Clang: Add identifying macro Q_CREATOR_RUNNikolai Kosjar2017-11-211-1/+1
| | | | | | | | | | | | | | | | | | | | Use the same we use for the built-in code model. This is useful for conditions of pragmas. Task-number: QTCREATORBUG-16847 Change-Id: I4c83be46bb2b8a23e4c8f70d98e2b4c9572121ee Reviewed-by: David Schulz <david.schulz@qt.io>
* | Clang: Require LLVM/Clang >= 5.0.0Nikolai Kosjar2017-10-271-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...for the code model parts and declare 5.0 as the supported version for the clang static analyzer. Adapt versions and tests, remove code assuming clang <= 5.0. LLVM/Clang 5 was released on 07 Sep 2017. Task-number: QTCREATORBUG-18931 Task-number: QTCREATORBUG-18657 Task-number: QTCREATORBUG-17187 Task-number: QTCREATORBUG-14881 Change-Id: I53b00258ca06a1d2e57f9379dacc54b310687295 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
* | CppTools: merge CompilerOptionsBuilder with Clang oneIvan Donchevskii2017-10-231-5/+18
|/ | | | | | | Since it's never used for other compilers. Change-Id: I9512692d1dc9f9a701ea2453b7d50005478bed5d Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Clang: Unify compiler options buildersIvan Donchevskii2017-09-221-3/+1
| | | | | | | | Make build command the same for all builders. Minimize differences. Change-Id: I1cfe5071b3afb4944ed178fff1e57d3aee45d8a9 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Convert macros from plain QByteArray to a vector of structsMarco Bubke2017-09-141-4/+6
| | | | | | | | | | | The old code model expected the macros as C++ formatted text ("#define Foo 42) but newer targets like the Clang codemodel expect key value arguments like "-DFoo=42". So instead of parsing the text again and again we use an abstract data description. Task-number: QTCREATORBUG-17915 Change-Id: I0179fd13c48a581e91ee79bba9d42d501c26f19f Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>