[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdevelop/5.3] plugins/custom-definesandincludes: Support for Objective-C++ in the custom-definesand
From: René J.V. Bertin <null () kde ! org>
Date: 2018-09-27 17:51:11
Message-ID: E1g5aRT-0000Jd-Q3 () code ! kde ! org
[Download RAW message or body]
Git commit 24e2f759694c0f5c467e27731fd447bdf289c3ab by René J.V. Bertin.
Committed on 27/09/2018 at 17:50.
Pushed by rjvbb into branch '5.3'.
Support for Objective-C++ in the custom-definesandincludes plugin
Differential Revision: https://phabricator.kde.org/D15764
M +18 -5 plugins/custom-definesandincludes/compilerprovider/gcclikecompiler.cpp
M +1 -0 plugins/custom-definesandincludes/compilerprovider/icompiler.h
M +14 -1 plugins/custom-definesandincludes/compilerprovider/settingsmanager.cpp
M +2 -0 plugins/custom-definesandincludes/kcm_widget/parserwidget.cpp
https://commits.kde.org/kdevelop/24e2f759694c0f5c467e27731fd447bdf289c3ab
diff --git a/plugins/custom-definesandincludes/compilerprovider/gcclikecompiler.cpp \
b/plugins/custom-definesandincludes/compilerprovider/gcclikecompiler.cpp index \
b6c8d8e703..45cfaa96cc 100644
--- a/plugins/custom-definesandincludes/compilerprovider/gcclikecompiler.cpp
+++ b/plugins/custom-definesandincludes/compilerprovider/gcclikecompiler.cpp
@@ -50,12 +50,14 @@ QString languageOption(Utils::LanguageType type)
return QStringLiteral("-xcuda");
case Utils::ObjC:
return QStringLiteral("-xobjective-c");
+ case Utils::ObjCpp:
+ return QStringLiteral("-xobjective-c++");
default:
Q_UNREACHABLE();
}
}
-QString languageStandard(const QString& arguments)
+QString languageStandard(const QString& arguments, Utils::LanguageType type)
{
// TODO: handle -ansi flag: In C mode, this is equivalent to -std=c90. In C++ \
mode, it is equivalent to -std=c++98. const QRegularExpression \
regexp(QStringLiteral("-std=(\\S+)")); @@ -63,8 +65,19 @@ QString \
languageStandard(const QString& arguments) if (result.hasMatch())
return result.captured(0);
- // no -std= flag passed -> assume c++11
- return QStringLiteral("-std=c++11");
+ switch (type) {
+ case Utils::C:
+ case Utils::ObjC:
+ return QStringLiteral("-std=c99");
+ case Utils::Cpp:
+ case Utils::ObjCpp:
+ case Utils::Cuda:
+ return QStringLiteral("-std=c++11");
+ case Utils::OpenCl:
+ return QStringLiteral("-cl-std=CL1.1");
+ default:
+ Q_UNREACHABLE();
+ }
}
}
@@ -87,7 +100,7 @@ Defines GccLikeCompiler::defines(Utils::LanguageType type, const \
QString& argume
// TODO: what about -mXXX or -target= flags, some of these change search \
paths/defines const QStringList compilerArguments{
languageOption(type),
- languageStandard(arguments),
+ languageStandard(arguments, type),
QStringLiteral("-dM"),
QStringLiteral("-E"),
QStringLiteral("-"),
@@ -144,7 +157,7 @@ Path::List GccLikeCompiler::includes(Utils::LanguageType type, \
const QString& ar
const QStringList compilerArguments{
languageOption(type),
- languageStandard(arguments),
+ languageStandard(arguments, type),
QStringLiteral("-E"),
QStringLiteral("-v"),
QStringLiteral("-"),
diff --git a/plugins/custom-definesandincludes/compilerprovider/icompiler.h \
b/plugins/custom-definesandincludes/compilerprovider/icompiler.h index \
cb8bb716cc..aa33a72ac1 100644
--- a/plugins/custom-definesandincludes/compilerprovider/icompiler.h
+++ b/plugins/custom-definesandincludes/compilerprovider/icompiler.h
@@ -38,6 +38,7 @@ enum LanguageType
OpenCl,
Cuda,
ObjC,
+ ObjCpp,
Other
};
diff --git a/plugins/custom-definesandincludes/compilerprovider/settingsmanager.cpp \
b/plugins/custom-definesandincludes/compilerprovider/settingsmanager.cpp index \
7e107c28dd..845c2bf94e 100644
--- a/plugins/custom-definesandincludes/compilerprovider/settingsmanager.cpp
+++ b/plugins/custom-definesandincludes/compilerprovider/settingsmanager.cpp
@@ -71,7 +71,12 @@ QString parserArgumentsKey(Utils::LanguageType languageType)
return QStringLiteral("parserArgumentsOpenCL");
case Utils::Cuda:
return QStringLiteral("parserArgumentsCuda");
+ // TODO: is there a need for "parserArgumentsObjC[++]" and if so how/where
+ // if not, merge the ObjC cases with the C/C++ cases.
case Utils::ObjC:
+ return QStringLiteral("parserArgumentsC");
+ case Utils::ObjCpp:
+ return QStringLiteral("parserArguments");
case Utils::Other:
break;
}
@@ -99,7 +104,11 @@ ParserArguments createDefaultArguments()
arguments[Utils::Cpp] = QStringLiteral("-ferror-limit=100 -fspell-checking \
-Wdocumentation -Wunused-parameter -Wunreachable-code -Wall \
-std=c++11");
arguments[Utils::OpenCl] = QStringLiteral("-ferror-limit=100 -fspell-checking \
-Wdocumentation -Wunused-parameter -Wunreachable-code -Wall \
-cl-std=CL1.1");
arguments[Utils::Cuda] = QStringLiteral("-ferror-limit=100 -fspell-checking \
-Wdocumentation -Wunused-parameter -Wunreachable-code -Wall \
-std=c++11");
- arguments[Utils::ObjC] = QStringLiteral("-ferror-limit=100 -fspell-checking \
-Wdocumentation -Wunused-parameter -Wunreachable-code -Wall -std=c99"); + // For \
now, use the same arguments for ObjC(++) as for C(++). -Wall enables a number + // \
of language-specific warnings, removing the need to add them explicitly. + // \
(https://embeddedartistry.com/blog/2017/3/7/clang-weverything) + \
arguments[Utils::ObjC] = arguments[Utils::C]; + arguments[Utils::ObjCpp] = \
arguments[Utils::Cpp]; arguments.parseAmbiguousAsCPP = true;
return arguments;
@@ -439,6 +448,10 @@ LanguageType languageType(const QString& path, bool \
treatAmbiguousAsCPP) return Cpp;
}
+ if (mimeType == QStringLiteral("text/x-objc++src")) {
+ return ObjCpp;
+ }
+
if (mimeType == QStringLiteral("text/x-objcsrc")) {
return ObjC;
}
diff --git a/plugins/custom-definesandincludes/kcm_widget/parserwidget.cpp \
b/plugins/custom-definesandincludes/kcm_widget/parserwidget.cpp index \
6ccb46ccb5..a39f03e565 100644
--- a/plugins/custom-definesandincludes/kcm_widget/parserwidget.cpp
+++ b/plugins/custom-definesandincludes/kcm_widget/parserwidget.cpp
@@ -57,6 +57,8 @@ QString languageDefaultStandard(Utils::LanguageType languageType)
return QStringLiteral("c++11");
case Utils::ObjC:
return QStringLiteral("c99");
+ case Utils::ObjCpp:
+ return QStringLiteral("c++11");
case Utils::Other:
break;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic