From d62278afd55c87101de7c7a9327f06cf5326af0b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 26 Jun 2018 10:43:52 +0200 Subject: shiboken: No longer hard-code the C++ language level The C++ language level was previously hard-coded in the default options. This is potentially problematic for projects using shiboken and also fell apart with Qt 5.12, where the experimental level "c++1z" used for MSVC2017/Clang 4 no longer works due to not being able to handle enumerator value deprecation attributes. Introduce an enumeration to represent the level and add functions to convert back to and forth to the respective Clang option. Add an option to shiboken. Add a function returning a default value for the emulated compiler, returning C++ 14 or C++1Z for the CMSVC2017/Clang 4 case. Task-number: PYSIDE-724 Change-Id: Ie7e19bf7f099a34e6cdaad4b462157a9a3ee8797 Reviewed-by: Christian Tismer --- sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp') diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index 09d10580c..1d8a349f1 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -32,6 +32,7 @@ #include #include +#include #include "parser/codemodel.h" @@ -443,10 +444,15 @@ void AbstractMetaBuilderPrivate::sortLists() cls->sortFunctions(); } -FileModelItem AbstractMetaBuilderPrivate::buildDom(const QByteArrayList &arguments, +FileModelItem AbstractMetaBuilderPrivate::buildDom(QByteArrayList arguments, + LanguageLevel level, unsigned clangFlags) { clang::Builder builder; + if (level == LanguageLevel::Default) + level = clang::emulatedCompilerLanguageLevel(); + arguments.prepend(QByteArrayLiteral("-std=") + + clang::languageLevelOption(level)); FileModelItem result = clang::parse(arguments, clangFlags, builder) ? builder.dom() : FileModelItem(); const clang::BaseVisitor::Diagnostics &diagnostics = builder.diagnostics(); @@ -726,9 +732,11 @@ void AbstractMetaBuilderPrivate::traverseDom(const FileModelItem &dom) std::puts(""); } -bool AbstractMetaBuilder::build(const QByteArrayList &arguments, unsigned clangFlags) +bool AbstractMetaBuilder::build(const QByteArrayList &arguments, + LanguageLevel level, + unsigned clangFlags) { - const FileModelItem dom = d->buildDom(arguments, clangFlags); + const FileModelItem dom = d->buildDom(arguments, level, clangFlags); if (dom.isNull()) return false; if (ReportHandler::isDebug(ReportHandler::MediumDebug)) -- cgit v1.2.3