Skip to content

Commit

Permalink
Fix simplification of operator->
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jul 11, 2023
1 parent 8a14ac3 commit c054ccf
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2469,7 +2469,7 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, Member
if (!end || !scope || !Token::simpleMatch(end->astParent(), "."))
return false;
auto it = std::find_if(scope->functionList.begin(), scope->functionList.end(), [](const Function& f) {
return f.isConst() && f.name() == "operator.";
return f.isConst() && f.name() == "operator->";
});
if (it == scope->functionList.end() || !it->retType || !it->retType->classScope)
return false;
Expand Down
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9778,7 +9778,7 @@ void Tokenizer::simplifyOperatorName()
if (par->str() == "," && !op.empty())
break;
if (!(Token::Match(par, "<|>") && !op.empty())) {
op += par->str();
op += par->str() == "." ? par->originalName() : par->str();
par = par->next();
done = false;
}
Expand Down
2 changes: 1 addition & 1 deletion test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8370,7 +8370,7 @@ class TestClass : public TestFixture {
"struct TPtr : public SPtr {\n"
" T* operator->() const { return (T*)p; }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:8]: (style) The function 'operator.' overrides a function in a base class but is not marked with a 'override' specifier.\n",
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:8]: (style) The function 'operator->' overrides a function in a base class but is not marked with a 'override' specifier.\n",
errout.str());
}

Expand Down
2 changes: 1 addition & 1 deletion test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4950,7 +4950,7 @@ class TestTokenizer : public TestFixture {
const char code[] = "void f() {"
"static_cast<ScToken*>(xResult.operator->())->GetMatrix();"
"}";
const char result[] = "void f ( ) { static_cast < ScToken * > ( xResult . operator. ( ) ) . GetMatrix ( ) ; }";
const char result[] = "void f ( ) { static_cast < ScToken * > ( xResult . operator-> ( ) ) . GetMatrix ( ) ; }";
ASSERT_EQUALS(result, tokenizeAndStringify(code));
}

Expand Down

0 comments on commit c054ccf

Please sign in to comment.