summaryrefslogtreecommitdiff
path: root/idlc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-07 14:22:27 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-07 18:55:33 +0200
commitf9151f426281de0fb7f446d7b968f2b0c09b7a9b (patch)
tree652848f582da6910b3770328f2c65e3a345b88f2 /idlc
parentf91745c82128bfd6bf795f4e2e1cc290448f1cdb (diff)
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>
Diffstat (limited to 'idlc')
-rw-r--r--idlc/source/astdump.cxx37
-rw-r--r--idlc/source/astinterface.cxx137
-rw-r--r--idlc/source/fehelper.cxx38
-rw-r--r--idlc/source/idlc.cxx66
4 files changed, 141 insertions, 137 deletions
diff --git a/idlc/source/astdump.cxx b/idlc/source/astdump.cxx
index 081671615912..79613e137fb9 100644
--- a/idlc/source/astdump.cxx
+++ b/idlc/source/astdump.cxx
@@ -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));
}
}
diff --git a/idlc/source/astinterface.cxx b/idlc/source/astinterface.cxx
index 991759384869..a5f2ed21bf2c 100644
--- a/idlc/source/astinterface.cxx
+++ b/idlc/source/astinterface.cxx
@@ -253,54 +253,55 @@ 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)
- {
- 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);
- }
+ 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_MANDATORY:
- if (direct || (!optional && !mainOptional)) {
- doubleDeclarations.interfaces.push_back(ifc);
- }
- return;
+ case INTERFACE_DIRECT_OPTIONAL:
+ if (direct || !mainOptional) {
+ doubleDeclarations.interfaces.push_back(ifc);
}
- }
- if (direct || !optional) {
- for (DeclList::const_iterator i(ifc->getIteratorBegin());
- i != ifc->getIteratorEnd(); ++i)
- {
- checkMemberClashes(
- doubleDeclarations.members, *i, !mainOptional);
+ return;
+
+ case INTERFACE_INDIRECT_MANDATORY:
+ if (direct) {
+ doubleDeclarations.interfaces.push_back(ifc);
}
- for (auto const& elem : ifc->m_inheritedInterfaces)
- {
- checkInheritedInterfaceClashes(
- doubleDeclarations, seenInterfaces, elem.getResolved(),
- false, elem.isOptional(), mainOptional);
+ 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)
+ {
+ checkMemberClashes(
+ doubleDeclarations.members, *i, !mainOptional);
+ }
+ for (auto const& elem : ifc->m_inheritedInterfaces)
+ {
+ checkInheritedInterfaceClashes(
+ doubleDeclarations, seenInterfaces, elem.getResolved(),
+ false, elem.isOptional(), mainOptional);
+ }
}
void AstInterface::checkMemberClashes(
@@ -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());
}
}
diff --git a/idlc/source/fehelper.cxx b/idlc/source/fehelper.cxx
index a147d3d26e1a..607f5a145677 100644
--- a/idlc/source/fehelper.cxx
+++ b/idlc/source/fehelper.cxx
@@ -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 ) )
- {
- m_pInherits = pDecl;
- }
- }
- else
+ if ( ErrorHandler::checkPublished( pDecl ) )
{
- 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: */
diff --git a/idlc/source/idlc.cxx b/idlc/source/idlc.cxx
index 61190845f1ba..5984ca759448 100644
--- a/idlc/source/idlc.cxx
+++ b/idlc/source/idlc.cxx
@@ -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)