summaryrefslogtreecommitdiff
path: root/idlc
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-08-28 08:58:48 +0200
committerNorbert Thiebaud <nthiebaud@gmail.com>2014-09-07 02:42:30 -0500
commited75aa271956824c89b7c9df2c06e4ad09a74734 (patch)
tree432c17088789736364b2932b9085e5b17a8cc71a /idlc
parent5ca2d1e26513095670b3fd2dce6a464a415cab89 (diff)
create clang plugin to warn about C-style casts
We don't like C-style casts in our nice C++ code Change-Id: I94e7ec90de9275cd6e20c4146d4f3a74bed93c9d Reviewed-on: https://gerrit.libreoffice.org/10367 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com> Tested-by: Norbert Thiebaud <nthiebaud@gmail.com>
Diffstat (limited to 'idlc')
-rw-r--r--idlc/inc/idlc/astdeclaration.hxx2
-rw-r--r--idlc/inc/idlc/errorhandler.hxx2
-rw-r--r--idlc/source/astdump.cxx16
-rw-r--r--idlc/source/astenum.cxx4
-rw-r--r--idlc/source/astinterface.cxx7
-rw-r--r--idlc/source/astoperation.cxx2
-rw-r--r--idlc/source/astscope.cxx6
-rw-r--r--idlc/source/aststruct.cxx2
-rw-r--r--idlc/source/errorhandler.cxx4
-rw-r--r--idlc/source/fehelper.cxx4
-rw-r--r--idlc/source/idlc.cxx40
11 files changed, 45 insertions, 44 deletions
diff --git a/idlc/inc/idlc/astdeclaration.hxx b/idlc/inc/idlc/astdeclaration.hxx
index caa35d6a1598..d7d7aec22274 100644
--- a/idlc/inc/idlc/astdeclaration.hxx
+++ b/idlc/inc/idlc/astdeclaration.hxx
@@ -75,6 +75,8 @@ public:
{ return m_fullName.getStr()+1; }
AstScope* getScope()
{ return m_pScope; }
+ const AstScope* getScope() const
+ { return m_pScope; }
void setScope(AstScope* pSc)
{ m_pScope = pSc; }
NodeType getNodeType() const
diff --git a/idlc/inc/idlc/errorhandler.hxx b/idlc/inc/idlc/errorhandler.hxx
index 9877f081221f..1e7e7285d0d8 100644
--- a/idlc/inc/idlc/errorhandler.hxx
+++ b/idlc/inc/idlc/errorhandler.hxx
@@ -118,7 +118,7 @@ public:
void flagError(ErrorCode e, sal_uInt32 flag);
- void forwardLookupError(AstDeclaration* pForward, const OString& name);
+ void forwardLookupError(const AstDeclaration* pForward, const OString& name);
void constantExpected(AstDeclaration* pDecl, const OString& name);
diff --git a/idlc/source/astdump.cxx b/idlc/source/astdump.cxx
index 6e052fbb6046..d4bbc196b3d2 100644
--- a/idlc/source/astdump.cxx
+++ b/idlc/source/astdump.cxx
@@ -77,7 +77,7 @@ bool AstModule::dump(RegistryKey& rKey)
if ( pDecl->getNodeType() == NT_const &&
pDecl->isInMainfile() )
{
- ((AstConstant*)pDecl)->dumpBlob(
+ static_cast<AstConstant*>(pDecl)->dumpBlob(
aBlob, index++,
getNodeType() == NT_module && pDecl->isPublished());
}
@@ -197,7 +197,7 @@ bool AstService::dump(RegistryKey& rKey)
case NT_service_member:
if (getNodeType() == NT_singleton) {
OSL_ASSERT(superName.isEmpty());
- superName = ((AstServiceMember *)(*i))->
+ superName = (static_cast<AstServiceMember *>(*i))->
getRealService()->getRelativName();
break;
}
@@ -247,16 +247,16 @@ bool AstService::dump(RegistryKey& rKey)
{
switch ((*i)->getNodeType()) {
case NT_operation:
- ((AstOperation *)(*i))->dumpBlob(writer, constructorIndex++);
+ static_cast<AstOperation *>(*i)->dumpBlob(writer, constructorIndex++);
break;
case NT_property:
- ((AstAttribute *)(*i))->dumpBlob(writer, propertyIndex++, 0);
+ static_cast<AstAttribute *>(*i)->dumpBlob(writer, propertyIndex++, 0);
break;
case NT_interface_member:
{
- AstInterfaceMember * decl = (AstInterfaceMember *)(*i);
+ AstInterfaceMember * decl = static_cast<AstInterfaceMember *>(*i);
writer.setReferenceData(
referenceIndex++, decl->getDocumentation(), RT_REF_SUPPORTS,
(decl->isOptional() ? RT_ACCESS_OPTIONAL : RT_ACCESS_INVALID),
@@ -268,7 +268,7 @@ bool AstService::dump(RegistryKey& rKey)
case NT_service_member:
if (getNodeType() == NT_service)
{
- AstServiceMember * decl = (AstServiceMember *)(*i);
+ AstServiceMember * decl = static_cast<AstServiceMember *>(*i);
writer.setReferenceData(referenceIndex++, decl->getDocumentation(), RT_REF_EXPORTS,
(decl->isOptional() ? RT_ACCESS_OPTIONAL : RT_ACCESS_INVALID),
OStringToOUString(decl->getRealService()->getRelativName(),
@@ -278,7 +278,7 @@ bool AstService::dump(RegistryKey& rKey)
case NT_observes:
{
- AstObserves * decl = (AstObserves *)(*i);
+ AstObserves * decl = static_cast<AstObserves *>(*i);
writer.setReferenceData(referenceIndex++, decl->getDocumentation(), RT_REF_OBSERVES,
RT_ACCESS_INVALID,
OStringToOUString( decl->getRealInterface()->getRelativName(),
@@ -288,7 +288,7 @@ bool AstService::dump(RegistryKey& rKey)
case NT_needs:
{
- AstNeeds * decl = (AstNeeds *)(*i);
+ AstNeeds * decl = static_cast<AstNeeds *>(*i);
writer.setReferenceData( referenceIndex++, decl->getDocumentation(), RT_REF_NEEDS,
RT_ACCESS_INVALID,
OStringToOUString( decl->getRealService()->getRelativName(),
diff --git a/idlc/source/astenum.cxx b/idlc/source/astenum.cxx
index 13bd8774f651..a0df33199ec5 100644
--- a/idlc/source/astenum.cxx
+++ b/idlc/source/astenum.cxx
@@ -45,7 +45,7 @@ AstConstant* AstEnum::checkValue(AstExpression* pExpr)
while ( iter != end)
{
pDecl = *iter;
- pConst = (AstConstant*)pDecl;
+ pConst = static_cast<AstConstant*>(pDecl);
if (pConst->getConstValue()->compare(pExpr))
return pConst;
@@ -88,7 +88,7 @@ bool AstEnum::dump(RegistryKey& rKey)
{
pDecl = *iter;
if ( pDecl->getNodeType() == NT_enum_val )
- ((AstConstant*)pDecl)->dumpBlob(aBlob, index++, false);
+ static_cast<AstConstant*>(pDecl)->dumpBlob(aBlob, index++, false);
++iter;
}
diff --git a/idlc/source/astinterface.cxx b/idlc/source/astinterface.cxx
index 3fd0a7e1845a..7f097fd23555 100644
--- a/idlc/source/astinterface.cxx
+++ b/idlc/source/astinterface.cxx
@@ -140,7 +140,7 @@ bool AstInterface::dump(RegistryKey& rKey)
if (!increment(&nAttributes, "attributes")) {
return false;
}
- AstAttribute * attr = (AstAttribute *)(*i);
+ AstAttribute * attr = static_cast<AstAttribute *>(*i);
if (attr->isBound()) {
version = TYPEREG_VERSION_1;
}
@@ -227,13 +227,12 @@ bool AstInterface::dump(RegistryKey& rKey)
{
switch ((*i)->getNodeType()) {
case NT_attribute:
-
- ((AstAttribute *)(*i))->dumpBlob(
+ static_cast<AstAttribute *>(*i)->dumpBlob(
aBlob, attributeIndex++, &methodIndex);
break;
case NT_operation:
- ((AstOperation *)(*i))->dumpBlob(aBlob, methodIndex++);
+ static_cast<AstOperation *>(*i)->dumpBlob(aBlob, methodIndex++);
break;
default:
diff --git a/idlc/source/astoperation.cxx b/idlc/source/astoperation.cxx
index 55e52931dfbb..cae75fe0027e 100644
--- a/idlc/source/astoperation.cxx
+++ b/idlc/source/astoperation.cxx
@@ -70,7 +70,7 @@ bool AstOperation::dumpBlob(typereg::Writer & rBlob, sal_uInt16 index)
pDecl = *iter;
if ( pDecl->getNodeType() == NT_parameter )
{
- AstParameter* pParam = (AstParameter*)pDecl;
+ AstParameter* pParam = static_cast<AstParameter*>(pDecl);
switch (pParam->getDirection())
{
case DIR_IN :
diff --git a/idlc/source/astscope.cxx b/idlc/source/astscope.cxx
index cc0812664181..caa2dc3cb20d 100644
--- a/idlc/source/astscope.cxx
+++ b/idlc/source/astscope.cxx
@@ -60,7 +60,7 @@ AstDeclaration* AstScope::addDeclaration(AstDeclaration* pDecl)
}
if ( (pDeclaration->getNodeType() == NT_interface)
&& (pDecl->getNodeType() == NT_interface)
- && !((AstInterface*)pDeclaration)->isDefined() )
+ && !(static_cast<AstInterface*>(pDeclaration)->isDefined()) )
{
m_declarations.push_back(pDecl);
return pDecl;
@@ -214,7 +214,7 @@ AstDeclaration* AstScope::lookupByNameLocal(const OString& name) const
AstDeclaration* AstScope::lookupInInherited(const OString& scopedName) const
{
- AstInterface* pInterface = (AstInterface*)this;
+ const AstInterface* pInterface = dynamic_cast<const AstInterface*>(this);
if ( !pInterface )
return NULL;
@@ -313,7 +313,7 @@ AstDeclaration* AstScope::lookupPrimitiveType(ExprType type)
if ( pDecl && (pDecl->getNodeType() == NT_predefined) )
{
- AstBaseType* pBaseType = (AstBaseType*)pDecl;
+ AstBaseType* pBaseType = static_cast<AstBaseType*>(pDecl);
if ( pBaseType->getExprType() == type )
return pDecl;
diff --git a/idlc/source/aststruct.cxx b/idlc/source/aststruct.cxx
index abc4bfed843b..7c42d1692ad0 100644
--- a/idlc/source/aststruct.cxx
+++ b/idlc/source/aststruct.cxx
@@ -131,7 +131,7 @@ bool AstStruct::dump(RegistryKey& rKey)
pDecl = *iter;
if ( pDecl->getNodeType() == NT_member )
{
- pMember = (AstMember*)pDecl;
+ pMember = static_cast<AstMember*>(pDecl);
RTFieldAccess flags = RT_ACCESS_READWRITE;
OString typeName;
if (pMember->getType()->getNodeType() == NT_type_parameter) {
diff --git a/idlc/source/errorhandler.cxx b/idlc/source/errorhandler.cxx
index 6a99b669e72f..b7b6e799be3a 100644
--- a/idlc/source/errorhandler.cxx
+++ b/idlc/source/errorhandler.cxx
@@ -564,7 +564,7 @@ void ErrorHandler::inheritanceError(NodeType nodeType, const OString* name, AstD
{
if ( nodeType == NT_interface &&
(pDecl->getNodeType() == NT_interface) &&
- !((AstInterface*)pDecl)->isDefined() )
+ !(static_cast<AstInterface*>(pDecl)->isDefined()) )
{
errorHeader(EIDL_INHERIT_FWD_ERROR);
fprintf(stderr, "interface '%s' cannot inherit from forward declared interface '%s'\n",
@@ -579,7 +579,7 @@ void ErrorHandler::inheritanceError(NodeType nodeType, const OString* name, AstD
idlc()->incErrorCount();
}
-void ErrorHandler::forwardLookupError(AstDeclaration* pForward,
+void ErrorHandler::forwardLookupError(const AstDeclaration* pForward,
const OString& name)
{
errorHeader(EIDL_FWD_DECL_LOOKUP);
diff --git a/idlc/source/fehelper.cxx b/idlc/source/fehelper.cxx
index 12636e1ef6a6..a11f4b053992 100644
--- a/idlc/source/fehelper.cxx
+++ b/idlc/source/fehelper.cxx
@@ -49,7 +49,7 @@ bool FeDeclarator::checkType(AstDeclaration const * type)
AstType const * FeDeclarator::compose(AstDeclaration const * pDecl)
{
- AstType* pType;
+ const AstType* pType;
if ( pDecl == 0 )
{
@@ -60,7 +60,7 @@ AstType const * FeDeclarator::compose(AstDeclaration const * pDecl)
idlc()->error()->noTypeError(pDecl);
return NULL;
}
- pType = (AstType*)pDecl;
+ pType = static_cast<const AstType*>(pDecl);
if (m_declType == FD_simple || m_pComplexPart == NULL)
return pType;
diff --git a/idlc/source/idlc.cxx b/idlc/source/idlc.cxx
index bf7594eee467..2617c22c237c 100644
--- a/idlc/source/idlc.cxx
+++ b/idlc/source/idlc.cxx
@@ -48,22 +48,22 @@ AstDeclaration* SAL_CALL scopeAsDecl(AstScope* pScope)
{
case NT_service:
case NT_singleton:
- return (AstService*)(pScope);
+ return static_cast<AstService*>(pScope);
case NT_module:
case NT_root:
- return (AstModule*)(pScope);
+ return static_cast<AstModule*>(pScope);
case NT_constants:
- return (AstConstants*)(pScope);
+ return static_cast<AstConstants*>(pScope);
case NT_interface:
- return (AstInterface*)(pScope);
+ return static_cast<AstInterface*>(pScope);
case NT_operation:
- return (AstOperation*)(pScope);
+ return static_cast<AstOperation*>(pScope);
case NT_exception:
- return (AstException*)(pScope);
+ return static_cast<AstException*>(pScope);
case NT_struct:
- return (AstStruct*)(pScope);
+ return static_cast<AstStruct*>(pScope);
case NT_enum:
- return (AstEnum*)(pScope);
+ return static_cast<AstEnum*>(pScope);
default:
return NULL;
}
@@ -76,23 +76,23 @@ AstScope* SAL_CALL declAsScope(AstDeclaration* pDecl)
switch(pDecl->getNodeType())
{
case NT_interface:
- return (AstInterface*)(pDecl);
+ return static_cast<AstInterface*>(pDecl);
case NT_service:
case NT_singleton:
- return (AstService*)(pDecl);
+ return static_cast<AstService*>(pDecl);
case NT_module:
case NT_root:
- return (AstModule*)(pDecl);
+ return static_cast<AstModule*>(pDecl);
case NT_constants:
- return (AstConstants*)(pDecl);
+ return static_cast<AstConstants*>(pDecl);
case NT_exception:
- return (AstException*)(pDecl);
+ return static_cast<AstException*>(pDecl);
case NT_struct:
- return (AstStruct*)(pDecl);
+ return static_cast<AstStruct*>(pDecl);
case NT_enum:
- return (AstEnum*)(pDecl);
+ return static_cast<AstEnum*>(pDecl);
case NT_operation:
- return (AstOperation*)(pDecl);
+ return static_cast<AstOperation*>(pDecl);
default:
return NULL;
}
@@ -127,21 +127,21 @@ static void SAL_CALL predefineXInterface(AstModule* pRoot)
pParentScope->addDeclaration(pInterface);
// define XInterface::queryInterface
- AstOperation* pOp = new AstOperation((AstType*)(pRoot->lookupPrimitiveType(ET_any)),
+ AstOperation* pOp = new AstOperation(static_cast<AstType*>(pRoot->lookupPrimitiveType(ET_any)),
OString("queryInterface"), pInterface);
AstParameter* pParam = new AstParameter(DIR_IN, false,
- (AstType*)(pRoot->lookupPrimitiveType(ET_type)),
+ static_cast<AstType*>(pRoot->lookupPrimitiveType(ET_type)),
OString("aType"), pOp);
pOp->addDeclaration(pParam);
pInterface->addMember(pOp);
// define XInterface::acquire
- pOp = new AstOperation((AstType*)(pRoot->lookupPrimitiveType(ET_void)),
+ pOp = new AstOperation(static_cast<AstType*>(pRoot->lookupPrimitiveType(ET_void)),
OString("acquire"), pInterface);
pInterface->addMember(pOp);
// define XInterface::release
- pOp = new AstOperation((AstType*)(pRoot->lookupPrimitiveType(ET_void)),
+ pOp = new AstOperation(static_cast<AstType*>(pRoot->lookupPrimitiveType(ET_void)),
OString("release"), pInterface);
pInterface->addMember(pOp);
}