Skip to content

Commit

Permalink
astutils.cpp: avoid checks for C++ code when processing C code [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Dec 12, 2023
1 parent ead02d5 commit 2173eb4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3085,7 +3085,7 @@ bool isIteratorPair(const std::vector<const Token*>& args)

const Token *findLambdaStartToken(const Token *last)
{
if (!last || last->str() != "}")
if (!last || !last->isCpp() || last->str() != "}")
return nullptr;
const Token* tok = last->link();
if (Token::simpleMatch(tok->astParent(), "("))
Expand All @@ -3095,7 +3095,7 @@ const Token *findLambdaStartToken(const Token *last)
return nullptr;
}

template<class T>
template<class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )>
static T* findLambdaEndTokenGeneric(T* first)
{
auto maybeLambda = [](T* tok) -> bool {
Expand All @@ -3113,7 +3113,7 @@ static T* findLambdaEndTokenGeneric(T* first)
return true;
};

if (!first || first->str() != "[")
if (!first || !first->isCpp() || first->str() != "[")
return nullptr;
if (!maybeLambda(first->previous()))
return nullptr;
Expand Down Expand Up @@ -3423,7 +3423,7 @@ bool isNullOperand(const Token *expr)
{
if (!expr)
return false;
if (Token::Match(expr, "static_cast|const_cast|dynamic_cast|reinterpret_cast <"))
if (expr->isCpp() && Token::Match(expr, "static_cast|const_cast|dynamic_cast|reinterpret_cast <"))
expr = expr->astParent();
else if (!expr->isCast())
return Token::Match(expr, "NULL|nullptr");
Expand Down

0 comments on commit 2173eb4

Please sign in to comment.