Commit a10bfb84 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools: Do not hardcode default language version

...instead, use the latest we support.

Change-Id: I7e7768bc4bc31de1fe0f441c03f3ab5d677d76e8
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
parent 602ad72d
......@@ -606,7 +606,6 @@ CppTools::ProjectPart::Ptr createProjectPart(const QStringList &files,
projectPart->projectFile = QLatin1String("myproject.project");
foreach (const QString &file, files)
projectPart->files.append(ProjectFile(file, ProjectFile::classify(file)));
projectPart->languageVersion = ProjectPart::CXX11;
projectPart->qtVersion = ProjectPart::NoQt;
projectPart->projectDefines = defines.toUtf8();
......
......@@ -130,28 +130,28 @@ QList<Core::Id> BaseProjectPartBuilder::createProjectPartsForFiles(const QString
if (cat.hasCSources()) {
createProjectPart(cat.cSources(),
cat.partName("C"),
ProjectPart::C11,
ProjectPart::LatestCVersion,
ProjectPart::NoExtensions);
}
if (cat.hasObjcSources()) {
createProjectPart(cat.objcSources(),
cat.partName("Obj-C"),
ProjectPart::C11,
ProjectPart::LatestCVersion,
ProjectPart::ObjectiveCExtensions);
}
if (cat.hasCxxSources()) {
createProjectPart(cat.cxxSources(),
cat.partName("C++"),
ProjectPart::CXX11,
ProjectPart::LatestCxxVersion,
ProjectPart::NoExtensions);
}
if (cat.hasObjcxxSources()) {
createProjectPart(cat.objcxxSources(),
cat.partName("Obj-C++"),
ProjectPart::CXX11,
ProjectPart::LatestCxxVersion,
ProjectPart::ObjectiveCExtensions);
}
}
......@@ -295,7 +295,7 @@ ToolChainInterfacePtr BaseProjectPartBuilder::selectToolChain(
{
ToolChainInterfacePtr toolChain = nullptr;
if (languageVersion < ProjectPart::CXX98)
if (languageVersion <= ProjectPart::LatestCVersion)
toolChain = m_project->toolChain(ProjectExplorer::ToolChain::Language::C, m_cFlags);
if (!toolChain) // Use Cxx toolchain for C projects without C compiler in kit and for C++ code
......
......@@ -949,7 +949,6 @@ ProjectPart::Ptr CppModelManager::fallbackProjectPart()
part->projectDefines = definedMacros();
part->headerPaths = headerPaths();
part->languageVersion = ProjectPart::CXX14;
// Do not activate ObjectiveCExtensions since this will lead to the
// "objective-c++" language option for a project-less *.cpp file.
......
......@@ -108,7 +108,6 @@ public:
projectInfo = ProjectInfo(project);
ProjectPart::Ptr part(new ProjectPart);
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
foreach (const QString &file, projectFiles) {
ProjectFile projectFile(file, ProjectFile::classify(file));
......@@ -187,7 +186,6 @@ void CppToolsPlugin::test_modelmanager_paths_are_clean()
typedef ProjectPartHeaderPath HeaderPath;
ProjectPart::Ptr part(new ProjectPart);
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->projectDefines = QByteArray("#define OH_BEHAVE -1\n");
part->headerPaths = { HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath),
......@@ -220,7 +218,6 @@ void CppToolsPlugin::test_modelmanager_framework_headers()
typedef ProjectPartHeaderPath HeaderPath;
ProjectPart::Ptr part(new ProjectPart);
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->projectDefines = QByteArray("#define OH_BEHAVE -1\n");
part->headerPaths = { HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath),
......@@ -270,7 +267,6 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
typedef ProjectPartHeaderPath HeaderPath;
ProjectPart::Ptr part(new ProjectPart);
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->projectDefines = QByteArray("#define OH_BEHAVE -1\n");
part->headerPaths = { HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath) };
......@@ -327,7 +323,6 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times()
ProjectInfo pi = ProjectInfo(project);
ProjectPart::Ptr part(new ProjectPart);
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->files.append(ProjectFile(testHeader1, ProjectFile::CXXHeader));
part->files.append(ProjectFile(testHeader2, ProjectFile::CXXHeader));
......@@ -346,7 +341,6 @@ 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->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->files.append(ProjectFile(testHeader1, ProjectFile::CXXHeader));
part->files.append(ProjectFile(testHeader2, ProjectFile::CXXHeader));
......@@ -391,7 +385,6 @@ void CppToolsPlugin::test_modelmanager_refresh_test_for_changes()
ProjectInfo pi = ProjectInfo(project);
ProjectPart::Ptr part(new ProjectPart);
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part);
......@@ -427,7 +420,6 @@ void CppToolsPlugin::test_modelmanager_refresh_added_and_purge_removed()
ProjectInfo pi = ProjectInfo(project);
ProjectPart::Ptr part(new ProjectPart);
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
part->files.append(ProjectFile(testHeader1, ProjectFile::CXXHeader));
......@@ -449,7 +441,6 @@ void CppToolsPlugin::test_modelmanager_refresh_added_and_purge_removed()
// Now add testHeader2 and remove testHeader1
pi = ProjectInfo(project);
ProjectPart::Ptr newPart(new ProjectPart);
newPart->languageVersion = ProjectPart::CXX14;
newPart->qtVersion = ProjectPart::Qt5;
newPart->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
newPart->files.append(ProjectFile(testHeader2, ProjectFile::CXXHeader));
......@@ -489,7 +480,6 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
ProjectInfo pi = ProjectInfo(project);
ProjectPart::Ptr part(new ProjectPart);
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
foreach (const QString &file, initialProjectFiles)
part->files.append(ProjectFile(file, ProjectFile::CXXSource));
......@@ -774,7 +764,6 @@ 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->languageVersion = ProjectPart::CXX11;
part1->qtVersion = ProjectPart::NoQt;
part1->projectDefines = QByteArray("#define SUB1\n");
part1->headerPaths = { HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath) };
......@@ -783,7 +772,6 @@ 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->languageVersion = ProjectPart::CXX11;
part2->qtVersion = ProjectPart::NoQt;
part2->projectDefines = QByteArray("#define SUB2\n");
part2->headerPaths = { HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath) };
......@@ -842,7 +830,6 @@ 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->languageVersion = ProjectPart::CXX11;
part1->qtVersion = ProjectPart::NoQt;
part1->precompiledHeaders.append(pch1File);
part1->headerPaths = { HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath) };
......@@ -851,7 +838,6 @@ 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->languageVersion = ProjectPart::CXX11;
part2->qtVersion = ProjectPart::NoQt;
part2->precompiledHeaders.append(pch2File);
part2->headerPaths = { HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath) };
......@@ -926,14 +912,12 @@ 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->languageVersion = ProjectPart::CXX11;
part1->qtVersion = ProjectPart::NoQt;
part1->headerPaths = { HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath) };
ProjectPart::Ptr part2(new ProjectPart);
part2->files.append(ProjectFile(main2File, ProjectFile::CXXSource));
part2->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part2->languageVersion = ProjectPart::CXX11;
part2->qtVersion = ProjectPart::NoQt;
part2->headerPaths = { HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath) };
......@@ -1014,7 +998,6 @@ void CppToolsPlugin::test_modelmanager_updateEditorsAfterProjectUpdate()
part->project = project;
part->files.append(ProjectFile(fileA, ProjectFile::CXXSource));
part->files.append(ProjectFile(fileB, ProjectFile::CXXSource));
part->languageVersion = ProjectPart::CXX11;
part->qtVersion = ProjectPart::NoQt;
ProjectInfo pi = ProjectInfo(project);
......
......@@ -34,7 +34,7 @@ ProjectPart::ProjectPart()
: project(0)
, toolChainWordWidth(WordWidth32Bit)
, isMsvc2015Toolchain(false)
, languageVersion(CXX14)
, languageVersion(LatestCxxVersion)
, languageExtensions(NoExtensions)
, qtVersion(UnknownQt)
, warningFlags(ProjectExplorer::WarningFlags::Default)
......
......@@ -54,11 +54,13 @@ public: // Types
C89,
C99,
C11,
LatestCVersion = C11,
CXX98,
CXX03,
CXX11,
CXX14,
CXX17,
LatestCxxVersion = CXX17,
};
enum LanguageExtension {
......
......@@ -365,7 +365,6 @@ void GenericProject::refreshCppCodeModel()
ppBuilder.setQtVersion(activeQtVersion);
ppBuilder.setIncludePaths(projectIncludePaths());
ppBuilder.setConfigFileName(configFileName());
ppBuilder.setCxxFlags(QStringList() << QLatin1String("-std=c++11"));
const QList<Id> languages = ppBuilder.createProjectPartsForFiles(files());
foreach (Id language, languages)
......
......@@ -156,7 +156,7 @@ TEST_F(BaseProjectPartBuilder, ProjectPartHasLatestLanguageVersionByDefault)
ASSERT_THAT(projectInfo.projectParts().size(), Eq(1));
const ProjectPart &projectPart = *projectInfo.projectParts().at(0);
ASSERT_THAT(projectPart.languageVersion, Eq(ProjectPart::CXX11));
ASSERT_THAT(projectPart.languageVersion, Eq(ProjectPart::LatestCxxVersion));
}
TEST_F(BaseProjectPartBuilder, ToolChainSetsLanguageVersion)
......@@ -197,13 +197,13 @@ TEST_F(BaseProjectPartBuilder, ProjectFileKindsMatchProjectPartVersion)
const QList<ProjectPart::Ptr> projectParts = projectInfo.projectParts();
ASSERT_THAT(projectParts.size(), Eq(4));
ASSERT_THAT(projectParts.at(0)->languageVersion, Eq(ProjectPart::C11));
ASSERT_THAT(projectParts.at(0)->languageVersion, Eq(ProjectPart::LatestCVersion));
ASSERT_THAT(projectParts.at(0)->files.at(0).kind, Eq(ProjectFile::CHeader));
ASSERT_THAT(projectParts.at(1)->languageVersion, Eq(ProjectPart::C11));
ASSERT_THAT(projectParts.at(1)->languageVersion, Eq(ProjectPart::LatestCVersion));
ASSERT_THAT(projectParts.at(1)->files.at(0).kind, Eq(ProjectFile::ObjCHeader));
ASSERT_THAT(projectParts.at(2)->languageVersion, Eq(ProjectPart::CXX11));
ASSERT_THAT(projectParts.at(2)->languageVersion, Eq(ProjectPart::LatestCxxVersion));
ASSERT_THAT(projectParts.at(2)->files.at(0).kind, Eq(ProjectFile::CXXHeader));
ASSERT_THAT(projectParts.at(3)->languageVersion, Eq(ProjectPart::CXX11));
ASSERT_THAT(projectParts.at(3)->languageVersion, Eq(ProjectPart::LatestCxxVersion));
ASSERT_THAT(projectParts.at(3)->files.at(0).kind, Eq(ProjectFile::ObjCXXHeader));
}
......
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