Refactorization: Renamed Token::isOperator() to Token::isOperatorKeyword() to avoid confusion with Token::isOp(), use Token::isOperatorKeyword() in setVarId().

This commit is contained in:
PKEuS 2015-07-22 13:57:14 +02:00
parent 4e693f1620
commit 258e3b9dc3
3 changed files with 8 additions and 11 deletions

View File

@ -347,7 +347,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
function.nestedIn = scope;
// operator function
if (function.tokenDef->isOperator()) {
if (function.tokenDef->isOperatorKeyword()) {
function.isOperator(true);
// 'operator =' is special

View File

@ -374,11 +374,11 @@ public:
void isAttributeNothrow(bool value) {
setFlag(fIsAttributeNothrow, value);
}
bool isOperator() const {
return getFlag(fIsOperator);
bool isOperatorKeyword() const {
return getFlag(fIsOperatorKeyword);
}
void isOperator(bool value) {
setFlag(fIsOperator, value);
void isOperatorKeyword(bool value) {
setFlag(fIsOperatorKeyword, value);
}
static const Token *findsimplematch(const Token *tok, const char pattern[]);
@ -784,7 +784,7 @@ private:
fIsAttributeNoreturn = (1 << 12), // __attribute__((noreturn)), __declspec(noreturn)
fIsAttributeNothrow = (1 << 13), // __attribute__((nothrow)), __declspec(nothrow)
fIsAttributeUsed = (1 << 14), // __attribute__((used))
fIsOperator = (1 << 15) // operator=, etc
fIsOperatorKeyword = (1 << 15) // operator=, etc
};
unsigned int _flags;

View File

@ -2776,10 +2776,7 @@ void Tokenizer::setVarId()
else if (Token::Match(prev2, "%type% ( !!)") && Token::simpleMatch(tok2->link(), ") ;")) {
// In C++ , a variable can't be called operator+ or something like that.
if (isCPP() &&
prev2->str().size() >= 9 &&
prev2->str().compare(0, 8, "operator") == 0 &&
prev2->str()[8] != '_' &&
!std::isalnum(prev2->str()[8]))
prev2->isOperatorKeyword())
continue;
const Token *tok3 = tok2->next();
@ -9985,7 +9982,7 @@ void Tokenizer::simplifyOperatorName()
}
if (!op.empty())
tok->isOperator(true);
tok->isOperatorKeyword(true);
}
}