Hello community, here is the log from the commit of package clazy for openSUSE:Factory checked in at 2020-05-05 18:55:53 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/clazy (Old) and /work/SRC/openSUSE:Factory/.clazy.new.2738 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "clazy" Tue May 5 18:55:53 2020 rev:9 rq:800164 version:1.6 Changes: -------- --- /work/SRC/openSUSE:Factory/clazy/clazy.changes 2020-03-31 17:14:49.379611508 +0200 +++ /work/SRC/openSUSE:Factory/.clazy.new.2738/clazy.changes 2020-05-05 18:55:58.041487249 +0200 @@ -1,0 +2,6 @@ +Mon May 4 18:19:03 UTC 2020 - Christophe Giboudeaux <christo...@krop.fr> + +- Add upstream patch: + * 0001-qstring-allocations-Fix-unit-tests-with-llvm-10.patch + +------------------------------------------------------------------- New: ---- 0001-qstring-allocations-Fix-unit-tests-with-llvm-10.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ clazy.spec ++++++ --- /var/tmp/diff_new_pack.UZDu8q/_old 2020-05-05 18:55:59.553490505 +0200 +++ /var/tmp/diff_new_pack.UZDu8q/_new 2020-05-05 18:55:59.553490505 +0200 @@ -26,6 +26,7 @@ Source0: https://download.kde.org/stable/%{name}/%{version}/src/%{name}-%{version}.tar.xz Patch0: cmake-clang-cpp.patch Patch1: 0001-Fix-build-issues-using-llvm-10.0.0.patch +Patch2: 0001-qstring-allocations-Fix-unit-tests-with-llvm-10.patch BuildRequires: clang BuildRequires: clang-devel >= 3.9 BuildRequires: cmake >= 3.0 ++++++ 0001-qstring-allocations-Fix-unit-tests-with-llvm-10.patch ++++++ >From 6eab2735dc7c0a0d24554343d7b9c33a19df2a5f Mon Sep 17 00:00:00 2001 From: Sergio Martins <smart...@kde.org> Date: Sun, 19 Apr 2020 22:19:01 +0100 Subject: [PATCH] qstring-allocations: Fix unit-tests with llvm-10 Wasn't warning for: QStringList list = { "foo" }; The child CXXConstructExprs appear in the AST but are never visited. --- src/checks/level2/qstring-allocations.cpp | 37 +++++++++++++++++++---- src/checks/level2/qstring-allocations.h | 1 + 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/checks/level2/qstring-allocations.cpp b/src/checks/level2/qstring-allocations.cpp index 999ee1e..e09745e 100644 --- a/src/checks/level2/qstring-allocations.cpp +++ b/src/checks/level2/qstring-allocations.cpp @@ -176,14 +176,39 @@ static StringLiteral* stringLiteralForCall(Stmt *call) void QStringAllocations::VisitCtor(Stmt *stm) { auto ctorExpr = dyn_cast<CXXConstructExpr>(stm); + if (!ctorExpr) + return; + if (!Utils::containsStringLiteral(ctorExpr, /**allowEmpty=*/ true)) return; CXXConstructorDecl *ctorDecl = ctorExpr->getConstructor(); +#if LLVM_VERSION_MAJOR >= 10 + // With llvm 10, for some reason, the child CXXConstructExpr of QStringList foo = {"foo}; aren't visited :(. + // Do it manually. + if (clazy::isOfClass(ctorDecl, "QStringList")) { + auto p = clazy::getFirstChildOfType2<CXXConstructExpr>(ctorExpr); + while (p) { + if (clazy::isOfClass(p, "QString")) { + VisitCtor(p); + } + p = clazy::getFirstChildOfType2<CXXConstructExpr>(p); + } + } else { + VisitCtor(ctorExpr); + } +#else + VisitCtor(ctorExpr); +#endif +} + +void QStringAllocations::VisitCtor(CXXConstructExpr *ctorExpr) +{ + CXXConstructorDecl *ctorDecl = ctorExpr->getConstructor(); if (!clazy::isOfClass(ctorDecl, "QString")) return; - if (Utils::insideCTORCall(m_context->parentMap, stm, { "QRegExp", "QIcon" })) { + if (Utils::insideCTORCall(m_context->parentMap, ctorExpr, { "QRegExp", "QIcon" })) { // https://blogs.kde.org/2015/11/05/qregexp-qstringliteral-crash-exit return; } @@ -193,7 +218,7 @@ void QStringAllocations::VisitCtor(Stmt *stm) if (initializerList != nullptr) return; // Nothing to do here, MSVC doesn't like it - StringLiteral *lt = stringLiteralForCall(stm); + StringLiteral *lt = stringLiteralForCall(ctorExpr); if (lt && lt->getNumConcatenated() > 1) { return; // Nothing to do here, MSVC doesn't like it } @@ -214,7 +239,7 @@ void QStringAllocations::VisitCtor(Stmt *stm) if (isQLatin1String) { ConditionalOperator *ternary = nullptr; - Latin1Expr qlatin1expr = qlatin1CtorExpr(stm, ternary); + Latin1Expr qlatin1expr = qlatin1CtorExpr(ctorExpr, ternary); if (!qlatin1expr.isValid()) { return; } @@ -233,7 +258,7 @@ void QStringAllocations::VisitCtor(Stmt *stm) if (!clazy::getLocStart(qlatin1Ctor).isMacroID()) { if (!ternary) { fixits = fixItReplaceWordWithWord(qlatin1Ctor, "QStringLiteral", "QLatin1String"); - bool shouldRemoveQString = clazy::getLocStart(qlatin1Ctor).getRawEncoding() != clazy::getLocStart(stm).getRawEncoding() && dyn_cast_or_null<CXXBindTemporaryExpr>(clazy::parent(m_context->parentMap, ctorExpr)); + bool shouldRemoveQString = clazy::getLocStart(qlatin1Ctor).getRawEncoding() != clazy::getLocStart(ctorExpr).getRawEncoding() && dyn_cast_or_null<CXXBindTemporaryExpr>(clazy::parent(m_context->parentMap, ctorExpr)); if (shouldRemoveQString) { // This is the case of QString(QLatin1String("foo")), which we just fixed to be QString(QStringLiteral("foo)), so now remove QString auto removalFixits = clazy::fixItRemoveToken(&m_astContext, ctorExpr, true); @@ -251,7 +276,7 @@ void QStringAllocations::VisitCtor(Stmt *stm) } } - maybeEmitWarning(clazy::getLocStart(stm), msg, fixits); + maybeEmitWarning(clazy::getLocStart(ctorExpr), msg, fixits); } else { vector<FixItHint> fixits; if (clazy::hasChildren(ctorExpr)) { @@ -293,7 +318,7 @@ void QStringAllocations::VisitCtor(Stmt *stm) } } - maybeEmitWarning(clazy::getLocStart(stm), msg, fixits); + maybeEmitWarning(clazy::getLocStart(ctorExpr), msg, fixits); } } diff --git a/src/checks/level2/qstring-allocations.h b/src/checks/level2/qstring-allocations.h index 560be7b..5bbd794 100644 --- a/src/checks/level2/qstring-allocations.h +++ b/src/checks/level2/qstring-allocations.h @@ -68,6 +68,7 @@ public: private: void VisitCtor(clang::Stmt *); + void VisitCtor(clang::CXXConstructExpr *); void VisitOperatorCall(clang::Stmt *); void VisitFromLatin1OrUtf8(clang::Stmt *); void VisitAssignOperatorQLatin1String(clang::Stmt *); -- 2.26.2