forked from qt-creator/qt-creator
CppTools: Avoid "defineLine" in CompilerOptionsBuilder API
...because it might suggest to append a new line. Change-Id: I8d5701a1d20c9d94ee528383227a6e3b446b4ff2 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -82,9 +82,9 @@ QByteArray Macro::toDefineOption(const QByteArray &option) const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilerOptionsBuilder::addDefine(const QByteArray &defineLine)
|
void CompilerOptionsBuilder::addDefine(const QByteArray &defineDirective)
|
||||||
{
|
{
|
||||||
m_options.append(defineLineToDefineOption(defineLine));
|
m_options.append(defineDirectiveToDefineOption(defineDirective));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilerOptionsBuilder::addTargetTriple()
|
void CompilerOptionsBuilder::addTargetTriple()
|
||||||
@@ -144,10 +144,10 @@ void CompilerOptionsBuilder::addDefines(const QByteArray &defineDirectives)
|
|||||||
QStringList result;
|
QStringList result;
|
||||||
|
|
||||||
foreach (QByteArray def, defineDirectives.split('\n')) {
|
foreach (QByteArray def, defineDirectives.split('\n')) {
|
||||||
if (def.isEmpty() || excludeDefineLine(def))
|
if (def.isEmpty() || excludeDefineDirective(def))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const QString defineOption = defineLineToDefineOption(def);
|
const QString defineOption = defineDirectiveToDefineOption(def);
|
||||||
if (!result.contains(defineOption))
|
if (!result.contains(defineOption))
|
||||||
result.append(defineOption);
|
result.append(defineOption);
|
||||||
}
|
}
|
||||||
@@ -351,9 +351,9 @@ QString CompilerOptionsBuilder::includeOption() const
|
|||||||
return QLatin1String("-I");
|
return QLatin1String("-I");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CompilerOptionsBuilder::defineLineToDefineOption(const QByteArray &defineLine)
|
QString CompilerOptionsBuilder::defineDirectiveToDefineOption(const QByteArray &defineDirective)
|
||||||
{
|
{
|
||||||
const Macro macro = Macro::fromDefineDirective(defineLine);
|
const Macro macro = Macro::fromDefineDirective(defineDirective);
|
||||||
const QByteArray option = macro.toDefineOption(defineOption().toLatin1());
|
const QByteArray option = macro.toDefineOption(defineOption().toLatin1());
|
||||||
|
|
||||||
return QString::fromLatin1(option);
|
return QString::fromLatin1(option);
|
||||||
@@ -370,11 +370,11 @@ static bool isGccOrMinGwToolchain(const Core::Id &toolchainType)
|
|||||||
|| toolchainType == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID;
|
|| toolchainType == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompilerOptionsBuilder::excludeDefineLine(const QByteArray &defineLine) const
|
bool CompilerOptionsBuilder::excludeDefineDirective(const QByteArray &defineDirective) const
|
||||||
{
|
{
|
||||||
// This is a quick fix for QTCREATORBUG-11501.
|
// This is a quick fix for QTCREATORBUG-11501.
|
||||||
// TODO: do a proper fix, see QTCREATORBUG-11709.
|
// TODO: do a proper fix, see QTCREATORBUG-11709.
|
||||||
if (defineLine.startsWith("#define __cplusplus"))
|
if (defineDirective.startsWith("#define __cplusplus"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// gcc 4.9 has:
|
// gcc 4.9 has:
|
||||||
@@ -383,8 +383,10 @@ bool CompilerOptionsBuilder::excludeDefineLine(const QByteArray &defineLine) con
|
|||||||
// The right-hand sides are gcc built-ins that clang does not understand, and they'd
|
// The right-hand sides are gcc built-ins that clang does not understand, and they'd
|
||||||
// override clang's own (non-macro, it seems) definitions of the symbols on the left-hand
|
// override clang's own (non-macro, it seems) definitions of the symbols on the left-hand
|
||||||
// side.
|
// side.
|
||||||
if (isGccOrMinGwToolchain(m_projectPart.toolchainType) && defineLine.contains("has_include"))
|
if (isGccOrMinGwToolchain(m_projectPart.toolchainType)
|
||||||
|
&& defineDirective.contains("has_include")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,7 @@ public:
|
|||||||
|
|
||||||
// Add custom options
|
// Add custom options
|
||||||
void add(const QString &option);
|
void add(const QString &option);
|
||||||
void addDefine(const QByteArray &defineLine);
|
void addDefine(const QByteArray &defineDirective);
|
||||||
|
|
||||||
// Add options based on project part
|
// Add options based on project part
|
||||||
virtual void addTargetTriple();
|
virtual void addTargetTriple();
|
||||||
@@ -56,7 +56,7 @@ public:
|
|||||||
void undefineCppLanguageFeatureMacrosForMsvc2015();
|
void undefineCppLanguageFeatureMacrosForMsvc2015();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool excludeDefineLine(const QByteArray &defineLine) const;
|
virtual bool excludeDefineDirective(const QByteArray &defineDirective) const;
|
||||||
virtual bool excludeHeaderPath(const QString &headerPath) const;
|
virtual bool excludeHeaderPath(const QString &headerPath) const;
|
||||||
|
|
||||||
virtual QString defineOption() const;
|
virtual QString defineOption() const;
|
||||||
@@ -65,7 +65,7 @@ protected:
|
|||||||
const ProjectPart m_projectPart;
|
const ProjectPart m_projectPart;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString defineLineToDefineOption(const QByteArray &defineLine);
|
QString defineDirectiveToDefineOption(const QByteArray &defineDirective);
|
||||||
|
|
||||||
QStringList m_options;
|
QStringList m_options;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user