From 7754449fd651f866316f558bf033640a694093b4 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 6 Sep 2020 23:48:05 -0500 Subject: [PATCH] Format --- lib/checkstl.cpp | 9 +++++---- test/teststl.cpp | 12 ++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 2a7339bf9..2158a4abe 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -89,19 +89,20 @@ void CheckStl::outOfBounds() const Token* indexTok = parent->tokAt(2)->astOperand2(); if (!indexTok) continue; - const ValueFlow::Value *indexValue = indexTok ? indexTok->getMaxValue(false) : nullptr; + const ValueFlow::Value* indexValue = indexTok ? indexTok->getMaxValue(false) : nullptr; if (indexValue && indexValue->intvalue >= value.intvalue) { - outOfBoundsError(parent, tok->expressionString(), &value, indexTok->expressionString(), indexValue); + outOfBoundsError( + parent, tok->expressionString(), &value, indexTok->expressionString(), indexValue); continue; } if (mSettings->isEnabled(Settings::WARNING)) { indexValue = indexTok ? indexTok->getMaxValue(true) : nullptr; if (indexValue && indexValue->intvalue >= value.intvalue) { - outOfBoundsError(parent, tok->expressionString(), &value, indexTok->expressionString(), indexValue); + outOfBoundsError( + parent, tok->expressionString(), &value, indexTok->expressionString(), indexValue); continue; } } - } if (Token::Match(tok, "%name% . %name% (") && container->getYield(tok->strAt(2)) == Library::Container::Yield::START_ITERATOR) { const Token *fparent = tok->tokAt(3)->astParent(); diff --git a/test/teststl.cpp b/test/teststl.cpp index 96ee25a9b..af953104f 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -352,15 +352,19 @@ private: " std::vector v;\n" " if(v.at(b?42:0)) {}\n" "}\n"); - ASSERT_EQUALS("test.cpp:3:error:Out of bounds access in expression 'v.at(b?42:0)' because 'v' is empty and 'at' may be non-zero.\n", errout.str()); + ASSERT_EQUALS( + "test.cpp:3:error:Out of bounds access in expression 'v.at(b?42:0)' because 'v' is empty and 'at' may be non-zero.\n", + errout.str()); checkNormal("void f(std::vector v, bool b){\n" " if (v.size() == 1)\n" " if(v.at(b?42:0)) {}\n" "}\n"); - ASSERT_EQUALS("test.cpp:3:warning:Either the condition 'v.size()==1' is redundant or v size can be 1. Expression 'v.at' cause access out of bounds.\n" - "test.cpp:2:note:condition 'v.size()==1'\n" - "test.cpp:3:note:Access out of bounds\n", errout.str()); + ASSERT_EQUALS( + "test.cpp:3:warning:Either the condition 'v.size()==1' is redundant or v size can be 1. Expression 'v.at' cause access out of bounds.\n" + "test.cpp:2:note:condition 'v.size()==1'\n" + "test.cpp:3:note:Access out of bounds\n", + errout.str()); } void outOfBoundsIndexExpression() {