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 {
if (currentText=="operator") {
handleOperatorOverloading("",
"",
mIndex,
false,
false);
return;
}
@ -1759,10 +1757,8 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType)
if (currentText=="operator") {
// operator overloading
handleOperatorOverloading(
"",
"",
mIndex,
false,
false);
return;
}
@ -1834,10 +1830,9 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType)
while (mIndex+1 < mTokenizer.tokenCount()) {
if (mTokenizer[mIndex]->text=="operator") {
handleOperatorOverloading(sType,
sName,
//sName,
mIndex,
isStatic,
isFriend);
isStatic);
return;
} else if (mTokenizer[mIndex + 1]->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);
}
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"
int index=operatorTokenIndex+1;
@ -2561,13 +2558,23 @@ void CppParser::handleOperatorOverloading(const QString &sType, const QString &p
return;
}
Q_ASSERT(!op.isEmpty());
handleMethod(StatementKind::skFunction,
if (isIdentChar(op.front())) {
handleMethod(StatementKind::skFunction,
sType+" "+op,
"operator("+op+")",
index,
isStatic,
false,
true);
} else {
handleMethod(StatementKind::skFunction,
sType,
prefix+"operator"+(isIdentChar(op.front())?op+" ":op),
"operator"+op,
index,
isStatic,
isFriend,
false,
true);
}
}
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 handleOperatorOverloading(
const QString& sType,
const QString& prefix,
// const QString& prefix,
int operatorTokenIndex,
bool isStatic,
bool isFriend);
bool isStatic);
void handleMethod(
StatementKind functionKind,
const QString& sType,