diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index f388524f114..794ce6b3d72 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -8,7 +8,7 @@ on: env: QT_VERSION: 6.2.3 - CLANG_VERSION: 140 + CLANG_VERSION: 14.0.0 ELFUTILS_VERSION: 0.175 CMAKE_VERSION: 3.21.1 NINJA_VERSION: 1.10.2 diff --git a/coin/instructions/common_environment.yaml b/coin/instructions/common_environment.yaml index d179b44b4a3..a2f189f473b 100644 --- a/coin/instructions/common_environment.yaml +++ b/coin/instructions/common_environment.yaml @@ -7,7 +7,7 @@ instructions: variableValue: "RelWithDebInfo" - type: EnvironmentVariable variableName: LLVM_BASE_URL - variableValue: http://master.qt.io/development_releases/prebuilt/libclang/libclang-release_140-based + variableValue: http://master.qt.io/development_releases/prebuilt/libclang/libclang-release_14.0.0-based - type: Group instructions: diff --git a/share/qtcreator/scripts/openTerminal.py b/share/qtcreator/scripts/openTerminal.py index a0347c08674..8bab290d43e 100755 --- a/share/qtcreator/scripts/openTerminal.py +++ b/share/qtcreator/scripts/openTerminal.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ############################################################################ # @@ -102,7 +102,7 @@ def bash_setup(shell): def main(): # create temporary file to be sourced into bash that deletes itself - with NamedTemporaryFile(delete=False) as shell_script: + with NamedTemporaryFile(mode='wt', delete=False) as shell_script: shell = os.environ.get('SHELL') shell, system_login_script, login_script, non_interactive_shell, interactive_shell = ( zsh_setup(shell) if shell is not None and shell.endswith('/zsh') diff --git a/share/qtcreator/translations/translations.qbs b/share/qtcreator/translations/translations.qbs index 33e6a0f8724..4e4faddcc89 100644 --- a/share/qtcreator/translations/translations.qbs +++ b/share/qtcreator/translations/translations.qbs @@ -3,6 +3,8 @@ import qbs 1.0 Product { name: "Translations" type: "qm" + builtByDefault: false + Depends { name: "Qt.core" } Depends { name: "qtc" } diff --git a/src/libs/3rdparty/cplusplus/AST.cpp b/src/libs/3rdparty/cplusplus/AST.cpp index a48067ab755..360918d2af2 100644 --- a/src/libs/3rdparty/cplusplus/AST.cpp +++ b/src/libs/3rdparty/cplusplus/AST.cpp @@ -1393,7 +1393,6 @@ int ForeachStatementAST::lastToken() const return 1; } -/** \generated */ int FunctionDeclaratorAST::firstToken() const { if (lparen_token) @@ -1403,40 +1402,50 @@ int FunctionDeclaratorAST::firstToken() const return candidate; if (rparen_token) return rparen_token; - if (cv_qualifier_list) - if (int candidate = cv_qualifier_list->firstToken()) - return candidate; - if (ref_qualifier_token) + const int firstQualListToken = cv_qualifier_list ? cv_qualifier_list->firstToken() : 0; + const auto isBeforeFirstQualListToken = [firstQualListToken](int token) { + return token && (!firstQualListToken || token < firstQualListToken); + }; + if (isBeforeFirstQualListToken(ref_qualifier_token)) return ref_qualifier_token; - if (exception_specification) - if (int candidate = exception_specification->firstToken()) + if (exception_specification) { + const int candidate = exception_specification->firstToken(); + if (isBeforeFirstQualListToken(candidate)) return candidate; - if (trailing_return_type) - if (int candidate = trailing_return_type->firstToken()) + } + if (trailing_return_type) { + const int candidate = trailing_return_type->firstToken(); + if (isBeforeFirstQualListToken(candidate)) return candidate; + } + if (firstQualListToken) + return firstQualListToken; if (as_cpp_initializer) if (int candidate = as_cpp_initializer->firstToken()) return candidate; return 0; } -/** \generated */ int FunctionDeclaratorAST::lastToken() const { if (as_cpp_initializer) if (int candidate = as_cpp_initializer->lastToken()) return candidate; - if (trailing_return_type) - if (int candidate = trailing_return_type->lastToken()) - return candidate; - if (exception_specification) - if (int candidate = exception_specification->lastToken()) - return candidate; - if (ref_qualifier_token) - return ref_qualifier_token + 1; - if (cv_qualifier_list) - if (int candidate = cv_qualifier_list->lastToken()) - return candidate; + const int lastQualListToken = cv_qualifier_list ? cv_qualifier_list->lastToken() : 0; + const auto tokenOrLastQualListToken = [lastQualListToken](int token) { + return std::max(token ? token + 1 : 0, lastQualListToken); + }; + const auto tokenFromAstOrLastQualListToken = [lastQualListToken](const AST *ast) { + return std::max(ast ? ast->lastToken() : 0, lastQualListToken); + }; + if (int candidate = tokenFromAstOrLastQualListToken(trailing_return_type)) + return candidate; + if (int candidate = tokenFromAstOrLastQualListToken(exception_specification)) + return candidate; + if (int candidate = tokenOrLastQualListToken(ref_qualifier_token)) + return candidate; + if (lastQualListToken) + return lastQualListToken; if (rparen_token) return rparen_token + 1; if (parameter_declaration_clause) diff --git a/src/libs/cplusplus/Overview.cpp b/src/libs/cplusplus/Overview.cpp index 7303791b06d..02288d94cde 100644 --- a/src/libs/cplusplus/Overview.cpp +++ b/src/libs/cplusplus/Overview.cpp @@ -86,6 +86,7 @@ Overview::Overview() showTemplateParameters(false), showEnclosingTemplate(false), includeWhiteSpaceInOperatorName(true), + trailingReturnType(false), markedArgument(0), markedArgumentBegin(0), markedArgumentEnd(0) diff --git a/src/libs/cplusplus/Overview.h b/src/libs/cplusplus/Overview.h index 243390cd8ad..d12daa581fa 100644 --- a/src/libs/cplusplus/Overview.h +++ b/src/libs/cplusplus/Overview.h @@ -69,6 +69,7 @@ public: bool showTemplateParameters: 1; bool showEnclosingTemplate: 1; bool includeWhiteSpaceInOperatorName: 1; /// "operator =()" vs "operator=()" + bool trailingReturnType: 1; int markedArgument; int markedArgumentBegin; diff --git a/src/libs/cplusplus/TypePrettyPrinter.cpp b/src/libs/cplusplus/TypePrettyPrinter.cpp index d766a3f03b9..d6a2ce84fac 100644 --- a/src/libs/cplusplus/TypePrettyPrinter.cpp +++ b/src/libs/cplusplus/TypePrettyPrinter.cpp @@ -435,11 +435,17 @@ void TypePrettyPrinter::visit(Function *type) retAndArgOverview.showTemplateParameters = true; if (_overview->showReturnTypes) { - const QString returnType = retAndArgOverview.prettyType(type->returnType()); - if (!returnType.isEmpty()) { - if (!endsWithPtrOrRef(returnType) || !(_overview->starBindFlags & Overview::BindToIdentifier)) - _text.prepend(QLatin1Char(' ')); - _text.prepend(returnType); + if (_overview->trailingReturnType) { + _text.prepend("auto "); + } else { + const QString returnType = retAndArgOverview.prettyType(type->returnType()); + if (!returnType.isEmpty()) { + if (!endsWithPtrOrRef(returnType) + || !(_overview->starBindFlags & Overview::BindToIdentifier)) { + _text.prepend(QLatin1Char(' ')); + } + _text.prepend(returnType); + } } } @@ -525,10 +531,19 @@ void TypePrettyPrinter::visit(Function *type) // add exception specifier if (const StringLiteral *spec = type->exceptionSpecification()) { - appendSpace(); + if (type->refQualifier() != Function::NoRefQualifier) + _text.append(' '); + else + appendSpace(); _text += QLatin1String(spec->chars()); } } + + if (_overview->showReturnTypes && _overview->trailingReturnType) { + const QString returnType = retAndArgOverview.prettyType(type->returnType()); + if (!returnType.isEmpty()) + _text.append(" -> ").append(returnType); + } } void TypePrettyPrinter::appendSpace() diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index d0e628e4cce..b3e61789bf5 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -2835,9 +2835,15 @@ static void semanticHighlighter(QFutureInterface &future, if (path.rbegin()->hasConstType()) return false; for (auto it = path.rbegin() + 1; it != path.rend(); ++it) { - if (it->kind() == "Call" || it->kind() == "CXXConstruct" - || it->kind() == "MemberInitializer") { + if (it->kind() == "CXXConstruct" || it->kind() == "MemberInitializer") return true; + + if (it->kind() == "Call") { + // In class templates, member calls can result in "Call" nodes rather than + // "CXXMemberCall". We try to detect this by checking for a certain kind of + // child node. + const QList children = it->children().value_or(QList()); + return children.isEmpty() || children.first().kind() != "CXXDependentScopeMember"; } // The token should get marked for e.g. lambdas, but not for assignment operators, diff --git a/src/plugins/clangcodemodel/test/clangdtests.cpp b/src/plugins/clangcodemodel/test/clangdtests.cpp index 0381bd25772..67339c77293 100644 --- a/src/plugins/clangcodemodel/test/clangdtests.cpp +++ b/src/plugins/clangcodemodel/test/clangdtests.cpp @@ -1315,6 +1315,12 @@ void ClangdTestHighlighting::test_data() QTest::newRow("deref operator (object)") << 960 << 10 << 960 << 11 << QList{C_LOCAL} << 0; QTest::newRow("deref operator (member)") << 960 << 12 << 960 << 13 << QList{C_FIELD} << 0; QTest::newRow("nested call") << 979 << 20 << 979 << 21 << QList{C_LOCAL} << 0; + QTest::newRow("member call on dependent (1)") << 996 << 19 << 996 << 22 + << QList{C_FIELD} << 0; + QTest::newRow("member call on dependent (2)") << 996 << 38 << 996 << 41 + << QList{C_FIELD} << 0; + QTest::newRow("member call on dependent (3)") << 999 << 9 << 999 << 12 + << QList{C_LOCAL} << 0; } void ClangdTestHighlighting::test() diff --git a/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp b/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp index 7275ddd3307..1d4bcce7f8e 100644 --- a/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp +++ b/src/plugins/clangcodemodel/test/data/highlighting/highlighting.cpp @@ -978,3 +978,24 @@ void nestedCall() my_struct* s = get_my_struct(); new my_struct2(s->method(0)); } + +template +class my_class +{ +private: + struct my_int + { + int n; + }; + + std::vector vec; + +public: + void foo() + { + auto it = vec.begin(), end = vec.end(); + + T* ptr = nullptr; + ptr->bar(); + } +}; diff --git a/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp b/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp index a381fecd69b..21d056f6083 100644 --- a/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp +++ b/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp @@ -268,7 +268,18 @@ QList generateBuildTargets(const PreprocessedData &input, // CMake sometimes mixes several shell-escaped pieces into one fragment. Disentangle that again: const QStringList parts = ProcessArgs::splitArgs(f.fragment); - for (const QString &part : parts) { + for (QString part : parts) { + // Library search paths that are added with target_link_directories are added as + // -LIBPATH:... (Windows/MSVC), or + // -L... (Unix/GCC) + // with role "libraryPath" + if (f.role == "libraryPath") { + if (part.startsWith("-LIBPATH:")) + part = part.mid(9); + else if (part.startsWith("-L")) + part = part.mid(2); + } + // Some projects abuse linking to libraries to pass random flags to the linker, so ignore // flags mixed into a fragment if (part.startsWith("-")) diff --git a/src/plugins/coreplugin/find/optionspopup.cpp b/src/plugins/coreplugin/find/optionspopup.cpp index 532bd22390d..ab383b6e7b8 100644 --- a/src/plugins/coreplugin/find/optionspopup.cpp +++ b/src/plugins/coreplugin/find/optionspopup.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include using namespace Utils; @@ -64,7 +65,8 @@ OptionsPopup::OptionsPopup(QWidget *parent, const QVector &commands) layout->addWidget(checkBox); } const QPoint globalPos = parent->mapToGlobal(QPoint(0, -sizeHint().height())); - move(globalPos.x(), std::max(globalPos.y(), 0)); + const QRect screenGeometry = parent->screen()->availableGeometry(); + move(globalPos.x(), std::max(globalPos.y(), screenGeometry.y())); } bool OptionsPopup::event(QEvent *ev) diff --git a/src/plugins/coreplugin/welcomepagehelper.cpp b/src/plugins/coreplugin/welcomepagehelper.cpp index 4b12254aa9b..802bc6bdbed 100644 --- a/src/plugins/coreplugin/welcomepagehelper.cpp +++ b/src/plugins/coreplugin/welcomepagehelper.cpp @@ -204,7 +204,7 @@ bool ListModelFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceP if (!m_filterTags.isEmpty()) { return Utils::allOf(m_filterTags, [&item](const QString &filterTag) { - return item->tags.contains(filterTag); + return item->tags.contains(filterTag, Qt::CaseInsensitive); }); } @@ -214,7 +214,9 @@ bool ListModelFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceP wordMatch |= bool(item->name.contains(subString, Qt::CaseInsensitive)); if (wordMatch) continue; - const auto subMatch = [&subString](const QString &elem) { return elem.contains(subString); }; + const auto subMatch = [&subString](const QString &elem) { + return elem.contains(subString, Qt::CaseInsensitive); + }; wordMatch |= Utils::contains(item->tags, subMatch); if (wordMatch) continue; diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp index dd85e95470e..a2ed383c12f 100644 --- a/src/plugins/cppeditor/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/cppquickfix_test.cpp @@ -6110,6 +6110,41 @@ void QuickfixTest::testMoveFuncDefOutsideMemberFuncToCppWithInlinePartOfName() QuickFixOperationTest(testDocuments, &factory); } +void QuickfixTest::testMoveFuncDefOutsideMixedQualifiers() +{ + QList testDocuments; + QByteArray original; + QByteArray expected; + + // Header File + original = R"( +struct Base { + virtual auto func() const && noexcept -> void = 0; +}; +struct Derived : public Base { + auto @func() const && noexcept -> void override {} +};)"; + expected = R"( +struct Base { + virtual auto func() const && noexcept -> void = 0; +}; +struct Derived : public Base { + auto func() const && noexcept -> void override; +};)"; + testDocuments << CppTestDocument::create("file.h", original, expected); + + // Source File + original = "#include \"file.h\"\n"; + expected = R"DELIM(#include "file.h" + +auto Derived::func() const && noexcept -> void {} +)DELIM"; + testDocuments << CppTestDocument::create("file.cpp", original, expected); + + MoveFuncDefOutside factory; + QuickFixOperationTest(testDocuments, &factory); +} + void QuickfixTest::testMoveFuncDefOutsideMemberFuncToCppInsideNS() { QList testDocuments; diff --git a/src/plugins/cppeditor/cppquickfix_test.h b/src/plugins/cppeditor/cppquickfix_test.h index 0201c5b3bb9..3995234374b 100644 --- a/src/plugins/cppeditor/cppquickfix_test.h +++ b/src/plugins/cppeditor/cppquickfix_test.h @@ -192,6 +192,7 @@ private slots: void testMoveFuncDefOutsideUnnamedTemplate(); void testMoveFuncDefOutsideMemberFuncToCppStatic(); void testMoveFuncDefOutsideMemberFuncToCppWithInlinePartOfName(); + void testMoveFuncDefOutsideMixedQualifiers(); void testMoveAllFuncDefOutsideMemberFuncToCpp(); void testMoveAllFuncDefOutsideMemberFuncOutside(); diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 7afc867297e..6ed9736f3e1 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -6234,6 +6234,13 @@ QString definitionSignature(const CppQuickFixInterface *assist, oo.showArgumentNames = true; oo.showEnclosingTemplate = true; oo.showTemplateParameters = true; + oo.trailingReturnType = functionDefinitionAST->declarator + && functionDefinitionAST->declarator->postfix_declarator_list + && functionDefinitionAST->declarator->postfix_declarator_list->value + && functionDefinitionAST->declarator->postfix_declarator_list + ->value->asFunctionDeclarator() + && functionDefinitionAST->declarator->postfix_declarator_list + ->value->asFunctionDeclarator()->trailing_return_type; const Name *name = func->name(); if (name && nameIncludesOperatorName(name)) { CoreDeclaratorAST *coreDeclarator = functionDefinitionAST->declarator->core_declarator; diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryassetimportdialog.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryassetimportdialog.cpp index 1f974419c79..6c5005546e8 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryassetimportdialog.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryassetimportdialog.cpp @@ -724,11 +724,13 @@ void ItemLibraryAssetImportDialog::setCloseButtonState(bool importing) void ItemLibraryAssetImportDialog::addError(const QString &error, const QString &srcPath) { + m_closeOnFinish = false; addFormattedMessage(m_outputFormatter, error, srcPath, Utils::StdErrFormat); } void ItemLibraryAssetImportDialog::addWarning(const QString &warning, const QString &srcPath) { + m_closeOnFinish = false; addFormattedMessage(m_outputFormatter, warning, srcPath, Utils::StdOutFormat); } @@ -777,6 +779,10 @@ void ItemLibraryAssetImportDialog::onImportFinished() QString doneStr = tr("Import done."); addInfo(doneStr); setImportProgress(100, doneStr); + if (m_closeOnFinish) { + // Add small delay to allow user to visually confirm import finishing + QTimer::singleShot(1000, this, &ItemLibraryAssetImportDialog::onClose); + } } } @@ -785,7 +791,7 @@ void ItemLibraryAssetImportDialog::onClose() if (m_importer.isImporting()) { addInfo(tr("Canceling import.")); m_importer.cancelImport(); - } else { + } else if (isVisible()) { if (ui->progressBar->value() == 100) // import done successfully accept(); else diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryassetimportdialog.h b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryassetimportdialog.h index ded5d75703a..1b2c4c4ebda 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryassetimportdialog.h +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryassetimportdialog.h @@ -91,5 +91,6 @@ private: int m_optionsHeight = 0; int m_optionsRows = 0; QSet m_preselectedFilesForOverwrite; + bool m_closeOnFinish = true; }; } diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index d966d4fda1b..5e34593cc34 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -98,7 +98,6 @@ static TypeName resolveTypeName(const ASTPropertyReference *ref, const ContextPt type = componentObjectValue->className().toUtf8(); dotProperties = getObjectTypes(componentObjectValue, context); } else if (const ObjectValue * objectValue = value->asObjectValue()) { - type = objectValue->className().toUtf8(); dotProperties = getObjectTypes(objectValue, context); } diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index 7f030d524f5..ebe547176e2 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -555,6 +555,9 @@ void ExampleSetModel::updateQtVersionList() newQtVersion = findHighestQtVersion(versions); currentIndex = indexForQtVersion(newQtVersion); } // nothing to do for extra example sets + // Make sure to select something even if the above failed + if (currentIndex < 0 && rowCount() > 0) + currentIndex = 0; // simply select first selectExampleSet(currentIndex); emit selectedExampleSetChanged(currentIndex); } diff --git a/src/plugins/valgrind/valgrindmemcheckparsertest.cpp b/src/plugins/valgrind/valgrindmemcheckparsertest.cpp index 51380183028..4ca3d768126 100644 --- a/src/plugins/valgrind/valgrindmemcheckparsertest.cpp +++ b/src/plugins/valgrind/valgrindmemcheckparsertest.cpp @@ -549,7 +549,6 @@ void ValgrindMemcheckParserTest::testValgrindStartError() RunnerDumper dumper(&runner); runner.start(); runner.waitForFinished(); - QEXPECT_FAIL("", "Error codes of valgrind startup are currently unprocessed", Continue); //FIXME QVERIFY(dumper.m_errorReceived); // just finish without deadlock and we are fine } diff --git a/src/shared/qbs b/src/shared/qbs index 58b882945d6..66c67898456 160000 --- a/src/shared/qbs +++ b/src/shared/qbs @@ -1 +1 @@ -Subproject commit 58b882945d6faaf928b0f9bd7fcd146935fe758c +Subproject commit 66c67898456c4f599e48d5466022d49b044f679d