Don't remove __cplusplus

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>
This commit is contained in:
Marco Bubke
2018-10-09 14:26:47 +02:00
parent 5249d0c376
commit 77b5907c57
9 changed files with 108 additions and 76 deletions

View File

@@ -44,13 +44,15 @@ namespace CppTools {
CompilerOptionsBuilder::CompilerOptionsBuilder(const ProjectPart &projectPart,
UseSystemHeader useSystemHeader,
SkipBuiltIn skipBuiltInHeaderPathsAndDefines,
SkipLanguageDefines skipLanguageDefines,
QString clangVersion,
QString clangResourceDirectory)
: m_projectPart(projectPart)
, m_useSystemHeader(useSystemHeader)
, m_clangVersion(clangVersion)
, m_clangResourceDirectory(clangResourceDirectory)
, m_useSystemHeader(useSystemHeader)
, m_skipBuiltInHeaderPathsAndDefines(skipBuiltInHeaderPathsAndDefines)
, m_skipLanguageDefines(skipLanguageDefines)
{
}
@@ -601,8 +603,18 @@ bool CompilerOptionsBuilder::excludeDefineDirective(const ProjectExplorer::Macro
{
// Avoid setting __cplusplus & co as this might conflict with other command line flags.
// Clang should set __cplusplus based on -std= and -fms-compatibility-version version.
QTC_ASSERT(macro.key != "__cplusplus", return true);
QTC_ASSERT(macro.key != "__STDC_VERSION__", return true);
static const auto languageDefines = {"__cplusplus",
"__STDC_VERSION__",
"_MSC_BUILD",
"_MSVC_LANG",
"_MSC_FULL_VER",
"_MSC_VER"};
if (m_skipLanguageDefines == SkipLanguageDefines::Yes
&& std::find(languageDefines.begin(),
languageDefines.end(),
macro.key) != languageDefines.end()) {
return true;
}
// Ignore for all compiler toolchains since LLVM has it's own implementation for
// __has_include(STR) and __has_include_next(STR)

View File

@@ -31,13 +31,19 @@
namespace CppTools {
enum class UseSystemHeader
enum class UseSystemHeader : char
{
Yes,
No
};
enum class SkipBuiltIn
enum class SkipBuiltIn : char
{
Yes,
No
};
enum class SkipLanguageDefines : char
{
Yes,
No
@@ -54,6 +60,7 @@ public:
CompilerOptionsBuilder(const ProjectPart &projectPart,
UseSystemHeader useSystemHeader = UseSystemHeader::No,
SkipBuiltIn skipBuiltInHeaderPathsAndDefines = SkipBuiltIn::No,
SkipLanguageDefines skipLanguageDefines = SkipLanguageDefines::Yes,
QString clangVersion = QString(),
QString clangResourceDirectory = QString());
@@ -107,12 +114,13 @@ private:
void addWrappedQtHeadersIncludePath(QStringList &list);
QStringList m_options;
UseSystemHeader m_useSystemHeader;
QString m_clangVersion;
QString m_clangResourceDirectory;
UseSystemHeader m_useSystemHeader;
SkipBuiltIn m_skipBuiltInHeaderPathsAndDefines;
SkipLanguageDefines m_skipLanguageDefines;
};
} // namespace CppTools