CppEditor: Fix codemodel highlighting for QNX

The code model will get the necessary bits so that it can successfully
parse the QNX code.

Fixes: QTCREATORBUG-23483
Change-Id: Id9488f644ace23952edf7a7cb5da7ca138182134
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Cristian Adam
2021-12-03 13:52:21 +01:00
parent 41fe7eec65
commit 5a6c625c5e
3 changed files with 25 additions and 3 deletions

View File

@@ -35,6 +35,8 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectmacro.h>
#include <qnx/qnxconstants.h>
#include <utils/algorithm.h>
#include <utils/cpplanguage_details.h>
#include <utils/fileutils.h>
@@ -152,6 +154,7 @@ QStringList CompilerOptionsBuilder::build(ProjectFile::Kind fileKind,
undefineClangVersionMacrosForMsvc();
undefineCppLanguageFeatureMacrosForMsvc2015();
addDefineFunctionMacrosMsvc();
addDefineFunctionMacrosQnx();
addHeaderPathOptions();
@@ -404,8 +407,8 @@ void CompilerOptionsBuilder::addProjectMacros()
static const int useMacros = qEnvironmentVariableIntValue("QTC_CLANG_USE_TOOLCHAIN_MACROS");
if (m_projectPart.toolchainType == ProjectExplorer::Constants::CUSTOM_TOOLCHAIN_TYPEID
|| m_projectPart.toolchainType.name().contains("BareMetal")
|| useMacros) {
|| m_projectPart.toolchainType == Qnx::Constants::QNX_TOOLCHAIN_ID
|| m_projectPart.toolchainType.name().contains("BareMetal") || useMacros) {
addMacros(m_projectPart.toolChainMacros);
}
@@ -771,6 +774,17 @@ void CompilerOptionsBuilder::undefineClangVersionMacrosForMsvc()
}
}
void CompilerOptionsBuilder::addDefineFunctionMacrosQnx()
{
// QNX 7.0+ uses GCC with LIBCPP from Clang, and in that context GCC is giving
// the builtin operator new and delete.
//
// In our case we have only Clang and need to instruct LIBCPP that it doesn't
// have these operators. This makes the code model happy and doesn't produce errors.
if (m_projectPart.toolchainType == Qnx::Constants::QNX_TOOLCHAIN_ID)
addMacros({{"_LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE"}});
}
void CompilerOptionsBuilder::reset()
{
m_options.clear();