Skip to content

Commit 2173eb4

Browse files
committed
astutils.cpp: avoid checks for C++ code when processing C code [skip ci]
1 parent ead02d5 commit 2173eb4

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/astutils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3085,7 +3085,7 @@ bool isIteratorPair(const std::vector<const Token*>& args)
30853085

30863086
const Token *findLambdaStartToken(const Token *last)
30873087
{
3088-
if (!last || last->str() != "}")
3088+
if (!last || !last->isCpp() || last->str() != "}")
30893089
return nullptr;
30903090
const Token* tok = last->link();
30913091
if (Token::simpleMatch(tok->astParent(), "("))
@@ -3095,7 +3095,7 @@ const Token *findLambdaStartToken(const Token *last)
30953095
return nullptr;
30963096
}
30973097

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

3116-
if (!first || first->str() != "[")
3116+
if (!first || !first->isCpp() || first->str() != "[")
31173117
return nullptr;
31183118
if (!maybeLambda(first->previous()))
31193119
return nullptr;
@@ -3423,7 +3423,7 @@ bool isNullOperand(const Token *expr)
34233423
{
34243424
if (!expr)
34253425
return false;
3426-
if (Token::Match(expr, "static_cast|const_cast|dynamic_cast|reinterpret_cast <"))
3426+
if (expr->isCpp() && Token::Match(expr, "static_cast|const_cast|dynamic_cast|reinterpret_cast <"))
34273427
expr = expr->astParent();
34283428
else if (!expr->isCast())
34293429
return Token::Match(expr, "NULL|nullptr");

0 commit comments

Comments
 (0)