loplugin:flatten in idlc

Change-Id: Ieef78720d4569d59bc69b40a1bea02839667b847
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91819
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2020-04-07 18:55:33 +02:00
parent f91745c821
commit f9151f4262
4 changed files with 146 additions and 142 deletions
+19 -18
View File
@@ -383,24 +383,25 @@ void AstAttribute::dumpExceptions(
typereg::Writer & writer, OUString const & documentation,
DeclList const & exceptions, RTMethodMode flags, sal_uInt16 * methodIndex) const
{
if (!exceptions.empty()) {
OSL_ASSERT(methodIndex != nullptr);
sal_uInt16 idx = (*methodIndex)++;
// exceptions.size() <= SAL_MAX_UINT16 already checked in
// AstInterface::dump:
writer.setMethodData(
idx, documentation, flags,
OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8),
"void", 0,
static_cast< sal_uInt16 >(exceptions.size()));
sal_uInt16 exceptionIndex = 0;
for (auto const& elem : exceptions)
{
writer.setMethodExceptionTypeName(
idx, exceptionIndex++,
OStringToOUString(
elem->getRelativName(), RTL_TEXTENCODING_UTF8));
}
if (exceptions.empty())
return;
OSL_ASSERT(methodIndex != nullptr);
sal_uInt16 idx = (*methodIndex)++;
// exceptions.size() <= SAL_MAX_UINT16 already checked in
// AstInterface::dump:
writer.setMethodData(
idx, documentation, flags,
OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8),
"void", 0,
static_cast< sal_uInt16 >(exceptions.size()));
sal_uInt16 exceptionIndex = 0;
for (auto const& elem : exceptions)
{
writer.setMethodExceptionTypeName(
idx, exceptionIndex++,
OStringToOUString(
elem->getRelativName(), RTL_TEXTENCODING_UTF8));
}
}
+75 -72
View File
@@ -253,53 +253,54 @@ void AstInterface::checkInheritedInterfaceClashes(
std::set< OString > & seenInterfaces, AstInterface const * ifc,
bool direct, bool optional, bool mainOptional) const
{
if (direct || optional
|| seenInterfaces.insert(ifc->getScopedName()).second)
if (!(direct || optional
|| seenInterfaces.insert(ifc->getScopedName()).second))
return;
VisibleInterfaces::const_iterator visible(
m_visibleInterfaces.find(ifc->getScopedName()));
if (visible != m_visibleInterfaces.end()) {
switch (visible->second) {
case INTERFACE_INDIRECT_OPTIONAL:
if (direct && optional) {
doubleDeclarations.interfaces.push_back(ifc);
return;
}
break;
case INTERFACE_DIRECT_OPTIONAL:
if (direct || !mainOptional) {
doubleDeclarations.interfaces.push_back(ifc);
}
return;
case INTERFACE_INDIRECT_MANDATORY:
if (direct) {
doubleDeclarations.interfaces.push_back(ifc);
}
return;
case INTERFACE_DIRECT_MANDATORY:
if (direct || (!optional && !mainOptional)) {
doubleDeclarations.interfaces.push_back(ifc);
}
return;
}
}
if (!(direct || !optional))
return;
for (DeclList::const_iterator i(ifc->getIteratorBegin());
i != ifc->getIteratorEnd(); ++i)
{
VisibleInterfaces::const_iterator visible(
m_visibleInterfaces.find(ifc->getScopedName()));
if (visible != m_visibleInterfaces.end()) {
switch (visible->second) {
case INTERFACE_INDIRECT_OPTIONAL:
if (direct && optional) {
doubleDeclarations.interfaces.push_back(ifc);
return;
}
break;
case INTERFACE_DIRECT_OPTIONAL:
if (direct || !mainOptional) {
doubleDeclarations.interfaces.push_back(ifc);
}
return;
case INTERFACE_INDIRECT_MANDATORY:
if (direct) {
doubleDeclarations.interfaces.push_back(ifc);
}
return;
case INTERFACE_DIRECT_MANDATORY:
if (direct || (!optional && !mainOptional)) {
doubleDeclarations.interfaces.push_back(ifc);
}
return;
}
}
if (direct || !optional) {
for (DeclList::const_iterator i(ifc->getIteratorBegin());
i != ifc->getIteratorEnd(); ++i)
{
checkMemberClashes(
doubleDeclarations.members, *i, !mainOptional);
}
for (auto const& elem : ifc->m_inheritedInterfaces)
{
checkInheritedInterfaceClashes(
doubleDeclarations, seenInterfaces, elem.getResolved(),
false, elem.isOptional(), mainOptional);
}
}
checkMemberClashes(
doubleDeclarations.members, *i, !mainOptional);
}
for (auto const& elem : ifc->m_inheritedInterfaces)
{
checkInheritedInterfaceClashes(
doubleDeclarations, seenInterfaces, elem.getResolved(),
false, elem.isOptional(), mainOptional);
}
}
@@ -309,25 +310,26 @@ void AstInterface::checkMemberClashes(
{
VisibleMembers::const_iterator i(
m_visibleMembers.find(member->getLocalName()));
if (i != m_visibleMembers.end()) {
if (i->second.mandatory != nullptr) {
if (i->second.mandatory->getScopedName() != member->getScopedName())
{
if (i == m_visibleMembers.end())
return;
if (i->second.mandatory != nullptr) {
if (i->second.mandatory->getScopedName() != member->getScopedName())
{
DoubleMemberDeclaration d;
d.first = i->second.mandatory;
d.second = member;
doubleMembers.push_back(d);
}
} else if (checkOptional) {
for (auto const& elem : i->second.optionals)
{
if (elem.second->getScopedName() != member->getScopedName()) {
DoubleMemberDeclaration d;
d.first = i->second.mandatory;
d.first = elem.second;
d.second = member;
doubleMembers.push_back(d);
}
} else if (checkOptional) {
for (auto const& elem : i->second.optionals)
{
if (elem.second->getScopedName() != member->getScopedName()) {
DoubleMemberDeclaration d;
d.first = elem.second;
d.second = member;
doubleMembers.push_back(d);
}
}
}
}
}
@@ -345,17 +347,18 @@ void AstInterface::addVisibleInterface(
if (!result.second && kind > result.first->second) {
result.first->second = kind;
}
if (!optional && !seen) {
for (DeclList::const_iterator i(ifc->getIteratorBegin());
i != ifc->getIteratorEnd(); ++i)
{
m_visibleMembers.emplace(
(*i)->getLocalName(), VisibleMember(*i));
}
for (auto const& elem : ifc->m_inheritedInterfaces)
{
addVisibleInterface(elem.getResolved(), false, elem.isOptional());
}
if (optional || seen)
return;
for (DeclList::const_iterator i(ifc->getIteratorBegin());
i != ifc->getIteratorEnd(); ++i)
{
m_visibleMembers.emplace(
(*i)->getLocalName(), VisibleMember(*i));
}
for (auto const& elem : ifc->m_inheritedInterfaces)
{
addVisibleInterface(elem.getResolved(), false, elem.isOptional());
}
}
+19 -19
View File
@@ -69,34 +69,34 @@ FeInheritanceHeader::FeInheritanceHeader(
void FeInheritanceHeader::initializeInherits(OString const * pInherits)
{
if ( pInherits )
if ( !pInherits )
return;
AstScope* pScope = idlc()->scopes()->topNonNull();
AstDeclaration* pDecl = pScope->lookupByName(*pInherits);
if ( pDecl )
{
AstScope* pScope = idlc()->scopes()->topNonNull();
AstDeclaration* pDecl = pScope->lookupByName(*pInherits);
if ( pDecl )
AstDeclaration const * resolved = resolveTypedefs(pDecl);
if ( resolved->getNodeType() == getNodeType()
&& (resolved->getNodeType() != NT_interface
|| static_cast< AstInterface const * >(
resolved)->isDefined()) )
{
AstDeclaration const * resolved = resolveTypedefs(pDecl);
if ( resolved->getNodeType() == getNodeType()
&& (resolved->getNodeType() != NT_interface
|| static_cast< AstInterface const * >(
resolved)->isDefined()) )
if ( ErrorHandler::checkPublished( pDecl ) )
{
if ( ErrorHandler::checkPublished( pDecl ) )
{
m_pInherits = pDecl;
}
}
else
{
ErrorHandler::inheritanceError(
getNodeType(), getName(), pDecl);
m_pInherits = pDecl;
}
}
else
{
ErrorHandler::lookupError(*pInherits);
ErrorHandler::inheritanceError(
getNodeType(), getName(), pDecl);
}
}
else
{
ErrorHandler::lookupError(*pInherits);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+33 -33
View File
@@ -148,53 +148,53 @@ static void predefineXInterface(AstModule* pRoot)
static void initializePredefinedTypes(AstModule* pRoot)
{
if ( pRoot )
{
AstBaseType* pPredefined = new AstBaseType(ET_long, "long", pRoot);
pRoot->addDeclaration(pPredefined);
if ( !pRoot )
return;
pPredefined = new AstBaseType(ET_ulong, "unsigned long", pRoot);
pRoot->addDeclaration(pPredefined);
AstBaseType* pPredefined = new AstBaseType(ET_long, "long", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_hyper, "hyper", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_ulong, "unsigned long", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_uhyper, "unsigned hyper", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_hyper, "hyper", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_short, "short", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_uhyper, "unsigned hyper", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_ushort, "unsigned short", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_short, "short", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_float, "float", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_ushort, "unsigned short", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_double, "double", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_float, "float", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_char, "char", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_double, "double", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_byte, "byte", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_char, "char", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_any, "any", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_byte, "byte", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_string, "string", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_any, "any", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_type, "type", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_string, "string", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_boolean, "boolean", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_type, "type", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_void, "void", pRoot);
pRoot->addDeclaration(pPredefined);
}
pPredefined = new AstBaseType(ET_boolean, "boolean", pRoot);
pRoot->addDeclaration(pPredefined);
pPredefined = new AstBaseType(ET_void, "void", pRoot);
pRoot->addDeclaration(pPredefined);
}
Idlc::Idlc(Options* pOptions)