From 67921dfb342c3a17a867a6fdcf18e64b119e3e01 Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 2 Apr 2025 11:58:56 +0200 Subject: [PATCH 01/17] format.yml: small uncrustify build cleanup --- .github/workflows/format.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 05e9dbe25ac..d7403459ebd 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -20,6 +20,9 @@ jobs: runs-on: ubuntu-22.04 + env: + UNCRUSTIFY_VERSION: 0.72.0 + steps: - uses: actions/checkout@v4 with: @@ -36,12 +39,14 @@ jobs: - name: build uncrustify if: steps.cache-uncrustify.outputs.cache-hit != 'true' run: | - wget https://github.com/uncrustify/uncrustify/archive/refs/tags/uncrustify-0.72.0.tar.gz - tar xzvf uncrustify-0.72.0.tar.gz && cd uncrustify-uncrustify-0.72.0 + set -x + wget https://github.com/uncrustify/uncrustify/archive/refs/tags/uncrustify-${{ env.UNCRUSTIFY_VERSION }}.tar.gz + tar xzvf uncrustify-${{ env.UNCRUSTIFY_VERSION }}.tar.gz + cd uncrustify-uncrustify-${{ env.UNCRUSTIFY_VERSION }} cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 cmake --build build -- -j$(nproc) -s mkdir ~/uncrustify - cd build && cp uncrustify ~/uncrustify/ + cp build/uncrustify ~/uncrustify/ - name: Uncrustify check run: | From 472ba26efadbf668c22c37803c4fc7e8688d9604 Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 2 Apr 2025 11:59:09 +0200 Subject: [PATCH 02/17] format.yml: added uncrustify version to cache key --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index d7403459ebd..7651f095e97 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -34,7 +34,7 @@ jobs: with: path: | ~/uncrustify - key: ${{ runner.os }}-uncrustify + key: ${{ runner.os }}-uncrustify-${{ env.UNCRUSTIFY_VERSION }} - name: build uncrustify if: steps.cache-uncrustify.outputs.cache-hit != 'true' From 72def4cebfbe0ffeadd98c40f0f61a51f953103d Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 2 Apr 2025 12:04:19 +0200 Subject: [PATCH 03/17] format.yml: updated uncrustify to 0.73.0 --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 7651f095e97..bff00041af5 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-22.04 env: - UNCRUSTIFY_VERSION: 0.72.0 + UNCRUSTIFY_VERSION: 0.73.0 steps: - uses: actions/checkout@v4 From 25400bcaa209b915d596ebe1da25f4d2862a0a09 Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 2 Apr 2025 12:05:54 +0200 Subject: [PATCH 04/17] format.yml: updated uncrustify to 0.74.0 --- .github/workflows/format.yml | 2 +- lib/checkersreport.cpp | 10 +++++----- lib/checkstl.cpp | 12 ++++++------ lib/clangimport.cpp | 12 ++++++------ lib/programmemory.cpp | 2 +- lib/symboldatabase.cpp | 10 +++++----- lib/token.cpp | 4 ++-- lib/token.h | 2 +- lib/tokenize.cpp | 8 ++++---- lib/vf_settokenvalue.cpp | 2 +- 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index bff00041af5..c89a91d6742 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-22.04 env: - UNCRUSTIFY_VERSION: 0.73.0 + UNCRUSTIFY_VERSION: 0.74.0 steps: - uses: actions/checkout@v4 diff --git a/lib/checkersreport.cpp b/lib/checkersreport.cpp index dd870559936..350ca3bfe6b 100644 --- a/lib/checkersreport.cpp +++ b/lib/checkersreport.cpp @@ -191,11 +191,11 @@ std::string CheckersReport::getReport(const std::string& criticalErrors) const const bool cppcheckPremium = isCppcheckPremium(mSettings); auto reportSection = [&fout, cppcheckPremium] - (const std::string& title, - const Settings& settings, - const std::set& activeCheckers, - const std::map& premiumCheckers, - const std::string& substring) { + (const std::string& title, + const Settings& settings, + const std::set& activeCheckers, + const std::map& premiumCheckers, + const std::string& substring) { fout << std::endl << std::endl; fout << title << std::endl; fout << std::string(title.size(), '-') << std::endl; diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index bdade21bd48..d0de81abad1 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -3293,12 +3293,12 @@ static const ValueFlow::Value* getOOBIterValue(const Token* tok, const ValueFlow auto it = std::find_if(tok->values().begin(), tok->values().end(), [&](const ValueFlow::Value& v) { if (v.isPossible() || v.isKnown()) { switch (v.valueType) { - case ValueFlow::Value::ValueType::ITERATOR_END: - return v.intvalue >= 0; - case ValueFlow::Value::ValueType::ITERATOR_START: - return (v.intvalue < 0) || (sizeVal && v.intvalue >= sizeVal->intvalue); - default: - break; + case ValueFlow::Value::ValueType::ITERATOR_END: + return v.intvalue >= 0; + case ValueFlow::Value::ValueType::ITERATOR_START: + return (v.intvalue < 0) || (sizeVal && v.intvalue >= sizeVal->intvalue); + default: + break; } } return false; diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index c5962268998..b4e7f0b2b63 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -1502,12 +1502,12 @@ void clangimport::AstNode::createTokensForCXXRecord(TokenList &tokenList) std::vector children2; std::copy_if(children.cbegin(), children.cend(), std::back_inserter(children2), [](const AstNodePtr& child) { return child->nodeType == CXXConstructorDecl || - child->nodeType == CXXDestructorDecl || - child->nodeType == CXXMethodDecl || - child->nodeType == FieldDecl || - child->nodeType == VarDecl || - child->nodeType == AccessSpecDecl || - child->nodeType == TypedefDecl; + child->nodeType == CXXDestructorDecl || + child->nodeType == CXXMethodDecl || + child->nodeType == FieldDecl || + child->nodeType == VarDecl || + child->nodeType == AccessSpecDecl || + child->nodeType == TypedefDecl; }); Scope *scope = createScope(tokenList, isStruct ? ScopeType::eStruct : ScopeType::eClass, children2, classToken); const std::string addr = mExtTokens[0]; diff --git a/lib/programmemory.cpp b/lib/programmemory.cpp index de6c9733062..b88511ae72f 100644 --- a/lib/programmemory.cpp +++ b/lib/programmemory.cpp @@ -669,7 +669,7 @@ static ValueFlow::Value evaluate(const std::string& op, const ValueFlow::Value& return result; } -using BuiltinLibraryFunction = std::function&)>; +using BuiltinLibraryFunction = std::function&)>; static std::unordered_map createBuiltinLibraryFunctions() { std::unordered_map functions; diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index cda94aaadb7..95d6b196f8d 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -5735,11 +5735,11 @@ static bool hasMatchingConstructor(const Scope* classScope, const ValueType* arg return false; const ValueType* vt = f.getArgumentVar(0)->valueType(); return vt && - vt->type == argType->type && - (argType->sign == ValueType::Sign::UNKNOWN_SIGN || vt->sign == argType->sign) && - vt->pointer == argType->pointer && - (vt->constness & 1) >= (argType->constness & 1) && - (vt->volatileness & 1) >= (argType->volatileness & 1); + vt->type == argType->type && + (argType->sign == ValueType::Sign::UNKNOWN_SIGN || vt->sign == argType->sign) && + vt->pointer == argType->pointer && + (vt->constness & 1) >= (argType->constness & 1) && + (vt->volatileness & 1) >= (argType->volatileness & 1); }); } diff --git a/lib/token.cpp b/lib/token.cpp index 42bad2d08ae..870aae4008a 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -2542,7 +2542,7 @@ bool Token::hasKnownSymbolicValue(const Token* tok) const return mImpl->mValues && std::any_of(mImpl->mValues->begin(), mImpl->mValues->end(), [&](const ValueFlow::Value& value) { return value.isKnown() && value.isSymbolicValue() && value.tokvalue && - value.tokvalue->exprId() == tok->exprId(); + value.tokvalue->exprId() == tok->exprId(); }); } @@ -2615,7 +2615,7 @@ const ValueFlow::Value* Token::getMovedValue() const return nullptr; const auto it = std::find_if(mImpl->mValues->begin(), mImpl->mValues->end(), [](const ValueFlow::Value& value) { return value.isMovedValue() && !value.isImpossible() && - value.moveKind != ValueFlow::Value::MoveKind::NonMovedVariable; + value.moveKind != ValueFlow::Value::MoveKind::NonMovedVariable; }); return it == mImpl->mValues->end() ? nullptr : &*it; } diff --git a/lib/token.h b/lib/token.h index 4298bb1d72a..59774747f70 100644 --- a/lib/token.h +++ b/lib/token.h @@ -1428,7 +1428,7 @@ class CPPCHECKLIB Token { fIsInitBracket = (1ULL << 44), // Is this bracket used as a part of variable initialization i.e: int a{5}, b(2); }; - enum : std::uint8_t { + enum : std::uint8_t { efMaxSize = sizeof(nonneg int) * 8, efIsUnique = efMaxSize - 2, }; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 38c1d207565..ec5354753fc 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -10852,10 +10852,10 @@ bool Tokenizer::hasIfdef(const Token *start, const Token *end) const const auto& directives = mDirectives; return std::any_of(directives.cbegin(), directives.cend(), [&](const Directive& d) { return startsWith(d.str, "#if") && - d.linenr >= start->linenr() && - d.linenr <= end->linenr() && - start->fileIndex() < list.getFiles().size() && - d.file == list.getFiles()[start->fileIndex()]; + d.linenr >= start->linenr() && + d.linenr <= end->linenr() && + start->fileIndex() < list.getFiles().size() && + d.file == list.getFiles()[start->fileIndex()]; }); } diff --git a/lib/vf_settokenvalue.cpp b/lib/vf_settokenvalue.cpp index ae19abbed8b..b4c2c921559 100644 --- a/lib/vf_settokenvalue.cpp +++ b/lib/vf_settokenvalue.cpp @@ -526,7 +526,7 @@ namespace ValueFlow args2.begin(), [&](const Token* atok, const Token* btok) { return atok->getKnownIntValue() == - btok->getKnownIntValue(); + btok->getKnownIntValue(); }); } else { equal = false; From a7c6c05b14c252b02b720c7a60d3723acea145c1 Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 2 Apr 2025 12:21:40 +0200 Subject: [PATCH 05/17] format.yml: updated uncrustify to 0.75.0 --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index c89a91d6742..b9ec0ed61a1 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-22.04 env: - UNCRUSTIFY_VERSION: 0.74.0 + UNCRUSTIFY_VERSION: 0.75.0 steps: - uses: actions/checkout@v4 From 26ca224fb2cea0175b38610b40aa5433045d853c Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 22 Apr 2025 09:38:43 +0200 Subject: [PATCH 06/17] format.yml: updated uncrustify to 0.75.1 --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index b9ec0ed61a1..22f3e488956 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-22.04 env: - UNCRUSTIFY_VERSION: 0.75.0 + UNCRUSTIFY_VERSION: 0.75.1 steps: - uses: actions/checkout@v4 From dddc47d838d5aa6749bb74a013b379eb6b9f4327 Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 22 Apr 2025 09:40:04 +0200 Subject: [PATCH 07/17] format.yml: updated uncrustify to 0.76.0 --- .github/workflows/format.yml | 2 +- cli/cmdlineparser.cpp | 3 +- cli/sehwrapper.h | 10 ++--- democlient/democlient.cpp | 3 +- gui/mainwindow.cpp | 3 +- gui/newsuppressiondialog.cpp | 3 +- lib/checkmemoryleak.cpp | 3 +- lib/checkstl.cpp | 12 +++--- lib/checkunusedfunctions.cpp | 8 ++-- lib/keywords.cpp | 48 +++++++++++------------ lib/valueflow.cpp | 20 +++++----- lib/vf_analyzers.cpp | 3 +- oss-fuzz/main.cpp | 9 +++-- test/fixture.h | 6 ++- test/helpers.h | 2 +- test/testclangimport.cpp | 14 +++---- test/testcppcheck.cpp | 3 +- test/testio.cpp | 56 +++++++++++++-------------- test/testsymboldatabase.cpp | 72 +++++++++++++++++------------------ test/testutils.cpp | 3 +- test/testvalueflow.cpp | 74 ++++++++++++++++++------------------ 21 files changed, 185 insertions(+), 172 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 22f3e488956..7bf573e6dc6 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-22.04 env: - UNCRUSTIFY_VERSION: 0.75.1 + UNCRUSTIFY_VERSION: 0.76.0 steps: - uses: actions/checkout@v4 diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 0ea355358d6..c003b74a077 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -129,7 +129,8 @@ namespace { } void reportProgress(const std::string & /*filename*/, const char /*stage*/[], const std::size_t /*value*/) override - {} + { + } }; } diff --git a/cli/sehwrapper.h b/cli/sehwrapper.h index 9a7e25f9454..fe55581eba7 100644 --- a/cli/sehwrapper.h +++ b/cli/sehwrapper.h @@ -40,11 +40,11 @@ namespace internal * Has to be clean for using with SEH on windows, i.e. no construction of C++ object instances is allowed! */ #define CALL_WITH_SEH_WRAPPER(f) \ - __try { \ - return (f); \ - } __except (internal::filter_seh_exeception(GetExceptionCode(), GetExceptionInformation())) { \ - return -1; \ - } + __try { \ + return (f); \ + } __except (internal::filter_seh_exeception(GetExceptionCode(), GetExceptionInformation())) { \ + return -1; \ + } #endif diff --git a/democlient/democlient.cpp b/democlient/democlient.cpp index 59746788163..4aafc207f0b 100644 --- a/democlient/democlient.cpp +++ b/democlient/democlient.cpp @@ -70,7 +70,8 @@ class CppcheckExecutor : public ErrorLogger { cppcheck.check(FileWithDetails("test.cpp", Standards::Language::CPP, 0), code); } - void reportOut(const std::string & /*outmsg*/, Color /*c*/) override {} + void reportOut(const std::string & /*outmsg*/, Color /*c*/) override { + } void reportErr(const ErrorMessage &msg) override { static const std::string templateFormat = "{bold}{file}:{line}:{column}: {red}{inconclusive:{magenta}}{severity}:{inconclusive: inconclusive:}{default} {message} [{id}]{reset}\\n{code}"; static const std::string templateLocation = "{bold}{file}:{line}:{column}: {dim}note:{reset} {info}\\n{code}"; diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 2e31009b392..ee732d080ce 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1687,7 +1687,8 @@ void MainWindow::complianceReport() } void MainWindow::resultsAdded() -{} +{ +} void MainWindow::toggleMainToolBar() { diff --git a/gui/newsuppressiondialog.cpp b/gui/newsuppressiondialog.cpp index a750e7c673b..121b5db2c0a 100644 --- a/gui/newsuppressiondialog.cpp +++ b/gui/newsuppressiondialog.cpp @@ -41,7 +41,8 @@ NewSuppressionDialog::NewSuppressionDialog(QWidget *parent) : class QErrorLogger : public ErrorLogger { public: - void reportOut(const std::string & /*outmsg*/, Color /*c*/) override {} + void reportOut(const std::string & /*outmsg*/, Color /*c*/) override { + } void reportErr(const ErrorMessage &msg) override { errorIds << QString::fromStdString(msg.id); } diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 04a94ea31a5..169673d0ec1 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -969,7 +969,8 @@ void CheckMemoryLeakStructMember::runChecks(const Tokenizer &tokenizer, ErrorLog } void CheckMemoryLeakStructMember::getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) const -{} +{ +} void CheckMemoryLeakNoVar::check() diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index d0de81abad1..bdade21bd48 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -3293,12 +3293,12 @@ static const ValueFlow::Value* getOOBIterValue(const Token* tok, const ValueFlow auto it = std::find_if(tok->values().begin(), tok->values().end(), [&](const ValueFlow::Value& v) { if (v.isPossible() || v.isKnown()) { switch (v.valueType) { - case ValueFlow::Value::ValueType::ITERATOR_END: - return v.intvalue >= 0; - case ValueFlow::Value::ValueType::ITERATOR_START: - return (v.intvalue < 0) || (sizeVal && v.intvalue >= sizeVal->intvalue); - default: - break; + case ValueFlow::Value::ValueType::ITERATOR_END: + return v.intvalue >= 0; + case ValueFlow::Value::ValueType::ITERATOR_START: + return (v.intvalue < 0) || (sizeVal && v.intvalue >= sizeVal->intvalue); + default: + break; } } return false; diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index f6a07b8e01f..d18bb2b5d30 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -357,10 +357,10 @@ static void staticFunctionError(ErrorLogger& errorLogger, #define logChecker(id) \ - do { \ - const ErrorMessage errmsg({}, nullptr, Severity::internal, "logChecker", (id), CWE(0U), Certainty::normal); \ - errorLogger.reportErr(errmsg); \ - } while (false) + do { \ + const ErrorMessage errmsg({}, nullptr, Severity::internal, "logChecker", (id), CWE(0U), Certainty::normal); \ + errorLogger.reportErr(errmsg); \ + } while (false) bool CheckUnusedFunctions::check(const Settings& settings, ErrorLogger& errorLogger) const { diff --git a/lib/keywords.cpp b/lib/keywords.cpp index 7642c3811d4..0a550cd0411 100644 --- a/lib/keywords.cpp +++ b/lib/keywords.cpp @@ -23,20 +23,20 @@ // see https://en.cppreference.com/w/c/keyword #define C90_KEYWORDS \ - "auto", "break", "case", "char", "const", "continue", "default", \ - "do", "double", "else", "enum", "extern", "float", "for", "goto", "if", "int", "long", \ - "register", "return", "short", "signed", "sizeof", "static", "struct", "switch", "typedef", \ - "union", "unsigned", "void", "volatile", "while" + "auto", "break", "case", "char", "const", "continue", "default", \ + "do", "double", "else", "enum", "extern", "float", "for", "goto", "if", "int", "long", \ + "register", "return", "short", "signed", "sizeof", "static", "struct", "switch", "typedef", \ + "union", "unsigned", "void", "volatile", "while" #define C99_KEYWORDS \ - "inline", "restrict", "_Bool", "_Complex", "_Imaginary" + "inline", "restrict", "_Bool", "_Complex", "_Imaginary" #define C11_KEYWORDS \ - "_Alignas", "_Alignof", "_Atomic", "_Generic", "_Noreturn", "_Static_assert", "_Thread_local" + "_Alignas", "_Alignof", "_Atomic", "_Generic", "_Noreturn", "_Static_assert", "_Thread_local" #define C23_KEYWORDS \ - "alignas", "alignof", "bool", "constexpr", "false", "nullptr", "static_assert", "thread_local", "true", "typeof", "typeof_unqual", \ - "_BitInt", "_Decimal128", "_Decimal32", "_Decimal64" + "alignas", "alignof", "bool", "constexpr", "false", "nullptr", "static_assert", "thread_local", "true", "typeof", "typeof_unqual", \ + "_BitInt", "_Decimal128", "_Decimal32", "_Decimal64" static const std::unordered_set c89_keywords_all = { C90_KEYWORDS @@ -80,24 +80,24 @@ static const std::unordered_set c23_keywords = { // see https://en.cppreference.com/w/cpp/keyword #define CPP03_KEYWORDS \ - "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break", "case", "catch", "char", \ - "class", "compl", "const", "const_cast", "continue", "default", \ - "delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", \ - "float", "for", "friend", "goto", "if", "inline", "int", "long", \ - "mutable", "namespace", "new", "not", "not_eq", "operator", \ - "or", "or_eq", "private", "protected", "public", "register", "reinterpret_cast", \ - "return", "short", "signed", "sizeof", "static", \ - "static_cast", "struct", "switch", "template", "this", "throw", \ - "true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using", \ - "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq" + "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break", "case", "catch", "char", \ + "class", "compl", "const", "const_cast", "continue", "default", \ + "delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", \ + "float", "for", "friend", "goto", "if", "inline", "int", "long", \ + "mutable", "namespace", "new", "not", "not_eq", "operator", \ + "or", "or_eq", "private", "protected", "public", "register", "reinterpret_cast", \ + "return", "short", "signed", "sizeof", "static", \ + "static_cast", "struct", "switch", "template", "this", "throw", \ + "true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using", \ + "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq" #define CPP11_KEYWORDS \ - "alignas", "alignof", "char16_t", "char32_t", "constexpr", "decltype", \ - "noexcept", "nullptr", "static_assert", "thread_local" + "alignas", "alignof", "char16_t", "char32_t", "constexpr", "decltype", \ + "noexcept", "nullptr", "static_assert", "thread_local" #define CPP20_KEYWORDS \ - "char8_t", "concept", "consteval", "constinit", "co_await", \ - "co_return", "co_yield", "requires" + "char8_t", "concept", "consteval", "constinit", "co_await", \ + "co_return", "co_yield", "requires" #ifdef __clang__ #pragma clang diagnostic push @@ -105,10 +105,10 @@ static const std::unordered_set c23_keywords = { #endif #define CPP_TMTS_KEYWORDS \ - "atomic_cancel", "atomic_commit", "atomic_noexcept", "synchronized" + "atomic_cancel", "atomic_commit", "atomic_noexcept", "synchronized" #define CPP_REFL_TS_KEYWORDS \ - "reflexpr" + "reflexpr" #ifdef __clang__ #pragma clang diagnostic pop diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 3ba67c5d081..0a3ca994da0 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -153,13 +153,13 @@ static void bailoutInternal(const std::string& type, } #define bailout2(type, tokenlist, errorLogger, tok, what) \ - bailoutInternal((type), (tokenlist), (errorLogger), (tok), (what), __FILE__, __LINE__, __func__) + bailoutInternal((type), (tokenlist), (errorLogger), (tok), (what), __FILE__, __LINE__, __func__) #define bailout(tokenlist, errorLogger, tok, what) \ - bailout2("valueFlowBailout", (tokenlist), (errorLogger), (tok), (what)) + bailout2("valueFlowBailout", (tokenlist), (errorLogger), (tok), (what)) #define bailoutIncompleteVar(tokenlist, errorLogger, tok, what) \ - bailoutInternal("valueFlowBailoutIncompleteVar", (tokenlist), (errorLogger), (tok), (what), "", 0, __func__) + bailoutInternal("valueFlowBailoutIncompleteVar", (tokenlist), (errorLogger), (tok), (what), "", 0, __func__) static void changeKnownToPossible(std::list& values, int indirect = -1) { @@ -7405,13 +7405,13 @@ static ValueFlowPassAdaptor makeValueFlowPassAdaptor(const char* name, bool c } #define VALUEFLOW_ADAPTOR(cpp, ...) \ - makeValueFlowPassAdaptor(#__VA_ARGS__, \ - (cpp), \ - [](TokenList& tokenlist, \ - SymbolDatabase& symboldatabase, \ - ErrorLogger& errorLogger, \ - const Settings& settings, \ - const std::set& skippedFunctions) { \ + makeValueFlowPassAdaptor(#__VA_ARGS__, \ + (cpp), \ + [](TokenList& tokenlist, \ + SymbolDatabase& symboldatabase, \ + ErrorLogger& errorLogger, \ + const Settings& settings, \ + const std::set& skippedFunctions) { \ (void)tokenlist; \ (void)symboldatabase; \ (void)errorLogger; \ diff --git a/lib/vf_analyzers.cpp b/lib/vf_analyzers.cpp index 5b8bd4aa1ec..6abe69724be 100644 --- a/lib/vf_analyzers.cpp +++ b/lib/vf_analyzers.cpp @@ -467,7 +467,8 @@ struct ValueFlowAnalyzer : Analyzer { template static void assignValueIfMutable(const T& /*unused*/, const U& /*unused*/) - {} + { + } static std::string removeAssign(const std::string& assign) { return std::string{assign.cbegin(), assign.cend() - 1}; diff --git a/oss-fuzz/main.cpp b/oss-fuzz/main.cpp index f7bad77adb9..7c03fb34bdc 100644 --- a/oss-fuzz/main.cpp +++ b/oss-fuzz/main.cpp @@ -38,11 +38,14 @@ class DummyErrorLogger : public ErrorLogger { public: - void reportOut(const std::string& /*outmsg*/, Color /*c*/) override {} - void reportErr(const ErrorMessage& /*msg*/) override {} + void reportOut(const std::string& /*outmsg*/, Color /*c*/) override { + } + void reportErr(const ErrorMessage& /*msg*/) override { + } void reportProgress(const std::string& /*filename*/, const char /*stage*/[], - const std::size_t /*value*/) override {} + const std::size_t /*value*/) override { + } }; static Settings create_settings() diff --git a/test/fixture.h b/test/fixture.h index 37a3fadd8cc..e93e42dbcf4 100644 --- a/test/fixture.h +++ b/test/fixture.h @@ -66,9 +66,11 @@ class TestFixture : public ErrorLogger { virtual void run() = 0; bool prepareTest(const char testname[]); - virtual void prepareTestInternal() {} + virtual void prepareTestInternal() { + } void teardownTest(); - virtual void teardownTestInternal() {} + virtual void teardownTestInternal() { + } std::string getLocationStr(const char * filename, unsigned int linenr) const; class AssertFailedError : public std::exception {}; diff --git a/test/helpers.h b/test/helpers.h index 00ef9262626..8ab85bc09aa 100644 --- a/test/helpers.h +++ b/test/helpers.h @@ -194,7 +194,7 @@ namespace cppcheck { ); */ #define dinit(T, ...) \ - ([&] { T ${}; __VA_ARGS__; return $; }()) + ([&] { T ${}; __VA_ARGS__; return $; }()) // Default construct object to avoid bug in clang // error: default member initializer for 'y' needed within definition of enclosing class 'X' outside of member functions diff --git a/test/testclangimport.cpp b/test/testclangimport.cpp index c2434367cc2..302f7caca1e 100644 --- a/test/testclangimport.cpp +++ b/test/testclangimport.cpp @@ -1060,15 +1060,15 @@ class TestClangImport : public TestFixture { #define GET_SYMBOL_DB(AST) \ - const Settings settings = settingsBuilder().clang().platform(Platform::Type::Unix64).build(); \ + const Settings settings = settingsBuilder().clang().platform(Platform::Type::Unix64).build(); \ TokenList tokenlist{&settings}; \ Tokenizer tokenizer(std::move(tokenlist), settings, *this); \ - { \ - std::istringstream istr(AST); \ - clangimport::parseClangAstDump(tokenizer, istr); \ - } \ - const SymbolDatabase *db = tokenizer.getSymbolDatabase(); \ - ASSERT(db) + { \ + std::istringstream istr(AST); \ + clangimport::parseClangAstDump(tokenizer, istr); \ + } \ + const SymbolDatabase *db = tokenizer.getSymbolDatabase(); \ + ASSERT(db) void tokenIndex() { const char clang[] = "`-FunctionDecl 0x1e07dd0 <67.cpp:1:1, col:13> col:6 foo 'void ()'\n" diff --git a/test/testcppcheck.cpp b/test/testcppcheck.cpp index 175e158ed5c..42b7fb99cfb 100644 --- a/test/testcppcheck.cpp +++ b/test/testcppcheck.cpp @@ -46,7 +46,8 @@ class TestCppcheck : public TestFixture { std::list errmsgs; private: - void reportOut(const std::string & /*outmsg*/, Color /*c*/ = Color::Reset) override {} + void reportOut(const std::string & /*outmsg*/, Color /*c*/ = Color::Reset) override { + } void reportErr(const ErrorMessage &msg) override { ids.push_back(msg.id); diff --git a/test/testio.cpp b/test/testio.cpp index 61a78430821..cb0c5d19a67 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -802,34 +802,34 @@ class TestIO : public TestFixture { #define TEST_SCANF_CODE(format, type) \ - "void f(){" type " x; scanf(\"" format "\", &x);}" + "void f(){" type " x; scanf(\"" format "\", &x);}" #define TEST_SCANF_ERR(format, formatStr, type) \ - "[test.c:1]: (warning) " format " in format string (no. 1) requires '" formatStr " *' but the argument type is '" type " *'.\n" + "[test.c:1]: (warning) " format " in format string (no. 1) requires '" formatStr " *' but the argument type is '" type " *'.\n" #define TEST_SCANF_ERR_AKA_(file, format, formatStr, type, akaType) \ - "[" file ":1]: (portability) " format " in format string (no. 1) requires '" formatStr " *' but the argument type is '" type " * {aka " akaType " *}'.\n" + "[" file ":1]: (portability) " format " in format string (no. 1) requires '" formatStr " *' but the argument type is '" type " * {aka " akaType " *}'.\n" #define TEST_SCANF_ERR_AKA(format, formatStr, type, akaType) \ - TEST_SCANF_ERR_AKA_("test.c", format, formatStr, type, akaType) + TEST_SCANF_ERR_AKA_("test.c", format, formatStr, type, akaType) #define TEST_SCANF_ERR_AKA_CPP(format, formatStr, type, akaType) \ - TEST_SCANF_ERR_AKA_("test.cpp", format, formatStr, type, akaType) + TEST_SCANF_ERR_AKA_("test.cpp", format, formatStr, type, akaType) #define TEST_PRINTF_CODE(format, type) \ - "void f(" type " x){printf(\"" format "\", x);}" + "void f(" type " x){printf(\"" format "\", x);}" #define TEST_PRINTF_ERR(format, requiredType, actualType) \ - "[test.c:1]: (warning) " format " in format string (no. 1) requires '" requiredType "' but the argument type is '" actualType "'.\n" + "[test.c:1]: (warning) " format " in format string (no. 1) requires '" requiredType "' but the argument type is '" actualType "'.\n" #define TEST_PRINTF_ERR_AKA_(file, format, requiredType, actualType, akaType) \ - "[" file ":1]: (portability) " format " in format string (no. 1) requires '" requiredType "' but the argument type is '" actualType " {aka " akaType "}'.\n" + "[" file ":1]: (portability) " format " in format string (no. 1) requires '" requiredType "' but the argument type is '" actualType " {aka " akaType "}'.\n" #define TEST_PRINTF_ERR_AKA(format, requiredType, actualType, akaType) \ - TEST_PRINTF_ERR_AKA_("test.c", format, requiredType, actualType, akaType) + TEST_PRINTF_ERR_AKA_("test.c", format, requiredType, actualType, akaType) #define TEST_PRINTF_ERR_AKA_CPP(format, requiredType, actualType, akaType) \ - TEST_PRINTF_ERR_AKA_("test.cpp", format, requiredType, actualType, akaType) + TEST_PRINTF_ERR_AKA_("test.cpp", format, requiredType, actualType, akaType) template void testFormatStrNoWarn(const char *filename, unsigned int linenr, const char (&code)[size], @@ -911,42 +911,42 @@ class TestIO : public TestFixture { } #define TEST_SCANF_NOWARN(FORMAT, FORMATSTR, TYPE) \ - testFormatStrNoWarn(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE)) + testFormatStrNoWarn(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE)) #define TEST_SCANF_NOWARN_CPP(FORMAT, FORMATSTR, TYPE) \ - testFormatStrNoWarn(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), true) + testFormatStrNoWarn(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), true) #define TEST_SCANF_WARN(FORMAT, FORMATSTR, TYPE) \ - testFormatStrWarn(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR(FORMAT, FORMATSTR, TYPE)) + testFormatStrWarn(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR(FORMAT, FORMATSTR, TYPE)) #define TEST_SCANF_WARN_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE, AKATYPE_WIN64) \ - testFormatStrWarnAka(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) + testFormatStrWarnAka(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) #define TEST_SCANF_WARN_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE, AKATYPE_WIN64) \ - testFormatStrWarnAka(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) + testFormatStrWarnAka(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) #define TEST_SCANF_WARN_AKA_WIN64(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64) \ - testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) + testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) #define TEST_SCANF_WARN_AKA_CPP_WIN64(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64) \ - testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) + testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) #define TEST_SCANF_WARN_AKA_WIN32(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32) \ - testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32)) + testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32)) #define TEST_SCANF_WARN_AKA_CPP_WIN32(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32) \ - testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32), true) + testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32), true) #define TEST_PRINTF_NOWARN(FORMAT, FORMATSTR, TYPE) \ - testFormatStrNoWarn(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE)) + testFormatStrNoWarn(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE)) #define TEST_PRINTF_NOWARN_CPP(FORMAT, FORMATSTR, TYPE) \ - testFormatStrNoWarn(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), true) + testFormatStrNoWarn(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), true) #define TEST_PRINTF_WARN(FORMAT, FORMATSTR, TYPE) \ - testFormatStrWarn(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR(FORMAT, FORMATSTR, TYPE)) + testFormatStrWarn(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR(FORMAT, FORMATSTR, TYPE)) #define TEST_PRINTF_WARN_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE, AKATYPE_WIN64) \ - testFormatStrWarnAka(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) + testFormatStrWarnAka(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) #define TEST_PRINTF_WARN_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE, AKATYPE_WIN64) \ - testFormatStrWarnAka(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) + testFormatStrWarnAka(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) #define TEST_PRINTF_WARN_AKA_WIN64(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64) \ - testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) + testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) #define TEST_PRINTF_WARN_AKA_CPP_WIN64(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64) \ - testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) + testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) #define TEST_PRINTF_WARN_AKA_WIN32(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32) \ - testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32)) + testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32)) #define TEST_PRINTF_WARN_AKA_CPP_WIN32(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32) \ - testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32), true) + testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32), true) void testScanfArgument() { check("void foo() {\n" diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 809f2df64b2..a471a4f0eb0 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -42,21 +42,21 @@ class TestSymbolDatabase; #define GET_SYMBOL_DB(code) \ - SimpleTokenizer tokenizer(settings1, *this); \ - const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code); \ - ASSERT(db); \ - do {} while (false) + SimpleTokenizer tokenizer(settings1, *this); \ + const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code); \ + ASSERT(db); \ + do {} while (false) #define GET_SYMBOL_DB_C(code) \ - SimpleTokenizer tokenizer(settings1, *this, false); \ - const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code); \ - do {} while (false) + SimpleTokenizer tokenizer(settings1, *this, false); \ + const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code); \ + do {} while (false) #define GET_SYMBOL_DB_DBG(code) \ - SimpleTokenizer tokenizer(settingsDbg, *this); \ - const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code); \ - ASSERT(db); \ - do {} while (false) + SimpleTokenizer tokenizer(settingsDbg, *this); \ + const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code); \ + ASSERT(db); \ + do {} while (false) class TestSymbolDatabase : public TestFixture { public: @@ -6368,11 +6368,11 @@ class TestSymbolDatabase : public TestFixture { } #define TEST(S) \ - v = db->getVariableFromVarId(id++); \ - ASSERT(v != nullptr); \ - ASSERT(v->isArray()); \ - ASSERT_EQUALS(1U, v->dimensions().size()); \ - ASSERT_EQUALS(S, v->dimension(0)) + v = db->getVariableFromVarId(id++); \ + ASSERT(v != nullptr); \ + ASSERT(v->isArray()); \ + ASSERT_EQUALS(1U, v->dimensions().size()); \ + ASSERT_EQUALS(S, v->dimension(0)) void enum7() { GET_SYMBOL_DB("enum E { X };\n" @@ -8755,9 +8755,9 @@ class TestSymbolDatabase : public TestFixture { } #define FUNC(x) do { \ - const Function *x = findFunctionByName(#x, &db->scopeList.front()); \ - ASSERT_EQUALS(true, x != nullptr); \ - ASSERT_EQUALS(true, x->isNoExcept()); \ + const Function *x = findFunctionByName(#x, &db->scopeList.front()); \ + ASSERT_EQUALS(true, x != nullptr); \ + ASSERT_EQUALS(true, x->isNoExcept()); \ } while (false) void noexceptFunction1() { @@ -8784,9 +8784,9 @@ class TestSymbolDatabase : public TestFixture { } #define CLASS_FUNC(x, y, z) do { \ - const Function *x = findFunctionByName(#x, y); \ - ASSERT_EQUALS(true, x != nullptr); \ - ASSERT_EQUALS(z, x->isNoExcept()); \ + const Function *x = findFunctionByName(#x, y); \ + ASSERT_EQUALS(true, x != nullptr); \ + ASSERT_EQUALS(z, x->isNoExcept()); \ } while (false) void noexceptFunction3() { @@ -8845,9 +8845,9 @@ class TestSymbolDatabase : public TestFixture { } #define FUNC_THROW(x) do { \ - const Function *x = findFunctionByName(#x, &db->scopeList.front()); \ - ASSERT_EQUALS(true, x != nullptr); \ - ASSERT_EQUALS(true, x->isThrow()); \ + const Function *x = findFunctionByName(#x, &db->scopeList.front()); \ + ASSERT_EQUALS(true, x != nullptr); \ + ASSERT_EQUALS(true, x->isThrow()); \ } while (false) void throwFunction1() { @@ -8865,9 +8865,9 @@ class TestSymbolDatabase : public TestFixture { } #define CLASS_FUNC_THROW(x, y) do { \ - const Function *x = findFunctionByName(#x, y); \ - ASSERT_EQUALS(true, x != nullptr); \ - ASSERT_EQUALS(true, x->isThrow()); \ + const Function *x = findFunctionByName(#x, y); \ + ASSERT_EQUALS(true, x != nullptr); \ + ASSERT_EQUALS(true, x->isThrow()); \ } while (false) void throwFunction2() { GET_SYMBOL_DB("struct Fred {\n" @@ -9539,14 +9539,14 @@ class TestSymbolDatabase : public TestFixture { ASSERT_EQUALS("unsigned long long", typeOf("enum E : unsigned long long { }; void foo() { E e[3]; bar(e[0]); }", "[ 0")); #define CHECK_LIBRARY_FUNCTION_RETURN_TYPE(type) do { \ - const char xmldata[] = "\n" \ - "\n" \ - "\n" \ - "\n" \ - "\n" \ - ""; \ - const Settings sF = settingsBuilder().libraryxml(xmldata).build(); \ - ASSERT_EQUALS(#type, typeOf("void f() { auto x = g(); }", "x", true, &sF)); \ + const char xmldata[] = "\n" \ + "\n" \ + "\n" \ + "\n" \ + "\n" \ + ""; \ + const Settings sF = settingsBuilder().libraryxml(xmldata).build(); \ + ASSERT_EQUALS(#type, typeOf("void f() { auto x = g(); }", "x", true, &sF)); \ } while (false) // *INDENT-OFF* CHECK_LIBRARY_FUNCTION_RETURN_TYPE(bool); diff --git a/test/testutils.cpp b/test/testutils.cpp index d1150b7b0d2..bd38aeeba7d 100644 --- a/test/testutils.cpp +++ b/test/testutils.cpp @@ -493,7 +493,8 @@ class TestUtils : public TestFixture { written = true; } // cppcheck-suppress functionStatic - needs to be const - void f() const {} + void f() const { + } }; { diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 5522f465356..523f986feac 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -1385,14 +1385,14 @@ class TestValueFlow : public TestFixture { ASSERT_EQUALS(4, values.back().intvalue); #define CHECK3(A, B, C) \ - do { \ - code = "void f() {\n" \ - " x = sizeof(" A ");\n" \ - "}"; \ - values = tokenValues(code,"( " C " )"); \ - ASSERT_EQUALS(1U, values.size()); \ - ASSERT_EQUALS(B, values.back().intvalue); \ - } while (false) + do { \ + code = "void f() {\n" \ + " x = sizeof(" A ");\n" \ + "}"; \ + values = tokenValues(code,"( " C " )"); \ + ASSERT_EQUALS(1U, values.size()); \ + ASSERT_EQUALS(B, values.back().intvalue); \ + } while (false) #define CHECK(A, B) CHECK3(A, B, A) // standard types @@ -1441,15 +1441,15 @@ class TestValueFlow : public TestFixture { ASSERT_EQUALS(2, values.back().intvalue); #define CHECK(A, B, C, D) \ - do { \ - code = "enum " A " E " B " { E0, E1 };\n" \ - "void f() {\n" \ - " x = sizeof(" C ");\n" \ - "}"; \ - values = tokenValues(code,"( " C " )"); \ - ASSERT_EQUALS(1U, values.size()); \ - ASSERT_EQUALS(D, values.back().intvalue); \ - } while (false) + do { \ + code = "enum " A " E " B " { E0, E1 };\n" \ + "void f() {\n" \ + " x = sizeof(" C ");\n" \ + "}"; \ + values = tokenValues(code,"( " C " )"); \ + ASSERT_EQUALS(1U, values.size()); \ + ASSERT_EQUALS(D, values.back().intvalue); \ + } while (false) // enums CHECK("", "", "E", settings.platform.sizeof_int); @@ -1516,16 +1516,16 @@ class TestValueFlow : public TestFixture { #undef CHECK #define CHECK(A, B) \ - do { \ - code = "enum E " A " { E0, E1 };\n" \ - "void f() {\n" \ - " E arrE[] = { E0, E1 };\n" \ - " x = sizeof(arrE);\n" \ - "}"; \ - values = tokenValues(code,"( arrE )"); \ - ASSERT_EQUALS(1U, values.size()); \ - ASSERT_EQUALS(B * 2ULL, values.back().intvalue); \ - } while (false) + do { \ + code = "enum E " A " { E0, E1 };\n" \ + "void f() {\n" \ + " E arrE[] = { E0, E1 };\n" \ + " x = sizeof(arrE);\n" \ + "}"; \ + values = tokenValues(code,"( arrE )"); \ + ASSERT_EQUALS(1U, values.size()); \ + ASSERT_EQUALS(B * 2ULL, values.back().intvalue); \ + } while (false) // enum array CHECK("", settings.platform.sizeof_int); @@ -1551,16 +1551,16 @@ class TestValueFlow : public TestFixture { #undef CHECK #define CHECK(A, B) \ - do { \ - code = "enum class E " A " { E0, E1 };\n" \ - "void f() {\n" \ - " E arrE[] = { E::E0, E::E1 };\n" \ - " x = sizeof(arrE);\n" \ - "}"; \ - values = tokenValues(code,"( arrE )"); \ - ASSERT_EQUALS(1U, values.size()); \ - ASSERT_EQUALS(B * 2ULL, values.back().intvalue); \ - } while (false) + do { \ + code = "enum class E " A " { E0, E1 };\n" \ + "void f() {\n" \ + " E arrE[] = { E::E0, E::E1 };\n" \ + " x = sizeof(arrE);\n" \ + "}"; \ + values = tokenValues(code,"( arrE )"); \ + ASSERT_EQUALS(1U, values.size()); \ + ASSERT_EQUALS(B * 2ULL, values.back().intvalue); \ + } while (false) // enum array CHECK("", settings.platform.sizeof_int); From fc794ee810997e890c7045f4960526c6c32fc0a0 Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 23 Apr 2025 12:53:32 +0200 Subject: [PATCH 08/17] .uncrustify.cfg: override `nl_collapse_empty_body_functions` --- .uncrustify.cfg | 11 ++++++++--- cli/cmdlineparser.cpp | 3 +-- democlient/democlient.cpp | 3 +-- gui/mainwindow.cpp | 3 +-- gui/newsuppressiondialog.cpp | 3 +-- lib/checkmemoryleak.cpp | 3 +-- lib/vf_analyzers.cpp | 3 +-- oss-fuzz/main.cpp | 9 +++------ test/fixture.h | 6 ++---- test/testcppcheck.cpp | 3 +-- test/testutils.cpp | 3 +-- 11 files changed, 21 insertions(+), 29 deletions(-) diff --git a/.uncrustify.cfg b/.uncrustify.cfg index f15f26a3009..15dc92e21f3 100644 --- a/.uncrustify.cfg +++ b/.uncrustify.cfg @@ -1,4 +1,4 @@ -# Uncrustify-0.72.0_f +# Uncrustify-0.76.0_f # The original size of tabs in the input. # @@ -133,10 +133,15 @@ indent_class = true # true/false # Default: 1 indent_access_spec = -4 # number -# Whether to collapse empty blocks between '{' and '}'. -# If true, overrides nl_inside_empty_func +# Whether to collapse empty blocks between '{' and '}' except for functions. +# Use nl_collapse_empty_body_functions to specify how empty function braces +# should be formatted. nl_collapse_empty_body = true # true/false +# Whether to collapse empty blocks between '{' and '}' for functions only. +# If true, overrides nl_inside_empty_func. +nl_collapse_empty_body_functions = true # true/false + # Whether to convert all tabs to spaces in comments. If false, tabs in # comments are left alone, unless used for indenting. cmt_convert_tab_to_spaces = true # true/false diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index c003b74a077..0ea355358d6 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -129,8 +129,7 @@ namespace { } void reportProgress(const std::string & /*filename*/, const char /*stage*/[], const std::size_t /*value*/) override - { - } + {} }; } diff --git a/democlient/democlient.cpp b/democlient/democlient.cpp index 4aafc207f0b..59746788163 100644 --- a/democlient/democlient.cpp +++ b/democlient/democlient.cpp @@ -70,8 +70,7 @@ class CppcheckExecutor : public ErrorLogger { cppcheck.check(FileWithDetails("test.cpp", Standards::Language::CPP, 0), code); } - void reportOut(const std::string & /*outmsg*/, Color /*c*/) override { - } + void reportOut(const std::string & /*outmsg*/, Color /*c*/) override {} void reportErr(const ErrorMessage &msg) override { static const std::string templateFormat = "{bold}{file}:{line}:{column}: {red}{inconclusive:{magenta}}{severity}:{inconclusive: inconclusive:}{default} {message} [{id}]{reset}\\n{code}"; static const std::string templateLocation = "{bold}{file}:{line}:{column}: {dim}note:{reset} {info}\\n{code}"; diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index ee732d080ce..2e31009b392 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1687,8 +1687,7 @@ void MainWindow::complianceReport() } void MainWindow::resultsAdded() -{ -} +{} void MainWindow::toggleMainToolBar() { diff --git a/gui/newsuppressiondialog.cpp b/gui/newsuppressiondialog.cpp index 121b5db2c0a..a750e7c673b 100644 --- a/gui/newsuppressiondialog.cpp +++ b/gui/newsuppressiondialog.cpp @@ -41,8 +41,7 @@ NewSuppressionDialog::NewSuppressionDialog(QWidget *parent) : class QErrorLogger : public ErrorLogger { public: - void reportOut(const std::string & /*outmsg*/, Color /*c*/) override { - } + void reportOut(const std::string & /*outmsg*/, Color /*c*/) override {} void reportErr(const ErrorMessage &msg) override { errorIds << QString::fromStdString(msg.id); } diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 169673d0ec1..04a94ea31a5 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -969,8 +969,7 @@ void CheckMemoryLeakStructMember::runChecks(const Tokenizer &tokenizer, ErrorLog } void CheckMemoryLeakStructMember::getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) const -{ -} +{} void CheckMemoryLeakNoVar::check() diff --git a/lib/vf_analyzers.cpp b/lib/vf_analyzers.cpp index 6abe69724be..5b8bd4aa1ec 100644 --- a/lib/vf_analyzers.cpp +++ b/lib/vf_analyzers.cpp @@ -467,8 +467,7 @@ struct ValueFlowAnalyzer : Analyzer { template static void assignValueIfMutable(const T& /*unused*/, const U& /*unused*/) - { - } + {} static std::string removeAssign(const std::string& assign) { return std::string{assign.cbegin(), assign.cend() - 1}; diff --git a/oss-fuzz/main.cpp b/oss-fuzz/main.cpp index 7c03fb34bdc..f7bad77adb9 100644 --- a/oss-fuzz/main.cpp +++ b/oss-fuzz/main.cpp @@ -38,14 +38,11 @@ class DummyErrorLogger : public ErrorLogger { public: - void reportOut(const std::string& /*outmsg*/, Color /*c*/) override { - } - void reportErr(const ErrorMessage& /*msg*/) override { - } + void reportOut(const std::string& /*outmsg*/, Color /*c*/) override {} + void reportErr(const ErrorMessage& /*msg*/) override {} void reportProgress(const std::string& /*filename*/, const char /*stage*/[], - const std::size_t /*value*/) override { - } + const std::size_t /*value*/) override {} }; static Settings create_settings() diff --git a/test/fixture.h b/test/fixture.h index e93e42dbcf4..37a3fadd8cc 100644 --- a/test/fixture.h +++ b/test/fixture.h @@ -66,11 +66,9 @@ class TestFixture : public ErrorLogger { virtual void run() = 0; bool prepareTest(const char testname[]); - virtual void prepareTestInternal() { - } + virtual void prepareTestInternal() {} void teardownTest(); - virtual void teardownTestInternal() { - } + virtual void teardownTestInternal() {} std::string getLocationStr(const char * filename, unsigned int linenr) const; class AssertFailedError : public std::exception {}; diff --git a/test/testcppcheck.cpp b/test/testcppcheck.cpp index 42b7fb99cfb..175e158ed5c 100644 --- a/test/testcppcheck.cpp +++ b/test/testcppcheck.cpp @@ -46,8 +46,7 @@ class TestCppcheck : public TestFixture { std::list errmsgs; private: - void reportOut(const std::string & /*outmsg*/, Color /*c*/ = Color::Reset) override { - } + void reportOut(const std::string & /*outmsg*/, Color /*c*/ = Color::Reset) override {} void reportErr(const ErrorMessage &msg) override { ids.push_back(msg.id); diff --git a/test/testutils.cpp b/test/testutils.cpp index bd38aeeba7d..d1150b7b0d2 100644 --- a/test/testutils.cpp +++ b/test/testutils.cpp @@ -493,8 +493,7 @@ class TestUtils : public TestFixture { written = true; } // cppcheck-suppress functionStatic - needs to be const - void f() const { - } + void f() const {} }; { From 383fd89a4d874b8d7f716fb28042b771f4ea671a Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 23 Apr 2025 13:02:32 +0200 Subject: [PATCH 09/17] .uncrustify.cfg: override `pp_multiline_define_body_indent` --- .uncrustify.cfg | 12 ++++++ cli/sehwrapper.h | 10 ++--- lib/checkunusedfunctions.cpp | 8 ++-- lib/keywords.cpp | 48 +++++++++++------------ lib/valueflow.cpp | 20 +++++----- test/helpers.h | 2 +- test/testclangimport.cpp | 14 +++---- test/testio.cpp | 56 +++++++++++++-------------- test/testsymboldatabase.cpp | 72 +++++++++++++++++------------------ test/testvalueflow.cpp | 74 ++++++++++++++++++------------------ 10 files changed, 164 insertions(+), 152 deletions(-) diff --git a/.uncrustify.cfg b/.uncrustify.cfg index 15dc92e21f3..d7f6429e558 100644 --- a/.uncrustify.cfg +++ b/.uncrustify.cfg @@ -146,6 +146,18 @@ nl_collapse_empty_body_functions = true # true/false # comments are left alone, unless used for indenting. cmt_convert_tab_to_spaces = true # true/false +# An offset value that controls the indentation of the body of a multiline #define. +# 'body' refers to all the lines of a multiline #define except the first line. +# Requires 'pp_ignore_define_body = false'. +# +# <0: Absolute column: the body indentation starts off at the specified column +# (ex. -3 ==> the body is indented starting from column 3) +# >=0: Relative to the column of the '#' of '#define' +# (ex. 3 ==> the body is indented starting 3 columns at the right of '#') +# +# Default: 8 +pp_multiline_define_body_indent = 4 # number + # The value might be used twice: # - at the assignment # - at the opening brace diff --git a/cli/sehwrapper.h b/cli/sehwrapper.h index fe55581eba7..9a7e25f9454 100644 --- a/cli/sehwrapper.h +++ b/cli/sehwrapper.h @@ -40,11 +40,11 @@ namespace internal * Has to be clean for using with SEH on windows, i.e. no construction of C++ object instances is allowed! */ #define CALL_WITH_SEH_WRAPPER(f) \ - __try { \ - return (f); \ - } __except (internal::filter_seh_exeception(GetExceptionCode(), GetExceptionInformation())) { \ - return -1; \ - } + __try { \ + return (f); \ + } __except (internal::filter_seh_exeception(GetExceptionCode(), GetExceptionInformation())) { \ + return -1; \ + } #endif diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index d18bb2b5d30..f6a07b8e01f 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -357,10 +357,10 @@ static void staticFunctionError(ErrorLogger& errorLogger, #define logChecker(id) \ - do { \ - const ErrorMessage errmsg({}, nullptr, Severity::internal, "logChecker", (id), CWE(0U), Certainty::normal); \ - errorLogger.reportErr(errmsg); \ - } while (false) + do { \ + const ErrorMessage errmsg({}, nullptr, Severity::internal, "logChecker", (id), CWE(0U), Certainty::normal); \ + errorLogger.reportErr(errmsg); \ + } while (false) bool CheckUnusedFunctions::check(const Settings& settings, ErrorLogger& errorLogger) const { diff --git a/lib/keywords.cpp b/lib/keywords.cpp index 0a550cd0411..7642c3811d4 100644 --- a/lib/keywords.cpp +++ b/lib/keywords.cpp @@ -23,20 +23,20 @@ // see https://en.cppreference.com/w/c/keyword #define C90_KEYWORDS \ - "auto", "break", "case", "char", "const", "continue", "default", \ - "do", "double", "else", "enum", "extern", "float", "for", "goto", "if", "int", "long", \ - "register", "return", "short", "signed", "sizeof", "static", "struct", "switch", "typedef", \ - "union", "unsigned", "void", "volatile", "while" + "auto", "break", "case", "char", "const", "continue", "default", \ + "do", "double", "else", "enum", "extern", "float", "for", "goto", "if", "int", "long", \ + "register", "return", "short", "signed", "sizeof", "static", "struct", "switch", "typedef", \ + "union", "unsigned", "void", "volatile", "while" #define C99_KEYWORDS \ - "inline", "restrict", "_Bool", "_Complex", "_Imaginary" + "inline", "restrict", "_Bool", "_Complex", "_Imaginary" #define C11_KEYWORDS \ - "_Alignas", "_Alignof", "_Atomic", "_Generic", "_Noreturn", "_Static_assert", "_Thread_local" + "_Alignas", "_Alignof", "_Atomic", "_Generic", "_Noreturn", "_Static_assert", "_Thread_local" #define C23_KEYWORDS \ - "alignas", "alignof", "bool", "constexpr", "false", "nullptr", "static_assert", "thread_local", "true", "typeof", "typeof_unqual", \ - "_BitInt", "_Decimal128", "_Decimal32", "_Decimal64" + "alignas", "alignof", "bool", "constexpr", "false", "nullptr", "static_assert", "thread_local", "true", "typeof", "typeof_unqual", \ + "_BitInt", "_Decimal128", "_Decimal32", "_Decimal64" static const std::unordered_set c89_keywords_all = { C90_KEYWORDS @@ -80,24 +80,24 @@ static const std::unordered_set c23_keywords = { // see https://en.cppreference.com/w/cpp/keyword #define CPP03_KEYWORDS \ - "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break", "case", "catch", "char", \ - "class", "compl", "const", "const_cast", "continue", "default", \ - "delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", \ - "float", "for", "friend", "goto", "if", "inline", "int", "long", \ - "mutable", "namespace", "new", "not", "not_eq", "operator", \ - "or", "or_eq", "private", "protected", "public", "register", "reinterpret_cast", \ - "return", "short", "signed", "sizeof", "static", \ - "static_cast", "struct", "switch", "template", "this", "throw", \ - "true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using", \ - "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq" + "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break", "case", "catch", "char", \ + "class", "compl", "const", "const_cast", "continue", "default", \ + "delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", \ + "float", "for", "friend", "goto", "if", "inline", "int", "long", \ + "mutable", "namespace", "new", "not", "not_eq", "operator", \ + "or", "or_eq", "private", "protected", "public", "register", "reinterpret_cast", \ + "return", "short", "signed", "sizeof", "static", \ + "static_cast", "struct", "switch", "template", "this", "throw", \ + "true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using", \ + "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq" #define CPP11_KEYWORDS \ - "alignas", "alignof", "char16_t", "char32_t", "constexpr", "decltype", \ - "noexcept", "nullptr", "static_assert", "thread_local" + "alignas", "alignof", "char16_t", "char32_t", "constexpr", "decltype", \ + "noexcept", "nullptr", "static_assert", "thread_local" #define CPP20_KEYWORDS \ - "char8_t", "concept", "consteval", "constinit", "co_await", \ - "co_return", "co_yield", "requires" + "char8_t", "concept", "consteval", "constinit", "co_await", \ + "co_return", "co_yield", "requires" #ifdef __clang__ #pragma clang diagnostic push @@ -105,10 +105,10 @@ static const std::unordered_set c23_keywords = { #endif #define CPP_TMTS_KEYWORDS \ - "atomic_cancel", "atomic_commit", "atomic_noexcept", "synchronized" + "atomic_cancel", "atomic_commit", "atomic_noexcept", "synchronized" #define CPP_REFL_TS_KEYWORDS \ - "reflexpr" + "reflexpr" #ifdef __clang__ #pragma clang diagnostic pop diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 0a3ca994da0..3ba67c5d081 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -153,13 +153,13 @@ static void bailoutInternal(const std::string& type, } #define bailout2(type, tokenlist, errorLogger, tok, what) \ - bailoutInternal((type), (tokenlist), (errorLogger), (tok), (what), __FILE__, __LINE__, __func__) + bailoutInternal((type), (tokenlist), (errorLogger), (tok), (what), __FILE__, __LINE__, __func__) #define bailout(tokenlist, errorLogger, tok, what) \ - bailout2("valueFlowBailout", (tokenlist), (errorLogger), (tok), (what)) + bailout2("valueFlowBailout", (tokenlist), (errorLogger), (tok), (what)) #define bailoutIncompleteVar(tokenlist, errorLogger, tok, what) \ - bailoutInternal("valueFlowBailoutIncompleteVar", (tokenlist), (errorLogger), (tok), (what), "", 0, __func__) + bailoutInternal("valueFlowBailoutIncompleteVar", (tokenlist), (errorLogger), (tok), (what), "", 0, __func__) static void changeKnownToPossible(std::list& values, int indirect = -1) { @@ -7405,13 +7405,13 @@ static ValueFlowPassAdaptor makeValueFlowPassAdaptor(const char* name, bool c } #define VALUEFLOW_ADAPTOR(cpp, ...) \ - makeValueFlowPassAdaptor(#__VA_ARGS__, \ - (cpp), \ - [](TokenList& tokenlist, \ - SymbolDatabase& symboldatabase, \ - ErrorLogger& errorLogger, \ - const Settings& settings, \ - const std::set& skippedFunctions) { \ + makeValueFlowPassAdaptor(#__VA_ARGS__, \ + (cpp), \ + [](TokenList& tokenlist, \ + SymbolDatabase& symboldatabase, \ + ErrorLogger& errorLogger, \ + const Settings& settings, \ + const std::set& skippedFunctions) { \ (void)tokenlist; \ (void)symboldatabase; \ (void)errorLogger; \ diff --git a/test/helpers.h b/test/helpers.h index 8ab85bc09aa..00ef9262626 100644 --- a/test/helpers.h +++ b/test/helpers.h @@ -194,7 +194,7 @@ namespace cppcheck { ); */ #define dinit(T, ...) \ - ([&] { T ${}; __VA_ARGS__; return $; }()) + ([&] { T ${}; __VA_ARGS__; return $; }()) // Default construct object to avoid bug in clang // error: default member initializer for 'y' needed within definition of enclosing class 'X' outside of member functions diff --git a/test/testclangimport.cpp b/test/testclangimport.cpp index 302f7caca1e..c2434367cc2 100644 --- a/test/testclangimport.cpp +++ b/test/testclangimport.cpp @@ -1060,15 +1060,15 @@ class TestClangImport : public TestFixture { #define GET_SYMBOL_DB(AST) \ - const Settings settings = settingsBuilder().clang().platform(Platform::Type::Unix64).build(); \ + const Settings settings = settingsBuilder().clang().platform(Platform::Type::Unix64).build(); \ TokenList tokenlist{&settings}; \ Tokenizer tokenizer(std::move(tokenlist), settings, *this); \ - { \ - std::istringstream istr(AST); \ - clangimport::parseClangAstDump(tokenizer, istr); \ - } \ - const SymbolDatabase *db = tokenizer.getSymbolDatabase(); \ - ASSERT(db) + { \ + std::istringstream istr(AST); \ + clangimport::parseClangAstDump(tokenizer, istr); \ + } \ + const SymbolDatabase *db = tokenizer.getSymbolDatabase(); \ + ASSERT(db) void tokenIndex() { const char clang[] = "`-FunctionDecl 0x1e07dd0 <67.cpp:1:1, col:13> col:6 foo 'void ()'\n" diff --git a/test/testio.cpp b/test/testio.cpp index cb0c5d19a67..61a78430821 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -802,34 +802,34 @@ class TestIO : public TestFixture { #define TEST_SCANF_CODE(format, type) \ - "void f(){" type " x; scanf(\"" format "\", &x);}" + "void f(){" type " x; scanf(\"" format "\", &x);}" #define TEST_SCANF_ERR(format, formatStr, type) \ - "[test.c:1]: (warning) " format " in format string (no. 1) requires '" formatStr " *' but the argument type is '" type " *'.\n" + "[test.c:1]: (warning) " format " in format string (no. 1) requires '" formatStr " *' but the argument type is '" type " *'.\n" #define TEST_SCANF_ERR_AKA_(file, format, formatStr, type, akaType) \ - "[" file ":1]: (portability) " format " in format string (no. 1) requires '" formatStr " *' but the argument type is '" type " * {aka " akaType " *}'.\n" + "[" file ":1]: (portability) " format " in format string (no. 1) requires '" formatStr " *' but the argument type is '" type " * {aka " akaType " *}'.\n" #define TEST_SCANF_ERR_AKA(format, formatStr, type, akaType) \ - TEST_SCANF_ERR_AKA_("test.c", format, formatStr, type, akaType) + TEST_SCANF_ERR_AKA_("test.c", format, formatStr, type, akaType) #define TEST_SCANF_ERR_AKA_CPP(format, formatStr, type, akaType) \ - TEST_SCANF_ERR_AKA_("test.cpp", format, formatStr, type, akaType) + TEST_SCANF_ERR_AKA_("test.cpp", format, formatStr, type, akaType) #define TEST_PRINTF_CODE(format, type) \ - "void f(" type " x){printf(\"" format "\", x);}" + "void f(" type " x){printf(\"" format "\", x);}" #define TEST_PRINTF_ERR(format, requiredType, actualType) \ - "[test.c:1]: (warning) " format " in format string (no. 1) requires '" requiredType "' but the argument type is '" actualType "'.\n" + "[test.c:1]: (warning) " format " in format string (no. 1) requires '" requiredType "' but the argument type is '" actualType "'.\n" #define TEST_PRINTF_ERR_AKA_(file, format, requiredType, actualType, akaType) \ - "[" file ":1]: (portability) " format " in format string (no. 1) requires '" requiredType "' but the argument type is '" actualType " {aka " akaType "}'.\n" + "[" file ":1]: (portability) " format " in format string (no. 1) requires '" requiredType "' but the argument type is '" actualType " {aka " akaType "}'.\n" #define TEST_PRINTF_ERR_AKA(format, requiredType, actualType, akaType) \ - TEST_PRINTF_ERR_AKA_("test.c", format, requiredType, actualType, akaType) + TEST_PRINTF_ERR_AKA_("test.c", format, requiredType, actualType, akaType) #define TEST_PRINTF_ERR_AKA_CPP(format, requiredType, actualType, akaType) \ - TEST_PRINTF_ERR_AKA_("test.cpp", format, requiredType, actualType, akaType) + TEST_PRINTF_ERR_AKA_("test.cpp", format, requiredType, actualType, akaType) template void testFormatStrNoWarn(const char *filename, unsigned int linenr, const char (&code)[size], @@ -911,42 +911,42 @@ class TestIO : public TestFixture { } #define TEST_SCANF_NOWARN(FORMAT, FORMATSTR, TYPE) \ - testFormatStrNoWarn(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE)) + testFormatStrNoWarn(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE)) #define TEST_SCANF_NOWARN_CPP(FORMAT, FORMATSTR, TYPE) \ - testFormatStrNoWarn(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), true) + testFormatStrNoWarn(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), true) #define TEST_SCANF_WARN(FORMAT, FORMATSTR, TYPE) \ - testFormatStrWarn(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR(FORMAT, FORMATSTR, TYPE)) + testFormatStrWarn(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR(FORMAT, FORMATSTR, TYPE)) #define TEST_SCANF_WARN_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE, AKATYPE_WIN64) \ - testFormatStrWarnAka(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) + testFormatStrWarnAka(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) #define TEST_SCANF_WARN_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE, AKATYPE_WIN64) \ - testFormatStrWarnAka(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) + testFormatStrWarnAka(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) #define TEST_SCANF_WARN_AKA_WIN64(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64) \ - testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) + testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) #define TEST_SCANF_WARN_AKA_CPP_WIN64(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64) \ - testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) + testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) #define TEST_SCANF_WARN_AKA_WIN32(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32) \ - testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32)) + testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32)) #define TEST_SCANF_WARN_AKA_CPP_WIN32(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32) \ - testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32), true) + testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_SCANF_CODE(FORMAT, TYPE), TEST_SCANF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32), true) #define TEST_PRINTF_NOWARN(FORMAT, FORMATSTR, TYPE) \ - testFormatStrNoWarn(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE)) + testFormatStrNoWarn(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE)) #define TEST_PRINTF_NOWARN_CPP(FORMAT, FORMATSTR, TYPE) \ - testFormatStrNoWarn(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), true) + testFormatStrNoWarn(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), true) #define TEST_PRINTF_WARN(FORMAT, FORMATSTR, TYPE) \ - testFormatStrWarn(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR(FORMAT, FORMATSTR, TYPE)) + testFormatStrWarn(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR(FORMAT, FORMATSTR, TYPE)) #define TEST_PRINTF_WARN_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE, AKATYPE_WIN64) \ - testFormatStrWarnAka(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) + testFormatStrWarnAka(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) #define TEST_PRINTF_WARN_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE, AKATYPE_WIN64) \ - testFormatStrWarnAka(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) + testFormatStrWarnAka(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) #define TEST_PRINTF_WARN_AKA_WIN64(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64) \ - testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) + testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64)) #define TEST_PRINTF_WARN_AKA_CPP_WIN64(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64) \ - testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) + testFormatStrWarnAkaWin64(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN64), true) #define TEST_PRINTF_WARN_AKA_WIN32(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32) \ - testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32)) + testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32)) #define TEST_PRINTF_WARN_AKA_CPP_WIN32(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32) \ - testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32), true) + testFormatStrWarnAkaWin32(__FILE__, __LINE__, TEST_PRINTF_CODE(FORMAT, TYPE), TEST_PRINTF_ERR_AKA_CPP(FORMAT, FORMATSTR, TYPE, AKATYPE_WIN32), true) void testScanfArgument() { check("void foo() {\n" diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index a471a4f0eb0..809f2df64b2 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -42,21 +42,21 @@ class TestSymbolDatabase; #define GET_SYMBOL_DB(code) \ - SimpleTokenizer tokenizer(settings1, *this); \ - const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code); \ - ASSERT(db); \ - do {} while (false) + SimpleTokenizer tokenizer(settings1, *this); \ + const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code); \ + ASSERT(db); \ + do {} while (false) #define GET_SYMBOL_DB_C(code) \ - SimpleTokenizer tokenizer(settings1, *this, false); \ - const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code); \ - do {} while (false) + SimpleTokenizer tokenizer(settings1, *this, false); \ + const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code); \ + do {} while (false) #define GET_SYMBOL_DB_DBG(code) \ - SimpleTokenizer tokenizer(settingsDbg, *this); \ - const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code); \ - ASSERT(db); \ - do {} while (false) + SimpleTokenizer tokenizer(settingsDbg, *this); \ + const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code); \ + ASSERT(db); \ + do {} while (false) class TestSymbolDatabase : public TestFixture { public: @@ -6368,11 +6368,11 @@ class TestSymbolDatabase : public TestFixture { } #define TEST(S) \ - v = db->getVariableFromVarId(id++); \ - ASSERT(v != nullptr); \ - ASSERT(v->isArray()); \ - ASSERT_EQUALS(1U, v->dimensions().size()); \ - ASSERT_EQUALS(S, v->dimension(0)) + v = db->getVariableFromVarId(id++); \ + ASSERT(v != nullptr); \ + ASSERT(v->isArray()); \ + ASSERT_EQUALS(1U, v->dimensions().size()); \ + ASSERT_EQUALS(S, v->dimension(0)) void enum7() { GET_SYMBOL_DB("enum E { X };\n" @@ -8755,9 +8755,9 @@ class TestSymbolDatabase : public TestFixture { } #define FUNC(x) do { \ - const Function *x = findFunctionByName(#x, &db->scopeList.front()); \ - ASSERT_EQUALS(true, x != nullptr); \ - ASSERT_EQUALS(true, x->isNoExcept()); \ + const Function *x = findFunctionByName(#x, &db->scopeList.front()); \ + ASSERT_EQUALS(true, x != nullptr); \ + ASSERT_EQUALS(true, x->isNoExcept()); \ } while (false) void noexceptFunction1() { @@ -8784,9 +8784,9 @@ class TestSymbolDatabase : public TestFixture { } #define CLASS_FUNC(x, y, z) do { \ - const Function *x = findFunctionByName(#x, y); \ - ASSERT_EQUALS(true, x != nullptr); \ - ASSERT_EQUALS(z, x->isNoExcept()); \ + const Function *x = findFunctionByName(#x, y); \ + ASSERT_EQUALS(true, x != nullptr); \ + ASSERT_EQUALS(z, x->isNoExcept()); \ } while (false) void noexceptFunction3() { @@ -8845,9 +8845,9 @@ class TestSymbolDatabase : public TestFixture { } #define FUNC_THROW(x) do { \ - const Function *x = findFunctionByName(#x, &db->scopeList.front()); \ - ASSERT_EQUALS(true, x != nullptr); \ - ASSERT_EQUALS(true, x->isThrow()); \ + const Function *x = findFunctionByName(#x, &db->scopeList.front()); \ + ASSERT_EQUALS(true, x != nullptr); \ + ASSERT_EQUALS(true, x->isThrow()); \ } while (false) void throwFunction1() { @@ -8865,9 +8865,9 @@ class TestSymbolDatabase : public TestFixture { } #define CLASS_FUNC_THROW(x, y) do { \ - const Function *x = findFunctionByName(#x, y); \ - ASSERT_EQUALS(true, x != nullptr); \ - ASSERT_EQUALS(true, x->isThrow()); \ + const Function *x = findFunctionByName(#x, y); \ + ASSERT_EQUALS(true, x != nullptr); \ + ASSERT_EQUALS(true, x->isThrow()); \ } while (false) void throwFunction2() { GET_SYMBOL_DB("struct Fred {\n" @@ -9539,14 +9539,14 @@ class TestSymbolDatabase : public TestFixture { ASSERT_EQUALS("unsigned long long", typeOf("enum E : unsigned long long { }; void foo() { E e[3]; bar(e[0]); }", "[ 0")); #define CHECK_LIBRARY_FUNCTION_RETURN_TYPE(type) do { \ - const char xmldata[] = "\n" \ - "\n" \ - "\n" \ - "\n" \ - "\n" \ - ""; \ - const Settings sF = settingsBuilder().libraryxml(xmldata).build(); \ - ASSERT_EQUALS(#type, typeOf("void f() { auto x = g(); }", "x", true, &sF)); \ + const char xmldata[] = "\n" \ + "\n" \ + "\n" \ + "\n" \ + "\n" \ + ""; \ + const Settings sF = settingsBuilder().libraryxml(xmldata).build(); \ + ASSERT_EQUALS(#type, typeOf("void f() { auto x = g(); }", "x", true, &sF)); \ } while (false) // *INDENT-OFF* CHECK_LIBRARY_FUNCTION_RETURN_TYPE(bool); diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 523f986feac..5522f465356 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -1385,14 +1385,14 @@ class TestValueFlow : public TestFixture { ASSERT_EQUALS(4, values.back().intvalue); #define CHECK3(A, B, C) \ - do { \ - code = "void f() {\n" \ - " x = sizeof(" A ");\n" \ - "}"; \ - values = tokenValues(code,"( " C " )"); \ - ASSERT_EQUALS(1U, values.size()); \ - ASSERT_EQUALS(B, values.back().intvalue); \ - } while (false) + do { \ + code = "void f() {\n" \ + " x = sizeof(" A ");\n" \ + "}"; \ + values = tokenValues(code,"( " C " )"); \ + ASSERT_EQUALS(1U, values.size()); \ + ASSERT_EQUALS(B, values.back().intvalue); \ + } while (false) #define CHECK(A, B) CHECK3(A, B, A) // standard types @@ -1441,15 +1441,15 @@ class TestValueFlow : public TestFixture { ASSERT_EQUALS(2, values.back().intvalue); #define CHECK(A, B, C, D) \ - do { \ - code = "enum " A " E " B " { E0, E1 };\n" \ - "void f() {\n" \ - " x = sizeof(" C ");\n" \ - "}"; \ - values = tokenValues(code,"( " C " )"); \ - ASSERT_EQUALS(1U, values.size()); \ - ASSERT_EQUALS(D, values.back().intvalue); \ - } while (false) + do { \ + code = "enum " A " E " B " { E0, E1 };\n" \ + "void f() {\n" \ + " x = sizeof(" C ");\n" \ + "}"; \ + values = tokenValues(code,"( " C " )"); \ + ASSERT_EQUALS(1U, values.size()); \ + ASSERT_EQUALS(D, values.back().intvalue); \ + } while (false) // enums CHECK("", "", "E", settings.platform.sizeof_int); @@ -1516,16 +1516,16 @@ class TestValueFlow : public TestFixture { #undef CHECK #define CHECK(A, B) \ - do { \ - code = "enum E " A " { E0, E1 };\n" \ - "void f() {\n" \ - " E arrE[] = { E0, E1 };\n" \ - " x = sizeof(arrE);\n" \ - "}"; \ - values = tokenValues(code,"( arrE )"); \ - ASSERT_EQUALS(1U, values.size()); \ - ASSERT_EQUALS(B * 2ULL, values.back().intvalue); \ - } while (false) + do { \ + code = "enum E " A " { E0, E1 };\n" \ + "void f() {\n" \ + " E arrE[] = { E0, E1 };\n" \ + " x = sizeof(arrE);\n" \ + "}"; \ + values = tokenValues(code,"( arrE )"); \ + ASSERT_EQUALS(1U, values.size()); \ + ASSERT_EQUALS(B * 2ULL, values.back().intvalue); \ + } while (false) // enum array CHECK("", settings.platform.sizeof_int); @@ -1551,16 +1551,16 @@ class TestValueFlow : public TestFixture { #undef CHECK #define CHECK(A, B) \ - do { \ - code = "enum class E " A " { E0, E1 };\n" \ - "void f() {\n" \ - " E arrE[] = { E::E0, E::E1 };\n" \ - " x = sizeof(arrE);\n" \ - "}"; \ - values = tokenValues(code,"( arrE )"); \ - ASSERT_EQUALS(1U, values.size()); \ - ASSERT_EQUALS(B * 2ULL, values.back().intvalue); \ - } while (false) + do { \ + code = "enum class E " A " { E0, E1 };\n" \ + "void f() {\n" \ + " E arrE[] = { E::E0, E::E1 };\n" \ + " x = sizeof(arrE);\n" \ + "}"; \ + values = tokenValues(code,"( arrE )"); \ + ASSERT_EQUALS(1U, values.size()); \ + ASSERT_EQUALS(B * 2ULL, values.back().intvalue); \ + } while (false) // enum array CHECK("", settings.platform.sizeof_int); From 9225c2f09b4cbbada950f1e2a5b3a7ce31c8a2e1 Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 23 Apr 2025 13:03:50 +0200 Subject: [PATCH 10/17] format.yml: updated uncrustify to 0.77.0 --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 7bf573e6dc6..1458c876d17 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-22.04 env: - UNCRUSTIFY_VERSION: 0.76.0 + UNCRUSTIFY_VERSION: 0.77.0 steps: - uses: actions/checkout@v4 From 1feb9c877f673a21f938e01d2e6689390e7cd73f Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 23 Apr 2025 13:05:01 +0200 Subject: [PATCH 11/17] format.yml: updated uncrustify to 0.77.1 --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 1458c876d17..a09ae76083b 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-22.04 env: - UNCRUSTIFY_VERSION: 0.77.0 + UNCRUSTIFY_VERSION: 0.77.1 steps: - uses: actions/checkout@v4 From ea6b99f7a414822ec64f55615af01bb9a7370d2f Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 23 Apr 2025 13:06:29 +0200 Subject: [PATCH 12/17] format.yml: updated uncrustify to 0.78.0 --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index a09ae76083b..3c1b48717c4 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-22.04 env: - UNCRUSTIFY_VERSION: 0.77.1 + UNCRUSTIFY_VERSION: 0.78.0 steps: - uses: actions/checkout@v4 From 5425c3c5e597c54aa41bc6b90258781fa99c204b Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 23 Apr 2025 13:07:38 +0200 Subject: [PATCH 13/17] format.yml: updated uncrustify to 0.78.1 --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 3c1b48717c4..57c4f2581fb 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-22.04 env: - UNCRUSTIFY_VERSION: 0.78.0 + UNCRUSTIFY_VERSION: 0.78.1 steps: - uses: actions/checkout@v4 From 37a41cc7224a8111e391ad5ec949c131604a92af Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 23 Apr 2025 13:08:48 +0200 Subject: [PATCH 14/17] format.yml: updated uncrustify to 0.79.0 --- .github/workflows/format.yml | 2 +- lib/valueflow.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 57c4f2581fb..5634c794025 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-22.04 env: - UNCRUSTIFY_VERSION: 0.78.1 + UNCRUSTIFY_VERSION: 0.79.0 steps: - uses: actions/checkout@v4 diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 3ba67c5d081..3201cc1ba03 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -2724,7 +2724,7 @@ static void valueFlowLifetimeFunction(Token *tok, const TokenList &tokenlist, Er const Token* varTok = args[iArg - 1]; if (varTok->variable() && varTok->variable()->isLocal()) LifetimeStore{ varTok, "Passed to '" + tok->str() + "'.", ValueFlow::Value::LifetimeKind::Address }.byRef( - tok->next(), tokenlist, errorLogger, settings); + tok->next(), tokenlist, errorLogger, settings); } } } From 23ed2a5ae06070033e1ac48b856ac28ca7517713 Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 23 Apr 2025 13:11:31 +0200 Subject: [PATCH 15/17] format.yml: updated uncrustify to 0.80.0 --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 5634c794025..00874d18ca5 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-22.04 env: - UNCRUSTIFY_VERSION: 0.79.0 + UNCRUSTIFY_VERSION: 0.80.0 steps: - uses: actions/checkout@v4 From 44116f322d4d3ebe85f8521c0bce02e8c7899d62 Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 23 Apr 2025 13:12:44 +0200 Subject: [PATCH 16/17] format.yml: updated uncrustify to 0.80.1 --- .github/workflows/format.yml | 2 +- .uncrustify.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 00874d18ca5..8ce4bd8595c 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-22.04 env: - UNCRUSTIFY_VERSION: 0.80.0 + UNCRUSTIFY_VERSION: 0.80.1 steps: - uses: actions/checkout@v4 diff --git a/.uncrustify.cfg b/.uncrustify.cfg index d7f6429e558..81722ff7249 100644 --- a/.uncrustify.cfg +++ b/.uncrustify.cfg @@ -1,4 +1,4 @@ -# Uncrustify-0.76.0_f +# Uncrustify-0.80.1_f # The original size of tabs in the input. # From bb9a6e80bf509352043b448594a080e181d4f93f Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 23 Apr 2025 13:13:30 +0200 Subject: [PATCH 17/17] format.yml: removed `-DCMAKE_POLICY_VERSION_MINIMUM` workaround --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 8ce4bd8595c..8ad9408a376 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -43,7 +43,7 @@ jobs: wget https://github.com/uncrustify/uncrustify/archive/refs/tags/uncrustify-${{ env.UNCRUSTIFY_VERSION }}.tar.gz tar xzvf uncrustify-${{ env.UNCRUSTIFY_VERSION }}.tar.gz cd uncrustify-uncrustify-${{ env.UNCRUSTIFY_VERSION }} - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release cmake --build build -- -j$(nproc) -s mkdir ~/uncrustify cp build/uncrustify ~/uncrustify/