Skip to content

Commit

Permalink
Token: folded update_property_char_string_literal() into `update_pr…
Browse files Browse the repository at this point in the history
…operty_info()`
  • Loading branch information
firewave committed Jul 15, 2024
1 parent 7bd50f2 commit 7ae26a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
18 changes: 6 additions & 12 deletions lib/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,14 @@ void Token::update_property_info()
if (!mStr.empty()) {
if (mStr == "true" || mStr == "false")
tokType(eBoolean);
else if (isStringLiteral(mStr))
else if (isStringLiteral(mStr)) {
tokType(eString);
else if (isCharLiteral(mStr))
isLong(isPrefixStringCharLiteral(mStr, '"', "L"));
}
else if (isCharLiteral(mStr)) {
tokType(eChar);
isLong(isPrefixStringCharLiteral(mStr, '\'', "L"));
}
else if (std::isalpha((unsigned char)mStr[0]) || mStr[0] == '_' || mStr[0] == '$') { // Name
if (mImpl->mVarId)
tokType(eVariable);
Expand Down Expand Up @@ -159,7 +163,6 @@ void Token::update_property_info()
else
tokType(eOther);

update_property_char_string_literal();
update_property_isStandardType();
} else {
tokType(eNone);
Expand Down Expand Up @@ -190,15 +193,6 @@ void Token::update_property_isStandardType()
}
}

void Token::update_property_char_string_literal()
{
if (mTokType != Token::eString && mTokType != Token::eChar)
return;

isLong(((mTokType == Token::eString) && isPrefixStringCharLiteral(mStr, '"', "L")) ||
((mTokType == Token::eChar) && isPrefixStringCharLiteral(mStr, '\'', "L")));
}

bool Token::isUpperCaseName() const
{
if (!isName())
Expand Down
3 changes: 0 additions & 3 deletions lib/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -1418,9 +1418,6 @@ class CPPCHECKLIB Token {
/** Update internal property cache about isStandardType() */
void update_property_isStandardType();

/** Update internal property cache about string and char literals */
void update_property_char_string_literal();

/** Internal helper function to avoid excessive string allocations */
void astStringVerboseRecursive(std::string& ret, const nonneg int indent1 = 0, const nonneg int indent2 = 0) const;

Expand Down

0 comments on commit 7ae26a0

Please sign in to comment.