Fix returnValueType()

This commit is contained in:
chrchr 2023-06-07 17:49:45 +02:00
parent 55f34e2681
commit 68a59830a4
1 changed files with 33 additions and 29 deletions

View File

@ -1366,6 +1366,7 @@ const Library::NonOverlappingData* Library::getNonOverlappingData(const Token *f
Library::UseRetValType Library::getUseRetValType(const Token *ftok) const Library::UseRetValType Library::getUseRetValType(const Token *ftok) const
{ {
if (isNotLibraryFunction(ftok)) {
if (Token::simpleMatch(ftok->astParent(), ".")) { if (Token::simpleMatch(ftok->astParent(), ".")) {
using Yield = Library::Container::Yield; using Yield = Library::Container::Yield;
const Yield yield = astContainerYield(ftok->astParent()->astOperand1()); const Yield yield = astContainerYield(ftok->astParent()->astOperand1());
@ -1375,8 +1376,8 @@ Library::UseRetValType Library::getUseRetValType(const Token *ftok) const
(yield == Yield::ITERATOR && astContainerAction(ftok->astParent()->astOperand1()) == Library::Container::Action::NO_ACTION)) (yield == Yield::ITERATOR && astContainerAction(ftok->astParent()->astOperand1()) == Library::Container::Action::NO_ACTION))
return Library::UseRetValType::DEFAULT; return Library::UseRetValType::DEFAULT;
} }
if (isNotLibraryFunction(ftok))
return Library::UseRetValType::NONE; return Library::UseRetValType::NONE;
}
const std::unordered_map<std::string, Function>::const_iterator it = functions.find(getFunctionName(ftok)); const std::unordered_map<std::string, Function>::const_iterator it = functions.find(getFunctionName(ftok));
if (it != functions.cend()) if (it != functions.cend())
return it->second.useretval; return it->second.useretval;
@ -1393,13 +1394,14 @@ const std::string& Library::returnValue(const Token *ftok) const
const std::string& Library::returnValueType(const Token *ftok) const const std::string& Library::returnValueType(const Token *ftok) const
{ {
if (isNotLibraryFunction(ftok)) {
if (Token::simpleMatch(ftok->astParent(), ".") && ftok->astParent()->astOperand1()) { if (Token::simpleMatch(ftok->astParent(), ".") && ftok->astParent()->astOperand1()) {
const Token* contTok = ftok->astParent()->astOperand1(); const Token* contTok = ftok->astParent()->astOperand1();
if (contTok->valueType() && contTok->valueType()->container) if (contTok->valueType() && contTok->valueType()->container)
return contTok->valueType()->container->getReturnType(ftok->str()); return contTok->valueType()->container->getReturnType(ftok->str());
} }
if (isNotLibraryFunction(ftok))
return emptyString; return emptyString;
}
const std::map<std::string, std::string>::const_iterator it = mReturnValueType.find(getFunctionName(ftok)); const std::map<std::string, std::string>::const_iterator it = mReturnValueType.find(getFunctionName(ftok));
return it != mReturnValueType.cend() ? it->second : emptyString; return it != mReturnValueType.cend() ? it->second : emptyString;
} }
@ -1492,14 +1494,15 @@ bool Library::isFunctionConst(const Token *ftok) const
{ {
if (ftok->function() && ftok->function()->isConst()) if (ftok->function() && ftok->function()->isConst())
return true; return true;
if (isNotLibraryFunction(ftok)) {
if (Token::simpleMatch(ftok->astParent(), ".")) { if (Token::simpleMatch(ftok->astParent(), ".")) {
using Yield = Library::Container::Yield; using Yield = Library::Container::Yield;
const Yield yield = astContainerYield(ftok->astParent()->astOperand1()); const Yield yield = astContainerYield(ftok->astParent()->astOperand1());
if (yield == Yield::EMPTY || yield == Yield::SIZE || yield == Yield::BUFFER_NT) if (yield == Yield::EMPTY || yield == Yield::SIZE || yield == Yield::BUFFER_NT)
return true; return true;
} }
if (isNotLibraryFunction(ftok))
return false; return false;
}
const std::unordered_map<std::string, Function>::const_iterator it = functions.find(getFunctionName(ftok)); const std::unordered_map<std::string, Function>::const_iterator it = functions.find(getFunctionName(ftok));
return (it != functions.cend() && it->second.isconst); return (it != functions.cend() && it->second.isconst);
} }
@ -1508,13 +1511,14 @@ bool Library::isnoreturn(const Token *ftok) const
{ {
if (ftok->function() && ftok->function()->isAttributeNoreturn()) if (ftok->function() && ftok->function()->isAttributeNoreturn())
return true; return true;
if (isNotLibraryFunction(ftok)) {
if (Token::simpleMatch(ftok->astParent(), ".")) { if (Token::simpleMatch(ftok->astParent(), ".")) {
if (astContainerAction(ftok->astParent()->astOperand1()) != Library::Container::Action::NO_ACTION || if (astContainerAction(ftok->astParent()->astOperand1()) != Library::Container::Action::NO_ACTION ||
astContainerYield(ftok->astParent()->astOperand1()) != Library::Container::Yield::NO_YIELD) astContainerYield(ftok->astParent()->astOperand1()) != Library::Container::Yield::NO_YIELD)
return false; return false;
} }
if (isNotLibraryFunction(ftok))
return false; return false;
}
const std::unordered_map<std::string, FalseTrueMaybe>::const_iterator it = mNoReturn.find(getFunctionName(ftok)); const std::unordered_map<std::string, FalseTrueMaybe>::const_iterator it = mNoReturn.find(getFunctionName(ftok));
if (it == mNoReturn.end()) if (it == mNoReturn.end())
return false; return false;