Commit 4d1a1981 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools: CompilerOptionsBuilder takes project part by reference

...since it assumes a project part != 0 and does not participate in
ownership.

Change-Id: Ia9c1eca52776990576a2dac61e9144234b04c59c
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@theqtcompany.com>
parent 340572c9
...@@ -312,8 +312,7 @@ static CppTools::ProjectPart projectPartForLanguageOption(CppTools::ProjectPart ...@@ -312,8 +312,7 @@ static CppTools::ProjectPart projectPartForLanguageOption(CppTools::ProjectPart
static QStringList languageOptions(const QString &filePath, CppTools::ProjectPart *projectPart) static QStringList languageOptions(const QString &filePath, CppTools::ProjectPart *projectPart)
{ {
const auto theProjectPart = CppTools::ProjectPart::Ptr( const auto theProjectPart = projectPartForLanguageOption(projectPart);
new CppTools::ProjectPart(projectPartForLanguageOption(projectPart)));
CppTools::CompilerOptionsBuilder builder(theProjectPart); CppTools::CompilerOptionsBuilder builder(theProjectPart);
builder.addLanguageOption(CppTools::ProjectFile::classify(filePath)); builder.addLanguageOption(CppTools::ProjectFile::classify(filePath));
......
...@@ -112,7 +112,7 @@ public: ...@@ -112,7 +112,7 @@ public:
if (projectPart.isNull()) if (projectPart.isNull())
return QStringList(); return QStringList();
LibClangOptionsBuilder optionsBuilder(projectPart); LibClangOptionsBuilder optionsBuilder(*projectPart.data());
if (verboseRunLog().isDebugEnabled()) if (verboseRunLog().isDebugEnabled())
optionsBuilder.add(QLatin1String("-v")); optionsBuilder.add(QLatin1String("-v"));
...@@ -135,7 +135,7 @@ public: ...@@ -135,7 +135,7 @@ public:
} }
private: private:
LibClangOptionsBuilder(const CppTools::ProjectPart::Ptr &projectPart) LibClangOptionsBuilder(const CppTools::ProjectPart &projectPart)
: CompilerOptionsBuilder(projectPart) : CompilerOptionsBuilder(projectPart)
{ {
} }
...@@ -171,7 +171,7 @@ private: ...@@ -171,7 +171,7 @@ private:
static const QString wrappedQtHeaders = ICore::instance()->resourcePath() static const QString wrappedQtHeaders = ICore::instance()->resourcePath()
+ QLatin1String("/cplusplus/wrappedQtHeaders"); + QLatin1String("/cplusplus/wrappedQtHeaders");
if (m_projectPart->qtVersion != ProjectPart::NoQt) { if (m_projectPart.qtVersion != ProjectPart::NoQt) {
add(QLatin1String("-I") + wrappedQtHeaders); add(QLatin1String("-I") + wrappedQtHeaders);
add(QLatin1String("-I") + wrappedQtHeaders + QLatin1String("/QtCore")); add(QLatin1String("-I") + wrappedQtHeaders + QLatin1String("/QtCore"));
} }
...@@ -179,9 +179,9 @@ private: ...@@ -179,9 +179,9 @@ private:
void addProjectConfigFileInclude() void addProjectConfigFileInclude()
{ {
if (!m_projectPart->projectConfigFile.isEmpty()) { if (!m_projectPart.projectConfigFile.isEmpty()) {
add(QLatin1String("-include")); add(QLatin1String("-include"));
add(m_projectPart->projectConfigFile); add(m_projectPart.projectConfigFile);
} }
} }
...@@ -213,7 +213,7 @@ private: ...@@ -213,7 +213,7 @@ private:
add(QStringLiteral("-Wno-documentation")); add(QStringLiteral("-Wno-documentation"));
add(QStringLiteral("-Wno-shadow")); add(QStringLiteral("-Wno-shadow"));
if (m_projectPart->languageVersion >= ProjectPart::CXX98) if (m_projectPart.languageVersion >= ProjectPart::CXX98)
add(QStringLiteral("-Wno-missing-prototypes")); add(QStringLiteral("-Wno-missing-prototypes"));
} }
}; };
......
...@@ -505,7 +505,7 @@ void ProjectPartBuilder::createProjectPart(const QStringList &theSources, ...@@ -505,7 +505,7 @@ void ProjectPartBuilder::createProjectPart(const QStringList &theSources,
} }
CompilerOptionsBuilder::CompilerOptionsBuilder(const ProjectPart::Ptr &projectPart) CompilerOptionsBuilder::CompilerOptionsBuilder(const ProjectPart &projectPart)
: m_projectPart(projectPart) : m_projectPart(projectPart)
{ {
} }
...@@ -544,7 +544,7 @@ void CompilerOptionsBuilder::addHeaderPathOptions() ...@@ -544,7 +544,7 @@ void CompilerOptionsBuilder::addHeaderPathOptions()
QStringList result; QStringList result;
foreach (const HeaderPath &headerPath , m_projectPart->headerPaths) { foreach (const HeaderPath &headerPath , m_projectPart.headerPaths) {
if (headerPath.path.isEmpty()) if (headerPath.path.isEmpty())
continue; continue;
...@@ -571,7 +571,7 @@ void CompilerOptionsBuilder::addHeaderPathOptions() ...@@ -571,7 +571,7 @@ void CompilerOptionsBuilder::addHeaderPathOptions()
void CompilerOptionsBuilder::addToolchainAndProjectDefines() void CompilerOptionsBuilder::addToolchainAndProjectDefines()
{ {
QByteArray extendedDefines = m_projectPart->toolchainDefines + m_projectPart->projectDefines; QByteArray extendedDefines = m_projectPart.toolchainDefines + m_projectPart.projectDefines;
QStringList result; QStringList result;
foreach (QByteArray def, extendedDefines.split('\n')) { foreach (QByteArray def, extendedDefines.split('\n')) {
...@@ -645,7 +645,7 @@ static QStringList createLanguageOptionGcc(ProjectFile::Kind fileKind, bool objc ...@@ -645,7 +645,7 @@ static QStringList createLanguageOptionGcc(ProjectFile::Kind fileKind, bool objc
void CompilerOptionsBuilder::addLanguageOption(ProjectFile::Kind fileKind) void CompilerOptionsBuilder::addLanguageOption(ProjectFile::Kind fileKind)
{ {
const bool objcExt = m_projectPart->languageExtensions & ProjectPart::ObjectiveCExtensions; const bool objcExt = m_projectPart.languageExtensions & ProjectPart::ObjectiveCExtensions;
const QStringList options = createLanguageOptionGcc(fileKind, objcExt); const QStringList options = createLanguageOptionGcc(fileKind, objcExt);
m_options.append(options); m_options.append(options);
} }
...@@ -653,9 +653,9 @@ void CompilerOptionsBuilder::addLanguageOption(ProjectFile::Kind fileKind) ...@@ -653,9 +653,9 @@ void CompilerOptionsBuilder::addLanguageOption(ProjectFile::Kind fileKind)
void CompilerOptionsBuilder::addOptionsForLanguage(bool checkForBorlandExtensions) void CompilerOptionsBuilder::addOptionsForLanguage(bool checkForBorlandExtensions)
{ {
QStringList opts; QStringList opts;
const ProjectPart::LanguageExtensions languageExtensions = m_projectPart->languageExtensions; const ProjectPart::LanguageExtensions languageExtensions = m_projectPart.languageExtensions;
const bool gnuExtensions = languageExtensions & ProjectPart::GnuExtensions; const bool gnuExtensions = languageExtensions & ProjectPart::GnuExtensions;
switch (m_projectPart->languageVersion) { switch (m_projectPart.languageVersion) {
case ProjectPart::C89: case ProjectPart::C89:
opts << (gnuExtensions ? QLatin1String("-std=gnu89") : QLatin1String("-std=c89")); opts << (gnuExtensions ? QLatin1String("-std=gnu89") : QLatin1String("-std=c89"));
break; break;
...@@ -716,7 +716,7 @@ bool CompilerOptionsBuilder::excludeDefineLine(const QByteArray &defineLine) con ...@@ -716,7 +716,7 @@ 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.
const bool isGccToolchain = m_projectPart->toolchainType == ProjectExplorer::Constants::GCC_TOOLCHAIN_TYPEID; const bool isGccToolchain = m_projectPart.toolchainType == ProjectExplorer::Constants::GCC_TOOLCHAIN_TYPEID;
if (isGccToolchain && defineLine.contains("has_include")) if (isGccToolchain && defineLine.contains("has_include"))
return true; return true;
......
...@@ -215,7 +215,7 @@ private: ...@@ -215,7 +215,7 @@ private:
class CPPTOOLS_EXPORT CompilerOptionsBuilder class CPPTOOLS_EXPORT CompilerOptionsBuilder
{ {
public: public:
CompilerOptionsBuilder(const ProjectPart::Ptr &projectPart); CompilerOptionsBuilder(const ProjectPart &projectPart);
virtual ~CompilerOptionsBuilder() {} virtual ~CompilerOptionsBuilder() {}
QStringList options() const; QStringList options() const;
...@@ -237,7 +237,7 @@ protected: ...@@ -237,7 +237,7 @@ protected:
virtual QString defineOption() const; virtual QString defineOption() const;
virtual QString includeOption() const; virtual QString includeOption() const;
const ProjectPart::Ptr m_projectPart; const ProjectPart m_projectPart;
private: private:
QString defineLineToDefineOption(const QByteArray &defineLine); QString defineLineToDefineOption(const QByteArray &defineLine);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment