CppTools: Make code model on "cl" mode more robust

Unknown command line options starting with / are now transformed
into commands starting with -, which will cause unknown commands
warnings in libclang.

The / commands cause errors because they are treated as missing
files.

Fixes: QTCREATORBUG-22871
Change-Id: I75f7878ab6a7951df24c954ccff1c298ea65f839
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Cristian Adam
2019-10-02 13:57:07 +02:00
parent 6ec8017bc6
commit 93ec10754f

View File

@@ -792,6 +792,15 @@ void CompilerOptionsBuilder::evaluateCompilerFlags()
containsDriverMode = true;
}
// Transfrom the "/" starting commands into "-" commands, which if
// unknown will not cause clang to fail because it thinks
// it's a missing file.
if (theOption.startsWith("/") &&
(toolChain == ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID ||
toolChain == ProjectExplorer::Constants::CLANG_CL_TOOLCHAIN_TYPEID)) {
theOption[0] = '-';
}
m_compilerFlags.flags.append(theOption);
}