Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
pfultz2 committed Aug 21, 2023
1 parent d13f794 commit 3893920
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,8 @@ std::vector<ValueType> getParentValueTypes(const Token* tok, const Settings* set
return {std::move(vtParent)};
}
// The return type of a function is not the parent valuetype
if (Token::simpleMatch(tok->astParent(), "(") && ftok && !tok->astParent()->isCast() && ftok->tokType() != Token::eType)
if (Token::simpleMatch(tok->astParent(), "(") && ftok && !tok->astParent()->isCast() &&
ftok->tokType() != Token::eType)
return {};
if (Token::Match(tok->astParent(), "return|(|{|%assign%") && parent) {
*parent = tok->astParent();
Expand Down
5 changes: 3 additions & 2 deletions lib/checkcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1468,8 +1468,9 @@ void CheckCondition::alwaysTrueFalse()
const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase();
for (const Scope * scope : symbolDatabase->functionScopes) {
for (const Token* tok = scope->bodyStart->next(); tok != scope->bodyEnd; tok = tok->next()) {
// don't write false positives when templates are used or inside of asserts or non-evaluated contexts
if (tok->link() && (Token::simpleMatch(tok, "<") || Token::Match(tok->previous(), "static_assert|assert|ASSERT|sizeof|decltype ("))) {
// don't write false positives when templates are used or inside of asserts or non-evaluated contexts
if (tok->link() && (Token::simpleMatch(tok, "<") ||
Token::Match(tok->previous(), "static_assert|assert|ASSERT|sizeof|decltype ("))) {
tok = tok->link();
continue;
}
Expand Down
10 changes: 5 additions & 5 deletions test/testcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4527,11 +4527,11 @@ class TestCondition : public TestFixture {
ASSERT_EQUALS("[test.cpp:5]: (style) Condition 'i==7' is always false\n"
"[test.cpp:6]: (style) Condition 'p==nullptr' is always false\n",
errout.str());
check("enum E { E0, E1 };\n"
"void f() {\n"
" static_assert(static_cast<int>(E::E1) == 1);\n"
"}\n");

check("enum E { E0, E1 };\n"
"void f() {\n"
" static_assert(static_cast<int>(E::E1) == 1);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}

Expand Down

0 comments on commit 3893920

Please sign in to comment.