Commit 990cedeb authored by Erik Verbruggen's avatar Erik Verbruggen

C++: remove C/C++ distinction from ProjectPart fields.

.. because they now hold only files for a single language+extensions
combination.

Task-number: QTCREATORBUG-11709
Task-number: QTCREATORBUG-12818
Change-Id: If294f6de07d60126be733d98de12b89b8af3efce
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 193cb3b9
......@@ -164,27 +164,11 @@ static QString getResourceDir()
*/
QStringList createClangOptions(const ProjectPart::Ptr &pPart, ProjectFile::Kind fileKind)
{
QStringList result = clangLanguageOption(fileKind);
switch (fileKind) {
default:
case CppTools::ProjectFile::CXXHeader:
case CppTools::ProjectFile::CXXSource:
case CppTools::ProjectFile::ObjCXXHeader:
case CppTools::ProjectFile::ObjCXXSource:
case CppTools::ProjectFile::CudaSource:
case CppTools::ProjectFile::OpenCLSource:
result << clangOptionsForCxx(pPart->qtVersion,
pPart->cxxVersion,
pPart->cxxExtensions);
break;
case CppTools::ProjectFile::CHeader:
case CppTools::ProjectFile::CSource:
case CppTools::ProjectFile::ObjCHeader:
case CppTools::ProjectFile::ObjCSource:
result << clangOptionsForC(pPart->cVersion,
pPart->cxxExtensions);
break;
}
const bool objcExt = pPart->languageExtensions & ProjectPart::ObjectiveCExtensions;
QStringList result = clangLanguageOption(fileKind, objcExt);
result << clangOptionsForLanguage(pPart->qtVersion,
pPart->languageVersion,
pPart->languageExtensions);
if (pPart.isNull())
return result;
......@@ -204,6 +188,7 @@ QStringList createClangOptions(const ProjectPart::Ptr &pPart, ProjectFile::Kind
result << QLatin1String("-fdiagnostics-show-note-include-stack");
result << QLatin1String("-fmacro-backtrace-limit=0");
result << QLatin1String("-fretain-comments-from-system-headers");
// TODO: -Xclang -ferror-limit -Xclang 0 ?
if (!pPart->projectConfigFile.isEmpty())
result << QLatin1String("-include") << pPart->projectConfigFile;
......@@ -263,57 +248,45 @@ QStringList createPCHInclusionOptions(const QString &pchFile)
}
/// @return "-std" flag to select standard, flags for C extensions
QStringList clangOptionsForC(ProjectPart::CVersion cVersion, ProjectPart::CXXExtensions cxxExtensions)
/// @return "-std" flag to select standard, flags for C++ extensions, Qt injections
QStringList clangOptionsForLanguage(CppTools::ProjectPart::QtVersion qtVersion,
CppTools::ProjectPart::LanguageVersion languageVersion,
ProjectPart::LanguageExtensions languageExtensions)
{
QStringList opts;
bool gnuExpensions = cxxExtensions & ProjectPart::GnuExtensions;
switch (cVersion) {
bool gnuExtensions = languageExtensions & ProjectPart::GnuExtensions;
switch (languageVersion) {
case ProjectPart::C89:
opts << (gnuExpensions ? QLatin1String("-std=gnu89") : QLatin1String("-std=c89"));
opts << (gnuExtensions ? QLatin1String("-std=gnu89") : QLatin1String("-std=c89"));
break;
case ProjectPart::C99:
opts << (gnuExpensions ? QLatin1String("-std=gnu99") : QLatin1String("-std=c99"));
opts << (gnuExtensions ? QLatin1String("-std=gnu99") : QLatin1String("-std=c99"));
break;
case ProjectPart::C11:
opts << (gnuExpensions ? QLatin1String("-std=gnu11") : QLatin1String("-std=c11"));
opts << (gnuExtensions ? QLatin1String("-std=gnu11") : QLatin1String("-std=c11"));
break;
}
if (cxxExtensions & ProjectPart::MicrosoftExtensions) {
opts << QLatin1String("-fms-extensions");
}
#if defined(CINDEX_VERSION) // clang 3.2 or higher
if (cxxExtensions & ProjectPart::BorlandExtensions)
opts << QLatin1String("-fborland-extensions");
#endif
return opts;
}
/// @return "-std" flag to select standard, flags for C++ extensions, Qt injections
QStringList clangOptionsForCxx(ProjectPart::QtVersion qtVersion,
ProjectPart::CXXVersion cxxVersion,
ProjectPart::CXXExtensions cxxExtensions)
{
QStringList opts;
bool gnuExpensions = cxxExtensions & ProjectPart::GnuExtensions;
switch (cxxVersion) {
case ProjectPart::CXX11:
opts << (gnuExpensions ? QLatin1String("-std=gnu++11") : QLatin1String("-std=c++11"));
opts << (gnuExtensions ? QLatin1String("-std=gnu++11") : QLatin1String("-std=c++11"));
break;
case ProjectPart::CXX98:
opts << (gnuExpensions ? QLatin1String("-std=gnu++98") : QLatin1String("-std=c++98"));
opts << (gnuExtensions ? QLatin1String("-std=gnu++98") : QLatin1String("-std=c++98"));
break;
case ProjectPart::CXX03:
opts << QLatin1String("-std=c++03");
break;
case ProjectPart::CXX14:
opts << QLatin1String("-std=c++1y"); // TODO: change to c++14 after 3.5
break;
case ProjectPart::CXX17:
opts << QLatin1String("-std=c++1z"); // TODO: change to c++17 at some point in the future
break;
}
if (cxxExtensions & ProjectPart::MicrosoftExtensions) {
opts << QLatin1String("-fms-extensions")
<< QLatin1String("-fdelayed-template-parsing");
}
if (languageExtensions & ProjectPart::MicrosoftExtensions)
opts << QLatin1String("-fms-extensions");
#if defined(CINDEX_VERSION) // clang 3.2 or higher
if (cxxExtensions & ProjectPart::BorlandExtensions)
if (languageExtensions & ProjectPart::BorlandExtensions)
opts << QLatin1String("-fborland-extensions");
#endif
......@@ -327,37 +300,48 @@ QStringList clangOptionsForCxx(ProjectPart::QtVersion qtVersion,
}
/// @return "-x language-code"
QStringList clangLanguageOption(ProjectFile::Kind fileKind)
QStringList clangLanguageOption(ProjectFile::Kind fileKind, bool objcExt)
{
QStringList opts;
opts += QLatin1String("-x");
switch (fileKind) {
case ProjectFile::CHeader:
// opts += QLatin1String("c-header");
// break;
if (objcExt)
opts += QLatin1String("objective-c-header");
else
opts += QLatin1String("c-header");
break;
case ProjectFile::CXXHeader:
default:
opts += QLatin1String("c++-header");
break;
case ProjectFile::CXXSource:
opts += QLatin1String("c++");
break;
case ProjectFile::CSource:
opts += QLatin1String("c");
break;
if (!objcExt) {
opts += QLatin1String("c++-header");
break;
} // else: fall-through!
case ProjectFile::ObjCHeader:
// opts += QLatin1String("objective-c-header");
// break;
case ProjectFile::ObjCXXHeader:
opts += QLatin1String("objective-c++-header");
break;
case ProjectFile::CSource:
if (!objcExt) {
opts += QLatin1String("c");
break;
} // else: fall-through!
case ProjectFile::ObjCSource:
opts += QLatin1String("objective-c");
break;
case ProjectFile::CXXSource:
if (!objcExt) {
opts += QLatin1String("c++");
break;
} // else: fall-through!
case ProjectFile::ObjCXXSource:
opts += QLatin1String("objective-c++");
break;
case ProjectFile::OpenCLSource:
opts += QLatin1String("cl");
break;
......
......@@ -45,12 +45,10 @@ QStringList clangNonProjectFileOptions(CppTools::ProjectFile::Kind kind);
QStringList createPCHInclusionOptions(const QStringList &pchFiles);
QStringList createPCHInclusionOptions(const QString &pchFile);
QStringList clangLanguageOption(CppTools::ProjectFile::Kind fileKind);
QStringList clangOptionsForC(CppTools::ProjectPart::CVersion cVersion,
CppTools::ProjectPart::CXXExtensions cxxExtensions);
QStringList clangOptionsForCxx(CppTools::ProjectPart::QtVersion qtVersion,
CppTools::ProjectPart::CXXVersion cxxVersion,
CppTools::ProjectPart::CXXExtensions cxxExtensions);
QStringList clangLanguageOption(CppTools::ProjectFile::Kind fileKind, bool objcExt);
QStringList clangOptionsForLanguage(CppTools::ProjectPart::QtVersion qtVersion,
CppTools::ProjectPart::LanguageVersion languageVersion,
CppTools::ProjectPart::LanguageExtensions languageExtensions);
} // namespace Utils
} // namespace Clang
......
......@@ -253,9 +253,8 @@ void PchManager::doPchInfoUpdateFuzzy(QFutureInterface<void> &future,
QHash<QString, bool> objc;
QHash<QString, bool> cplusplus;
QHash<QString, ProjectPart::QtVersion> qtVersions;
QHash<QString, ProjectPart::CVersion> cVersions;
QHash<QString, ProjectPart::CXXVersion> cxxVersions;
QHash<QString, ProjectPart::CXXExtensions> cxxExtensionsMap;
QHash<QString, ProjectPart::LanguageVersion> languageVersions;
QHash<QString, ProjectPart::LanguageExtensions> languageExtensionsMap;
QHash<QString, QList<ProjectPart::Ptr> > inputToParts;
foreach (const ProjectPart::Ptr &projectPart, params.projectParts) {
if (projectPart->precompiledHeaders.isEmpty())
......@@ -266,9 +265,9 @@ void PchManager::doPchInfoUpdateFuzzy(QFutureInterface<void> &future,
inputToParts[pch].append(projectPart);
headers[pch].unite(QSet<HeaderPath>::fromList(projectPart->headerPaths));
cVersions[pch] = std::max(cVersions.value(pch, ProjectPart::C89), projectPart->cVersion);
cxxVersions[pch] = std::max(cxxVersions.value(pch, ProjectPart::CXX98), projectPart->cxxVersion);
cxxExtensionsMap[pch] = cxxExtensionsMap[pch] | projectPart->cxxExtensions;
languageVersions[pch] = std::max(languageVersions.value(pch, ProjectPart::C89),
projectPart->languageVersion);
languageExtensionsMap[pch] = languageExtensionsMap[pch] | projectPart->languageExtensions;
if (hasObjCFiles(projectPart))
objc[pch] = true;
......@@ -301,9 +300,8 @@ void PchManager::doPchInfoUpdateFuzzy(QFutureInterface<void> &future,
return;
ProjectPart::Ptr projectPart(new ProjectPart);
projectPart->qtVersion = qtVersions[pch];
projectPart->cVersion = cVersions[pch];
projectPart->cxxVersion = cxxVersions[pch];
projectPart->cxxExtensions = cxxExtensionsMap[pch];
projectPart->languageVersion = languageVersions[pch];
projectPart->languageExtensions = languageExtensionsMap[pch];
projectPart->headerPaths = headers[pch].toList();
QList<QByteArray> defines = definesPerPCH[pch].toList();
......@@ -379,11 +377,10 @@ void PchManager::doPchInfoUpdateCustom(QFutureInterface<void> &future,
bool objc = false;
bool cplusplus = false;
ProjectPart::Ptr united(new ProjectPart());
united->cxxVersion = ProjectPart::CXX98;
united->languageVersion = ProjectPart::C89;
foreach (const ProjectPart::Ptr &projectPart, params.projectParts) {
headers += projectPart->headerPaths;
united->cVersion = std::max(united->cVersion, projectPart->cVersion);
united->cxxVersion = std::max(united->cxxVersion, projectPart->cxxVersion);
united->languageVersion = std::max(united->languageVersion, projectPart->languageVersion);
united->qtVersion = std::max(united->qtVersion, projectPart->qtVersion);
objc |= hasObjCFiles(projectPart);
cplusplus |= hasCppFiles(projectPart);
......
......@@ -1619,12 +1619,10 @@ void CppCodeModelInspectorDialog::updateProjectPartData(const ProjectPart::Ptr &
QDir::toNativeSeparators(part->projectFile))
<< qMakePair(QString::fromLatin1("Project Name"), projectName)
<< qMakePair(QString::fromLatin1("Project File"), projectFilePath)
<< qMakePair(QString::fromLatin1("C Version"),
CMI::Utils::toString(part->cVersion))
<< qMakePair(QString::fromLatin1("CXX Version"),
CMI::Utils::toString(part->cxxVersion))
<< qMakePair(QString::fromLatin1("CXX Extensions"),
CMI::Utils::toString(part->cxxExtensions))
<< qMakePair(QString::fromLatin1("Language Version"),
CMI::Utils::toString(part->languageVersion))
<< qMakePair(QString::fromLatin1("Language Extensions"),
CMI::Utils::toString(part->languageExtensions))
<< qMakePair(QString::fromLatin1("Qt Version"),
CMI::Utils::toString(part->qtVersion))
;
......
......@@ -90,44 +90,38 @@ QString Utils::toString(CPlusPlus::Document::DiagnosticMessage::Level level)
return QString();
}
QString Utils::toString(ProjectPart::CVersion cVersion)
QString Utils::toString(ProjectPart::LanguageVersion languageVersion)
{
#define CASE_CVERSION(x) case ProjectPart::x: return QLatin1String(#x)
switch (cVersion) {
CASE_CVERSION(C89);
CASE_CVERSION(C99);
CASE_CVERSION(C11);
#define CASE_LANGUAGEVERSION(x) case ProjectPart::x: return QLatin1String(#x)
switch (languageVersion) {
CASE_LANGUAGEVERSION(C89);
CASE_LANGUAGEVERSION(C99);
CASE_LANGUAGEVERSION(C11);
CASE_LANGUAGEVERSION(CXX98);
CASE_LANGUAGEVERSION(CXX03);
CASE_LANGUAGEVERSION(CXX11);
CASE_LANGUAGEVERSION(CXX14);
CASE_LANGUAGEVERSION(CXX17);
// no default to get a compiler warning if anything is added
}
#undef CASE_CVERSION
#undef CASE_LANGUAGEVERSION
return QString();
}
QString Utils::toString(ProjectPart::CXXVersion cxxVersion)
{
#define CASE_CXXVERSION(x) case ProjectPart::x: return QLatin1String(#x)
switch (cxxVersion) {
CASE_CXXVERSION(CXX98);
CASE_CXXVERSION(CXX11);
// no default to get a compiler warning if anything is added
}
#undef CASE_CXXVERSION
return QString();
}
QString Utils::toString(ProjectPart::CXXExtensions cxxExtension)
QString Utils::toString(ProjectPart::LanguageExtensions languageExtension)
{
QString result;
#define CASE_CXXEXTENSION(ext) if (cxxExtension & ProjectPart::ext) \
#define CASE_LANGUAGE_EXTENSION(ext) if (languageExtension & ProjectPart::ext) \
result += QLatin1String(#ext ", ");
CASE_CXXEXTENSION(NoExtensions);
CASE_CXXEXTENSION(GnuExtensions);
CASE_CXXEXTENSION(MicrosoftExtensions);
CASE_CXXEXTENSION(BorlandExtensions);
CASE_CXXEXTENSION(OpenMPExtensions);
#undef CASE_CXXEXTENSION
CASE_LANGUAGE_EXTENSION(NoExtensions);
CASE_LANGUAGE_EXTENSION(GnuExtensions);
CASE_LANGUAGE_EXTENSION(MicrosoftExtensions);
CASE_LANGUAGE_EXTENSION(BorlandExtensions);
CASE_LANGUAGE_EXTENSION(OpenMPExtensions);
CASE_LANGUAGE_EXTENSION(ObjectiveCExtensions);
#undef CASE_LANGUAGE_EXTENSION
if (result.endsWith(QLatin1String(", ")))
result.chop(2);
return result;
......@@ -496,13 +490,13 @@ void Dumper::dumpProjectInfos( const QList<ProjectInfo> &projectInfos)
if (!part->projectConfigFile.isEmpty())
m_out << i3 << "Project Config File: " << part->projectConfigFile << "\n";
m_out << i2 << "Project Part \"" << part->projectFile << "\"{{{3\n";
m_out << i3 << "Project Part Name : " << part->displayName << "\n";
m_out << i3 << "Project Name : " << projectName << "\n";
m_out << i3 << "Project File : " << projectFilePath << "\n";
m_out << i3 << "C Version : " << Utils::toString(part->cVersion) << "\n";
m_out << i3 << "CXX Version : " << Utils::toString(part->cxxVersion) << "\n";
m_out << i3 << "CXX Extensions : " << Utils::toString(part->cxxExtensions) << "\n";
m_out << i3 << "Qt Version : " << Utils::toString(part->qtVersion) << "\n";
m_out << i3 << "Project Part Name : " << part->displayName << "\n";
m_out << i3 << "Project Name : " << projectName << "\n";
m_out << i3 << "Project File : " << projectFilePath << "\n";
m_out << i3 << "Lanugage Version : " << Utils::toString(part->languageVersion)<<"\n";
m_out << i3 << "Lanugage Extensions : " << Utils::toString(part->languageExtensions)
<< "\n";
m_out << i3 << "Qt Version : " << Utils::toString(part->qtVersion) << "\n";
if (!part->files.isEmpty()) {
m_out << i3 << "Files:{{{4\n";
......
......@@ -48,9 +48,8 @@ struct CPPTOOLS_EXPORT Utils
static QString toString(const QDateTime &dateTime);
static QString toString(CPlusPlus::Document::CheckMode checkMode);
static QString toString(CPlusPlus::Document::DiagnosticMessage::Level level);
static QString toString(CppTools::ProjectPart::CVersion cVersion);
static QString toString(CppTools::ProjectPart::CXXVersion cxxVersion);
static QString toString(CppTools::ProjectPart::CXXExtensions cxxExtension);
static QString toString(CppTools::ProjectPart::LanguageVersion languageVersion);
static QString toString(CppTools::ProjectPart::LanguageExtensions languageExtension);
static QString toString(CppTools::ProjectPart::QtVersion qtVersion);
static QString toString(const QList<CppTools::ProjectFile> &projectFiles);
static QString toString(CppTools::ProjectFile::Kind kind);
......
......@@ -746,9 +746,8 @@ ProjectPart::Ptr CppModelManager::fallbackProjectPart() const
part->projectDefines = m_definedMacros;
part->headerPaths = m_headerPaths;
part->cVersion = ProjectPart::C11;
part->cxxVersion = ProjectPart::CXX11;
part->cxxExtensions = ProjectPart::AllExtensions;
part->languageVersion = ProjectPart::CXX14;
part->languageExtensions = ProjectPart::AllExtensions;
part->qtVersion = ProjectPart::Qt5;
return part;
......
......@@ -97,7 +97,7 @@ public:
QCOMPARE(projectInfo.project().data(), project);
ProjectPart::Ptr part(new ProjectPart);
part->cxxVersion = ProjectPart::CXX98;
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
foreach (const QString &file, projectFiles) {
ProjectFile projectFile(file, ProjectFile::classify(file));
......@@ -221,7 +221,7 @@ void CppToolsPlugin::test_modelmanager_paths_are_clean()
typedef ProjectPart::HeaderPath HeaderPath;
ProjectPart::Ptr part(new ProjectPart);
part->cxxVersion = ProjectPart::CXX98;
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->projectDefines = QByteArray("#define OH_BEHAVE -1\n");
part->headerPaths = QList<HeaderPath>()
......@@ -257,7 +257,7 @@ void CppToolsPlugin::test_modelmanager_framework_headers()
typedef ProjectPart::HeaderPath HeaderPath;
ProjectPart::Ptr part(new ProjectPart);
part->cxxVersion = ProjectPart::CXX98;
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->projectDefines = QByteArray("#define OH_BEHAVE -1\n");
part->headerPaths = QList<HeaderPath>()
......@@ -310,7 +310,7 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
typedef ProjectPart::HeaderPath HeaderPath;
ProjectPart::Ptr part(new ProjectPart);
part->cxxVersion = ProjectPart::CXX98;
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->projectDefines = QByteArray("#define OH_BEHAVE -1\n");
part->headerPaths = QList<HeaderPath>()
......@@ -371,7 +371,7 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times()
QCOMPARE(pi.project().data(), project);
ProjectPart::Ptr part(new ProjectPart);
part->cxxVersion = ProjectPart::CXX98;
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->files.append(ProjectFile(testHeader1, ProjectFile::CXXHeader));
part->files.append(ProjectFile(testHeader2, ProjectFile::CXXHeader));
......@@ -391,7 +391,7 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times()
// Simulate project configuration change by having different defines each time.
defines += "\n#define ANOTHER_DEFINE";
part->projectDefines = defines;
part->cxxVersion = ProjectPart::CXX98;
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->files.append(ProjectFile(testHeader1, ProjectFile::CXXHeader));
part->files.append(ProjectFile(testHeader2, ProjectFile::CXXHeader));
......@@ -438,7 +438,7 @@ void CppToolsPlugin::test_modelmanager_refresh_test_for_changes()
QCOMPARE(pi.project().data(), project);
ProjectPart::Ptr part(new ProjectPart);
part->cxxVersion = ProjectPart::CXX98;
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part);
......@@ -476,7 +476,7 @@ void CppToolsPlugin::test_modelmanager_refresh_added_and_purge_removed()
QCOMPARE(pi.project().data(), project);
ProjectPart::Ptr part(new ProjectPart);
part->cxxVersion = ProjectPart::CXX98;
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
part->files.append(ProjectFile(testHeader1, ProjectFile::CXXHeader));
......@@ -499,7 +499,7 @@ void CppToolsPlugin::test_modelmanager_refresh_added_and_purge_removed()
// Now add testHeader2 and remove testHeader1
pi.clearProjectParts();
ProjectPart::Ptr newPart(new ProjectPart);
newPart->cxxVersion = ProjectPart::CXX98;
newPart->languageVersion = ProjectPart::CXX14;
newPart->qtVersion = ProjectPart::Qt5;
newPart->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
newPart->files.append(ProjectFile(testHeader2, ProjectFile::CXXHeader));
......@@ -535,7 +535,7 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
QCOMPARE(pi.project().data(), project);
ProjectPart::Ptr part(new ProjectPart);
part->cxxVersion = ProjectPart::CXX98;
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
foreach (const ProjectFile &file, initialProjectFiles)
part->files.append(file);
......@@ -829,7 +829,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
part1->projectFile = QLatin1String("project1.projectfile");
part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource));
part1->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part1->cxxVersion = ProjectPart::CXX11;
part1->languageVersion = ProjectPart::CXX11;
part1->qtVersion = ProjectPart::NoQt;
part1->projectDefines = QByteArray("#define SUB1\n");
part1->headerPaths = QList<HeaderPath>()
......@@ -839,7 +839,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
part2->projectFile = QLatin1String("project1.projectfile");
part2->files.append(ProjectFile(main2File, ProjectFile::CXXSource));
part2->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part2->cxxVersion = ProjectPart::CXX11;
part2->languageVersion = ProjectPart::CXX11;
part2->qtVersion = ProjectPart::NoQt;
part2->projectDefines = QByteArray("#define SUB2\n");
part2->headerPaths = QList<HeaderPath>()
......@@ -905,7 +905,7 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
part1->projectFile = QLatin1String("project1.projectfile");
part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource));
part1->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part1->cxxVersion = ProjectPart::CXX11;
part1->languageVersion = ProjectPart::CXX11;
part1->qtVersion = ProjectPart::NoQt;
part1->precompiledHeaders.append(pch1File);
part1->headerPaths = QList<HeaderPath>()
......@@ -915,7 +915,7 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
part2->projectFile = QLatin1String("project2.projectfile");
part2->files.append(ProjectFile(main2File, ProjectFile::CXXSource));
part2->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part2->cxxVersion = ProjectPart::CXX11;
part2->languageVersion = ProjectPart::CXX11;
part2->qtVersion = ProjectPart::NoQt;
part2->precompiledHeaders.append(pch2File);
part2->headerPaths = QList<HeaderPath>()
......@@ -989,7 +989,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
ProjectPart::Ptr part1(new ProjectPart);
part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource));
part1->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part1->cxxVersion = ProjectPart::CXX11;
part1->languageVersion = ProjectPart::CXX11;
part1->qtVersion = ProjectPart::NoQt;
part1->headerPaths = QList<HeaderPath>()
<< HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath);
......@@ -997,7 +997,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
ProjectPart::Ptr part2(new ProjectPart);
part2->files.append(ProjectFile(main2File, ProjectFile::CXXSource));
part2->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part2->cxxVersion = ProjectPart::CXX11;
part2->languageVersion = ProjectPart::CXX11;
part2->qtVersion = ProjectPart::NoQt;
part2->headerPaths = QList<HeaderPath>()
<< HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath);
......
......@@ -44,12 +44,10 @@ using namespace ProjectExplorer;
ProjectPart::ProjectPart()
: project(0)
, cVersion(C89)
, cxxVersion(CXX11)
, cxxExtensions(NoExtensions)
, languageVersion(CXX14)
, languageExtensions(NoExtensions)
, qtVersion(UnknownQt)
, cWarningFlags(ProjectExplorer::ToolChain::WarningsDefault)
, cxxWarningFlags(ProjectExplorer::ToolChain::WarningsDefault)
, warningFlags(ProjectExplorer::ToolChain::WarningsDefault)
{
}
......@@ -61,43 +59,42 @@ ProjectPart::ProjectPart()
\param cflags C or ObjectiveC flags if possible, \a cxxflags otherwise.
*/
void ProjectPart::evaluateToolchain(const ProjectExplorer::ToolChain *tc,
const QStringList &cxxflags,
const QStringList &cflags,
const QStringList &commandLineFlags,
const Utils::FileName &sysRoot)
{
if (!tc)
return;
using namespace ProjectExplorer;
ToolChain::CompilerFlags cxx = tc->compilerFlags(cxxflags);
ToolChain::CompilerFlags c = (cxxflags == cflags)
? cxx : tc->compilerFlags(cflags);
if (c & ToolChain::StandardC11)
cVersion = C11;
else if (c & ToolChain::StandardC99)
cVersion = C99;
ToolChain::CompilerFlags flags = tc->compilerFlags(commandLineFlags);
if (flags & ToolChain::StandardC11)
languageVersion = C11;
else if (flags & ToolChain::StandardC99)
languageVersion = C99;
else if (flags & ToolChain::StandardCxx17)
languageVersion = CXX17;
else if (flags & ToolChain::StandardCxx14)
languageVersion = CXX14;
else if (flags & ToolChain::StandardCxx11)
languageVersion = CXX11;
else
cVersion = C89;
if (cxx & ToolChain::StandardCxx11)
cxxVersion = CXX11;
else
cxxVersion = CXX98;
if (cxx & ToolChain::BorlandExtensions)
cxxExtensions |= BorlandExtensions;
if (cxx & ToolChain::GnuExtensions)
cxxExtensions |= GnuExtensions;
if (cxx & ToolChain::MicrosoftExtensions)
cxxExtensions |= MicrosoftExtensions;
if (cxx & ToolChain::OpenMP)
cxxExtensions |= OpenMPExtensions;
cWarningFlags = tc->warningFlags(cflags);
cxxWarningFlags = tc->warningFlags(cxxflags);
const QList<ProjectExplorer::HeaderPath> headers = tc->systemHeaderPaths(cxxflags, sysRoot);
languageVersion = CXX11;
if (flags & ToolChain::BorlandExtensions)
languageExtensions |= BorlandExtensions;
if (flags & ToolChain::GnuExtensions)
languageExtensions |= GnuExtensions;
if (flags & ToolChain::MicrosoftExtensions)
languageExtensions |= MicrosoftExtensions;
if (flags & ToolChain::OpenMP)
languageExtensions |= OpenMPExtensions;
if (flags & ToolChain::ObjectiveC)
languageExtensions |= ObjectiveCExtensions;