summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/compileroptionsbuilder.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Clang: Never use toolchain definesIvan Donchevskii2019-01-161-23/+2
| | | | | | | | 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-121/+210
| | | | | | | | | | | | | 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-45/+91
| | | | | | | Rely on clang to do the "right thing" with them. Change-Id: I44adf2cd5c61549896da3fc9b7c35c2fb0142060 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* Utils: Move C++ language details from ProjectExplorer to UtilsMarco Bubke2019-01-151-7/+7
| | | | | | | | We want to use them in the backend processes too so it's nice to share them in Utils. A concrete size was added too because they should be serialized. Change-Id: Id5eb8f46643d5159f034fc9559f68a08d7e5847a Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Merge remote-tracking branch 'origin/4.8'Eike Ziller2019-01-151-16/+25
|\ | | | | | | | | | | | | Conflicts: src/plugins/cpptools/compileroptionsbuilder.cpp Change-Id: I522f91de70aff28692d7c3a050e8d52df0b82a76
| * Clang: Fix parsing boost headersIvan Donchevskii2019-01-141-19/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-5/+5
| | | | | | | | | | Change-Id: Iaf5af70136bceed52d19622c01d9d7147e5abeea Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* | Clang: Stop enabling exceptions explicitlyNikolai Kosjar2019-01-091-8/+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: More build fixesChristian Kandeler2018-12-211-2/+2
| | | | | | | | | | Change-Id: I350479c0f79869cccdf0edfd6c89d932d8f3215f Reviewed-by: André Hartmann <aha_1980@gmx.de>
* | CppTools: Fix buildChristian Kandeler2018-12-211-1/+1
| | | | | | | | | | | | | | Amends 97828a96af and ef8de6a384. Change-Id: I9dd7d6a093657ea6f20ff3b5a4d0c968f8293ad7 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* | CppTools: Add reset function to CompilerOptionsBuilderMarco Bubke2018-12-201-0/+5
| | | | | | | | | | | | | | | | 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-110/+36
| | | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'origin/4.8'Eike Ziller2018-12-121-38/+34
|\ \ | |/ | | | | | | | | | | | | | | Conflicts: qbs/modules/qtc/qtc.qbs qtcreator.pri src/plugins/cpptools/compileroptionsbuilder.cpp Change-Id: I87f47cecbb924064296a002fd9446a0627acad8e
| * Clang: Always force the built-in includes orderIvan Donchevskii2018-12-111-33/+32
| | | | | | | | | | | | | | | | | | C++ includes must always come first, then clang resource directory and then everything else. This prevents both c++ standard headers and intrinsics issues. Change-Id: Ia21bfa2fe99884c9adf58f7ef6beba1bede1724b Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* | Clang: Stop forwarding toolchain macrosNikolai Kosjar2018-12-101-9/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...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>
* | Merge remote-tracking branch 'origin/4.8'Eike Ziller2018-12-071-1/+2
|\ \ | |/ | | | | | | | | | | Conflicts: src/plugins/cpptools/compileroptionsbuilder.cpp Change-Id: I743ea39480cc5c7b6febcd2e93713d15a3ae6d9c
| * Clang: Use -fms-compatibility-version with clang-cl toolchainIvan Donchevskii2018-12-031-3/+5
| | | | | | | | | | | | | | It's used while building so let's also do that in Clang Code Model. Change-Id: I4e5e3ccc71d14c8d44049672e37380af2592390f Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* | CppTools: Split CppTools::UseBuiltin in two optionsNikolai Kosjar2018-12-041-6/+8
| | | | | | | | | | | | | | | | | | | | ...for clarity. No behavior change. Change-Id: Id0334bc79b97a8ff53b37089e337530c9a01b1d4 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io> Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* | CppTools: Fix build with MSVCNikolai Kosjar2018-12-041-2/+2
| | | | | | | | | | | | | | | | compileroptionsbuilder.cpp(196): error C2440: 'initializing': cannot convert from 'const char *' to 'QString' Change-Id: Ifa5e50ab927c534a855c2f7871d3dce87092b30a Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* | Clang: Unify CompilerOptionsBuilder optionsNikolai Kosjar2018-12-031-9/+9
| | | | | | | | | | | | | | | | | | | | 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>
* | CppTools: Fix compile with older Qt / gccChristian Stenger2018-12-031-2/+2
| | | | | | | | | | Change-Id: I00656b409135ee1a84a0a372f726fdbc7c20d1e6 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* | Clang: Clean up CompilerOptionsBuilderNikolai Kosjar2018-12-031-200/+185
|/ | | | | | | | | | | | | | | 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/+9
| | | | | | | | | | | | | | | | | | 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>
* Clang: Fix C++ paths search in compiler options builderIvan Donchevskii2018-11-211-5/+6
| | | | | | | | Take into account paths from MinGW and NDK Clang. Fixes: QTCREATORBUG-21540 Change-Id: I00906c75dc4ddeb92fe5942a0222285d8ce2eb9d Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* CppTools: Forward OpenMP extension flagNikolai Kosjar2018-11-131-0/+3
| | | | | | Fixes: QTCREATORBUG-21213 Change-Id: I986ab69bc44ece83a3b56f968cc3b6c3126e2c32 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* CompilationDatabase: Support both code modelsIvan Donchevskii2018-11-011-7/+0
| | | | | | | | | Extract headers, defines and fileKind from flags in order to have complete project parts. Side-effect: better support for MSVC-specific flags. Change-Id: Iaa1413c91c96c3cf89ddbe76a7a1f0f46c5289c0 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Clang: Check that file kind matches the language versionIvan Donchevskii2018-11-011-0/+5
| | | | | | | | It was checked that pure C header and source files had proper language version but not another way around. Change-Id: I1eaf41f342731bdbe30ee73e81144334d0f15d19 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Clang: Don't wrap Qt headers when generating compilation databaseIvan Donchevskii2018-10-301-0/+3
| | | | | | | This trick is needed only for internal purposes. Change-Id: Ic10c0898519eed663d14c4b1665a0d6b0d47b4a4 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Clang: Go through CLANG-UPGRADE-CHECKIvan Donchevskii2018-10-251-0/+2
| | | | | Change-Id: Iaaaea598d020a44bcdc60a8d06ee28a1f28386bb Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Don't remove __cplusplusMarco Bubke2018-10-101-3/+15
| | | | | | | | | | | 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>
* CppTools/ProjectExplorer: Remove enum duplicationNikolai Kosjar2018-10-081-17/+21
| | | | | | | | ... between CppTools::ProjectPart and ProjectExplorer::ToolChain. Change-Id: I8b448747e454adbed77547460383b8515462cc81 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io> Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* Toolchains: Detect unspecified language versionNikolai Kosjar2018-10-081-0/+12
| | | | | | | | | | | | | | | | | | | | We checked the command line from the project manager for "-std=X" and friends to figure out the language version to use. However, if such a flag was not provided, we assumed the latest version we support. This could conflict with the actual version of the compiler and its predefined macros. Figure out the version by inspecting __cplusplus/__STDC_VERSION__ in the predefined macros of the toolchain. The MSVC compiler is an exception to this, as it does not seem to properly set the value - check for _MSVC_LANG if possible, otherwise simply assume some versions as before. While at it, add also support for C17/C18 and the upcoming C++2a. Task-number: QTCREATORBUG-20884 Task-number: QTCREATORBUG-21188 Change-Id: I464ffcd52d2120c0208275a050e82efda44fae1c Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* CompilerOptionsBuilder unit-testsIvan Donchevskii2018-10-041-12/+16
| | | | | | | 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-8/+12
| | | | | | | | | | | | 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>
* Plugins: Add compilation database pluginIvan Donchevskii2018-09-191-0/+8
| | | | | | | | | | | | Introduce compilation database project support. Pass the arguments list for each file directly to ClangCodeModel via extraCodeModelFlags therefore introduce a dependency from the ClangCodeModel plugin. Change-Id: Iea5760d379de1ea246382dce56de0adf7ab5673d Task-number: QTCREATORBUG-21115 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* Clang: Use built-in paths knowledge to better place clang include pathIvan Donchevskii2018-09-181-88/+83
| | | | | | | | 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-1/+4
| | | | | | | We don't want to have compiler-specific paths there. Change-Id: If26434ea3760d4f2ca4c25bbcf0340f4ea781072 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* ProjectExplorer: Rename compiler includes from System to BuiltInIvan Donchevskii2018-09-171-14/+20
| | | | | | | | | System include are those used with -isystem keyword, built-in includes on the other hand come from compiler and always follow in the end of the include list (after system includes). Change-Id: I95c2fec36d2e5b43f014fe0a88d59c6769edfa1f Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* Clang: Do not use -isystem in ClangCodeModelIvan Donchevskii2018-09-171-1/+3
| | | | | | | | | Some other logic in the options builder is based on the -I usage and also we don't want to lock any files with ClangCodeModel. Change-Id: I4338abed26e91ebb0a561d449328ea0954fe44ea Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* ProjectExplorer: Rename IncludePathType to HeaderPathTypeTobias Hunger2018-09-131-4/+4
| | | | | | | | | | | | | 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>
* Add system include path to HeaderPath and merge ProjectPartHeaderPathMarco Bubke2018-09-101-4/+7
| | | | | | | | | | | | | 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>
* Clang: Do not add -undef to ClangCodeModel arguments with clang-clIvan Donchevskii2018-08-281-1/+3
| | | | | | | | 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>
* Clang: Fix include paths orderIvan Donchevskii2018-08-271-5/+113
| | | | | | | | | | 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>
* Clang: Fix excluded Clang path regular expressionIvan Donchevskii2018-08-241-1/+1
| | | | | | | Cover cases like /usr/lib64/clang/6.0.0/include Change-Id: I015ea3535637376eeab6f737752ad13d33887190 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* Add optional system include to compiler option builderMarco Bubke2018-08-141-6/+13
| | | | | | | | | | | | 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-65/+75
| | | | | Change-Id: Iaabdcfc8d1b3463c3f6e5ce47536f9c52556eac0 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* Clang: Provide include directory only for libclangIvan Donchevskii2018-08-081-29/+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-26/+10
| | | | | | | | | | 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>
* Clang: Avoid using -isystem include pathsNikolai Kosjar2018-06-271-26/+1
| | | | | | | | | | | | | | | | ...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>
* Clang: Remove redundant checkIvan Donchevskii2018-06-201-4/+0
| | | | | | | | | | | 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>