CppEditor: Prevent /TC and /TP with Objective-C files

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>
This commit is contained in:
Christian Kandeler
2022-11-28 12:28:54 +01:00
parent a146403596
commit aed633712f
4 changed files with 13 additions and 6 deletions

View File

@@ -119,10 +119,12 @@ static QJsonObject createFileObject(const FilePath &buildDir,
const ProjectFile::Kind kind = ProjectFile::classify(projFile.path);
if (projectPart.toolchainType == ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID
|| projectPart.toolchainType == ProjectExplorer::Constants::CLANG_CL_TOOLCHAIN_TYPEID) {
if (!ProjectFile::isObjC(kind)) {
if (ProjectFile::isC(kind))
args.append("/TC");
else if (ProjectFile::isCxx(kind))
args.append("/TP");
}
} else {
QStringList langOption
= createLanguageOptionGcc(projectPart.language, kind,

View File

@@ -426,7 +426,7 @@ void CompilerOptionsBuilder::addMacros(const Macros &macros)
void CompilerOptionsBuilder::updateFileLanguage(ProjectFile::Kind fileKind)
{
if (isClStyle()) {
if (isClStyle() && !ProjectFile::isObjC(fileKind)) {
QString option;
if (ProjectFile::isC(fileKind))
option = "/TC";

View File

@@ -67,7 +67,11 @@ bool ProjectFile::isAmbiguousHeader(const QString &filePath)
bool ProjectFile::isObjC(const QString &filePath)
{
const Kind kind = classify(filePath);
return isObjC(classify(filePath));
}
bool ProjectFile::isObjC(Kind kind)
{
switch (kind) {
case CppEditor::ProjectFile::ObjCHeader:
case CppEditor::ProjectFile::ObjCXXHeader:

View File

@@ -43,6 +43,7 @@ public:
static bool isCxx(Kind kind);
static bool isAmbiguousHeader(const QString &filePath);
static bool isObjC(const QString &filePath);
static bool isObjC(Kind kind);
bool isHeader() const;
bool isSource() const;