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
static QStringList languageOptions(const QString &filePath, CppTools::ProjectPart *projectPart)
{
const auto theProjectPart = CppTools::ProjectPart::Ptr(
new CppTools::ProjectPart(projectPartForLanguageOption(projectPart)));
const auto theProjectPart = projectPartForLanguageOption(projectPart);
CppTools::CompilerOptionsBuilder builder(theProjectPart);
builder.addLanguageOption(CppTools::ProjectFile::classify(filePath));
......
......@@ -112,7 +112,7 @@ public:
if (projectPart.isNull())
return QStringList();
LibClangOptionsBuilder optionsBuilder(projectPart);
LibClangOptionsBuilder optionsBuilder(*projectPart.data());
if (verboseRunLog().isDebugEnabled())
optionsBuilder.add(QLatin1String("-v"));
......@@ -135,7 +135,7 @@ public:
}
private:
LibClangOptionsBuilder(const CppTools::ProjectPart::Ptr &projectPart)
LibClangOptionsBuilder(const CppTools::ProjectPart &projectPart)
: CompilerOptionsBuilder(projectPart)
{
}
......@@ -171,7 +171,7 @@ private:
static const QString wrappedQtHeaders = ICore::instance()->resourcePath()
+ QLatin1String("/cplusplus/wrappedQtHeaders");
if (m_projectPart->qtVersion != ProjectPart::NoQt) {
if (m_projectPart.qtVersion != ProjectPart::NoQt) {
add(QLatin1String("-I") + wrappedQtHeaders);
add(QLatin1String("-I") + wrappedQtHeaders + QLatin1String("/QtCore"));
}
......@@ -179,9 +179,9 @@ private:
void addProjectConfigFileInclude()
{
if (!m_projectPart->projectConfigFile.isEmpty()) {
if (!m_projectPart.projectConfigFile.isEmpty()) {
add(QLatin1String("-include"));
add(m_projectPart->projectConfigFile);
add(m_projectPart.projectConfigFile);
}
}
......@@ -213,7 +213,7 @@ private:
add(QStringLiteral("-Wno-documentation"));
add(QStringLiteral("-Wno-shadow"));
if (m_projectPart->languageVersion >= ProjectPart::CXX98)
if (m_projectPart.languageVersion >= ProjectPart::CXX98)
add(QStringLiteral("-Wno-missing-prototypes"));
}
};
......
......@@ -505,7 +505,7 @@ void ProjectPartBuilder::createProjectPart(const QStringList &theSources,
}
CompilerOptionsBuilder::CompilerOptionsBuilder(const ProjectPart::Ptr &projectPart)
CompilerOptionsBuilder::CompilerOptionsBuilder(const ProjectPart &projectPart)
: m_projectPart(projectPart)
{
}
......@@ -544,7 +544,7 @@ void CompilerOptionsBuilder::addHeaderPathOptions()
QStringList result;
foreach (const HeaderPath &headerPath , m_projectPart->headerPaths) {
foreach (const HeaderPath &headerPath , m_projectPart.headerPaths) {
if (headerPath.path.isEmpty())
continue;
......@@ -571,7 +571,7 @@ void CompilerOptionsBuilder::addHeaderPathOptions()
void CompilerOptionsBuilder::addToolchainAndProjectDefines()
{
QByteArray extendedDefines = m_projectPart->toolchainDefines + m_projectPart->projectDefines;
QByteArray extendedDefines = m_projectPart.toolchainDefines + m_projectPart.projectDefines;
QStringList result;
foreach (QByteArray def, extendedDefines.split('\n')) {
......@@ -645,7 +645,7 @@ static QStringList createLanguageOptionGcc(ProjectFile::Kind fileKind, bool objc
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);
m_options.append(options);
}
......@@ -653,9 +653,9 @@ void CompilerOptionsBuilder::addLanguageOption(ProjectFile::Kind fileKind)
void CompilerOptionsBuilder::addOptionsForLanguage(bool checkForBorlandExtensions)
{
QStringList opts;
const ProjectPart::LanguageExtensions languageExtensions = m_projectPart->languageExtensions;
const ProjectPart::LanguageExtensions languageExtensions = m_projectPart.languageExtensions;
const bool gnuExtensions = languageExtensions & ProjectPart::GnuExtensions;
switch (m_projectPart->languageVersion) {
switch (m_projectPart.languageVersion) {
case ProjectPart::C89:
opts << (gnuExtensions ? QLatin1String("-std=gnu89") : QLatin1String("-std=c89"));
break;
......@@ -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
// override clang's own (non-macro, it seems) definitions of the symbols on the left-hand
// 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"))
return true;
......
......@@ -215,7 +215,7 @@ private:
class CPPTOOLS_EXPORT CompilerOptionsBuilder
{
public:
CompilerOptionsBuilder(const ProjectPart::Ptr &projectPart);
CompilerOptionsBuilder(const ProjectPart &projectPart);
virtual ~CompilerOptionsBuilder() {}
QStringList options() const;
......@@ -237,7 +237,7 @@ protected:
virtual QString defineOption() const;
virtual QString includeOption() const;
const ProjectPart::Ptr m_projectPart;
const ProjectPart m_projectPart;
private:
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