Skip to content

Commit 6ec5ac1

Browse files
committed
astutils.cpp: avoid checks for C++ code when processing C code [skip ci]
1 parent a48289d commit 6ec5ac1

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
@@ -3105,7 +3105,7 @@ bool isIteratorPair(const std::vector<const Token*>& args)
31053105

31063106
const Token *findLambdaStartToken(const Token *last)
31073107
{
3108-
if (!last || last->str() != "}")
3108+
if (!last || !last->isCpp() || last->str() != "}")
31093109
return nullptr;
31103110
const Token* tok = last->link();
31113111
if (Token::simpleMatch(tok->astParent(), "("))
@@ -3115,7 +3115,7 @@ const Token *findLambdaStartToken(const Token *last)
31153115
return nullptr;
31163116
}
31173117

3118-
template<class T>
3118+
template<class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )>
31193119
static T* findLambdaEndTokenGeneric(T* first)
31203120
{
31213121
auto maybeLambda = [](T* tok) -> bool {
@@ -3133,7 +3133,7 @@ static T* findLambdaEndTokenGeneric(T* first)
31333133
return true;
31343134
};
31353135

3136-
if (!first || first->str() != "[")
3136+
if (!first || !first->isCpp() || first->str() != "[")
31373137
return nullptr;
31383138
if (!maybeLambda(first->previous()))
31393139
return nullptr;
@@ -3447,7 +3447,7 @@ bool isNullOperand(const Token *expr)
34473447
{
34483448
if (!expr)
34493449
return false;
3450-
if (Token::Match(expr, "static_cast|const_cast|dynamic_cast|reinterpret_cast <"))
3450+
if (expr->isCpp() && Token::Match(expr, "static_cast|const_cast|dynamic_cast|reinterpret_cast <"))
34513451
expr = expr->astParent();
34523452
else if (!expr->isCast())
34533453
return Token::Match(expr, "NULL|nullptr");

0 commit comments

Comments
 (0)