Skip to content

Commit 714f30f

Browse files
committed
Token: only look up standard types in update_property_info() if necessary
1 parent 947d895 commit 714f30f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/token.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,18 @@ void Token::update_property_info()
127127
tokType(eVariable);
128128
else if (mTokensFrontBack.list.isKeyword(mStr)) {
129129
tokType(eKeyword);
130+
update_property_isStandardType();
130131
setFlag(fIsControlFlowKeyword, controlFlowKeywords.find(mStr) != controlFlowKeywords.end());
131132
}
132133
else if (mStr == "asm") { // TODO: not a keyword
133134
tokType(eKeyword);
134135
}
135-
else if (mTokType != eVariable && mTokType != eFunction && mTokType != eType && mTokType != eKeyword)
136+
// TODO: remove condition? appears to be (no longer necessary) protection for reset of varids in Tokenizer::setVarId()
137+
else if (mTokType != eVariable && mTokType != eFunction && mTokType != eType && mTokType != eKeyword) {
136138
tokType(eName);
139+
// some types are not being treated as keywords
140+
update_property_isStandardType();
141+
}
137142
} else if (simplecpp::Token::isNumberLike(mStr)) {
138143
if ((MathLib::isInt(mStr) || MathLib::isFloat(mStr)) && mStr.find('_') == std::string::npos)
139144
tokType(eNumber);
@@ -174,8 +179,6 @@ void Token::update_property_info()
174179
tokType(eEllipsis);
175180
else
176181
tokType(eOther);
177-
178-
update_property_isStandardType();
179182
} else {
180183
tokType(eNone);
181184
}

lib/token.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,9 @@ class CPPCHECKLIB Token {
952952
return mImpl->mVarId;
953953
}
954954
void varId(nonneg int id) {
955+
if (mImpl->mVarId == id)
956+
return;
957+
955958
mImpl->mVarId = id;
956959
// TODO: remove special handling?
957960
if (id != 0) {

0 commit comments

Comments
 (0)