fix: wrong type for operator overloading for conversion functions.

This commit is contained in:
Roy Qu 2023-03-10 20:50:46 +08:00
parent fec78d0045
commit fdc04c0d4f
2 changed files with 20 additions and 14 deletions

View File

@ -1731,9 +1731,7 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType)
} else { } else {
if (currentText=="operator") { if (currentText=="operator") {
handleOperatorOverloading("", handleOperatorOverloading("",
"",
mIndex, mIndex,
false,
false); false);
return; return;
} }
@ -1759,10 +1757,8 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType)
if (currentText=="operator") { if (currentText=="operator") {
// operator overloading // operator overloading
handleOperatorOverloading( handleOperatorOverloading(
"",
"", "",
mIndex, mIndex,
false,
false); false);
return; return;
} }
@ -1834,10 +1830,9 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType)
while (mIndex+1 < mTokenizer.tokenCount()) { while (mIndex+1 < mTokenizer.tokenCount()) {
if (mTokenizer[mIndex]->text=="operator") { if (mTokenizer[mIndex]->text=="operator") {
handleOperatorOverloading(sType, handleOperatorOverloading(sType,
sName, //sName,
mIndex, mIndex,
isStatic, isStatic);
isFriend);
return; return;
} else if (mTokenizer[mIndex + 1]->text == '(') { } else if (mTokenizer[mIndex + 1]->text == '(') {
if (mIndex+2<mTokenizer.tokenCount() && mTokenizer[mIndex+2]->text == '*') { if (mIndex+2<mTokenizer.tokenCount() && mTokenizer[mIndex+2]->text == '*') {
@ -2524,7 +2519,9 @@ void CppParser::handleLambda(int index, int endIndex)
removeScopeLevel(mTokenizer[bodyEnd]->line); removeScopeLevel(mTokenizer[bodyEnd]->line);
} }
void CppParser::handleOperatorOverloading(const QString &sType, const QString &prefix, int operatorTokenIndex, bool isStatic, bool isFriend) void CppParser::handleOperatorOverloading(const QString &sType,
//const QString &prefix,
int operatorTokenIndex, bool isStatic)
{ {
//operatorTokenIndex is the token index of "operator" //operatorTokenIndex is the token index of "operator"
int index=operatorTokenIndex+1; int index=operatorTokenIndex+1;
@ -2561,13 +2558,23 @@ void CppParser::handleOperatorOverloading(const QString &sType, const QString &p
return; return;
} }
Q_ASSERT(!op.isEmpty()); Q_ASSERT(!op.isEmpty());
if (isIdentChar(op.front())) {
handleMethod(StatementKind::skFunction, handleMethod(StatementKind::skFunction,
sType, sType+" "+op,
prefix+"operator"+(isIdentChar(op.front())?op+" ":op), "operator("+op+")",
index, index,
isStatic, isStatic,
isFriend, false,
true); true);
} else {
handleMethod(StatementKind::skFunction,
sType,
"operator"+op,
index,
isStatic,
false,
true);
}
} }
void CppParser::handleMethod(StatementKind functionKind,const QString &sType, const QString &sName, int argStart, bool isStatic, bool isFriend,bool isOperatorOverload) void CppParser::handleMethod(StatementKind functionKind,const QString &sType, const QString &sName, int argStart, bool isStatic, bool isFriend,bool isOperatorOverload)

View File

@ -445,10 +445,9 @@ private:
void handleLambda(int index, int endIndex); void handleLambda(int index, int endIndex);
void handleOperatorOverloading( void handleOperatorOverloading(
const QString& sType, const QString& sType,
const QString& prefix, // const QString& prefix,
int operatorTokenIndex, int operatorTokenIndex,
bool isStatic, bool isStatic);
bool isFriend);
void handleMethod( void handleMethod(
StatementKind functionKind, StatementKind functionKind,
const QString& sType, const QString& sType,