loplugin:unreffun: also warn about redundant redeclarations

Change-Id: I9a812220b58cf6da00d854e65794f7c673ab239d
This commit is contained in:
Stephan Bergmann 2014-06-27 15:25:46 +02:00
parent b05b970daa
commit e48a233960
31 changed files with 38 additions and 131 deletions

View File

@ -51,8 +51,6 @@ class TabBar;
class BaseWindow;
class LocalizationMgr;
bool RemoveDialog( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rDlgName );
class Shell :
public SfxViewShell,
public DocumentEventListener

View File

@ -226,7 +226,6 @@ extern RTLFUNC(Timer);
extern RTLFUNC(Weekday);
extern RTLFUNC(WeekdayName);
extern RTLFUNC(Year);
extern RTLFUNC(Date);
extern RTLFUNC(InputBox);
extern RTLFUNC(Me);
extern RTLFUNC(MsgBox);

View File

@ -84,8 +84,6 @@ using namespace com::sun::star::uno;
#include <ctype.h>
#include <errno.h>
SbxVariable* getDefaultProp( SbxVariable* pRef );
#include "sbobjmod.hxx"
#ifdef WNT

View File

@ -384,8 +384,6 @@ typelib_TypeClass cpp_vtable_call(
return eRet;
}
extern "C" void privateSnippetExecutor();
const int codeSnippetSize = 24;
// Generate a trampoline that redirects method calls to

View File

@ -45,6 +45,19 @@ bool hasCLanguageLinkageType(FunctionDecl const * decl) {
return false;
}
bool isFriendDecl(Decl const * decl) {
return decl->getFriendObjectKind() != Decl::FOK_None;
}
Decl const * getPreviousNonFriendDecl(Decl const * decl) {
for (;;) {
decl = decl->getPreviousDecl();
if (decl == nullptr || !isFriendDecl(decl)) {
return decl;
}
}
}
class UnrefFun: public RecursiveASTVisitor<UnrefFun>, public loplugin::Plugin {
public:
explicit UnrefFun(InstantiationData const & data): Plugin(data) {}
@ -69,6 +82,26 @@ bool UnrefFun::VisitFunctionDecl(FunctionDecl const * decl) {
return true;
}
if (!(decl->isThisDeclarationADefinition() || isFriendDecl(decl)
|| decl->isFunctionTemplateSpecialization()))
{
Decl const * prev = getPreviousNonFriendDecl(decl);
if (prev != nullptr/* && prev != decl->getPrimaryTemplate()*/) {
report(
DiagnosticsEngine::Warning,
"redundant function%0 redeclaration", decl->getLocation())
<< ((decl->getTemplatedKind()
== FunctionDecl::TK_FunctionTemplate)
? " template" : "")
<< decl->getSourceRange();
report(
DiagnosticsEngine::Note, "previous declaration is here",
prev->getLocation())
<< prev->getSourceRange();
return true;
}
}
FunctionDecl const * canon = decl->getCanonicalDecl();
//TODO: is that the first?
if (canon->isDeleted() || canon->isReferenced()

View File

@ -25,7 +25,6 @@
namespace connectivity
{
bool LoadLibrary_ODBC3(OUString &_rPath);
// extern declaration of the function pointer
extern T3SQLAllocHandle pODBC3SQLAllocHandle;
extern T3SQLConnect pODBC3SQLConnect;

View File

@ -988,14 +988,6 @@ int token_debug(const char *format, ...);
* section 1.
*/
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int yywrap YY_PROTO(( void ));
#else
extern int yywrap YY_PROTO(( void ));
#endif
#endif
#ifndef YY_NO_UNPUT
//static void yyunput YY_PROTO(( int c, char *buf_ptr ));
#endif

View File

@ -162,29 +162,6 @@ namespace canvas
::com::sun::star::uno::XInterface >& xIf,
::sal_Int16 nArgPos );
/** Verify that the given point contains valid floating point
values.
@param rPoint
Point to check
@param xIf
The interface that should be reported as the one
generating the exception.
@param nArgPos
Argument position on the call site (i.e. the position of
the argument, checked here, on the UNO interface
method. Counting starts at 0).
@throws an lang::IllegalArgumentException, if anything is wrong
*/
CANVASTOOLS_DLLPUBLIC void verifyInput( const ::com::sun::star::geometry::RealPoint2D& rPoint,
const char* pStr,
const ::com::sun::star::uno::Reference<
::com::sun::star::uno::XInterface >& xIf,
::sal_Int16 nArgPos );
/** Verify that the given rectangle contains valid floating
point values.

View File

@ -28,10 +28,6 @@
#include <string.h>
#ifndef _NO_PROTO
int AddInclude( char *pIncStr ); /* BP, 11.09.91, Forward-Deklaration */
#endif
#if (OSL_DEBUG_LEVEL > 1) && (HOST == SYS_VMS || HOST == SYS_UNIX)
#include <signal.h>
#endif
@ -75,7 +71,6 @@ void addfile(FILE* fp, char* filename)
*/
{
FILEINFO *file;
extern FILEINFO *getfile( int, char * );
file = getfile(NBUFF, filename);
file->fp = fp; /* Better remember FILE * */
file->buffer[0] = EOS; /* Initialize for first read */
@ -440,10 +435,6 @@ void initdefines()
int i;
time_t tvec;
#if !defined( WNT ) && !defined(G3)
extern char *ctime(time_t const *);
#endif
/*
* Predefine the built-in symbols. Allow the
* implementor to pre-define a symbol as "" to

View File

@ -397,7 +397,6 @@ void expand(DEFBUF* tokenp)
{
int c;
FILEINFO *file;
extern FILEINFO *getfile(int, char *);
#if OSL_DEBUG_LEVEL > 1
if (debug)
@ -553,7 +552,6 @@ void expstuff(DEFBUF* tokenp)
char *defend; /* -> output buff end */
int string_magic; /* String formal hack */
FILEINFO *file; /* Funny #include */
extern FILEINFO *getfile(int, char *);
file = getfile(NBUFF, tokenp->name);
inp = tokenp->repl; /* -> macro replacement */

View File

@ -218,7 +218,6 @@ eval()
int skip; /* For short-circuit testing */
int value[NEXP]; /* Value stack */
OPTAB opstack[NEXP]; /* Operand stack */
extern int *evaleval(int *, int, int); /* Does actual evaluation */
valp = value;
opp = opstack;
opp->op = OP_END; /* Mark bottom of stack */

View File

@ -1021,7 +1021,6 @@ void ungetstring(char* text)
*/
{
FILEINFO *file;
extern FILEINFO *getfile(int, char *);
file = getfile(strlen(text) + 1, "");
strcpy(file->buffer, text);
}

View File

@ -85,7 +85,6 @@ using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::drawing::XShape;
extern OUString getPageApiNameFromUiName( const OUString& rUIName );
extern OUString getUiNameFromPageApiNameImpl( const OUString& rApiName );
typedef std::map<sal_uIntPtr, SfxExtItemPropertySetInfo*> SdExtPropertySetInfoCache;

View File

@ -19,6 +19,7 @@
#include "filterdet.hxx"
#include "inc/pdfihelper.hxx"
#include "inc/pdfparse.hxx"
#include <osl/diagnose.h>

View File

@ -94,12 +94,6 @@ bool checkDocChecksum( const OUString& rInPDFFileURL,
sal_uInt32 nBytes,
const OUString& rChkSum );
bool getPassword( const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
OUString& o_rPwd,
bool bFirstTry,
const OUString& i_rDocName
);
}
#endif

View File

@ -32,10 +32,6 @@ static inline sal_uInt16 Count_Impl(const sal_uInt16 * pRanges)
TYPEINIT1_AUTOFACTORY(SfxRangeItem, SfxPoolItem);
TYPEINIT1_AUTOFACTORY(SfxUShortRangesItem, SfxPoolItem);
sal_uInt16 Count_Impl( const sal_uInt16 *pRanges );
SfxRangeItem::SfxRangeItem()
{
nFrom = 0;

View File

@ -302,7 +302,6 @@ public:
};
bool CheckNodesRange( const SwNodeIndex&, const SwNodeIndex&, bool bChkSection );
bool GoInCntnt( SwPaM & rPam, SwMoveFn fnMove );
#endif // INCLUDED_SW_INC_PAM_HXX

View File

@ -559,7 +559,6 @@ void GetRTFWriter( const OUString&, const OUString&, WriterRef& );
void GetASCWriter( const OUString&, const OUString&, WriterRef& );
void GetHTMLWriter( const OUString&, const OUString&, WriterRef& );
void GetXMLWriter( const OUString&, const OUString&, WriterRef& );
void GetWW8Writer( const OUString&, const OUString&, WriterRef& );
#endif

View File

@ -132,8 +132,6 @@
using namespace ::com::sun::star;
extern void _FrmFinit();
// some ranges for sets in collections/ nodes
// AttrSet range for the 2 break attributes

View File

@ -159,8 +159,6 @@ typedef bool (*FN_lcl_SetBoxWidth)(SwTableLine*, CR_SetBoxWidth&, SwTwips, bool
#ifdef DBG_UTIL
void _CheckBoxWidth( const SwTableLine& rLine, SwTwips nSize );
#define CHECKBOXWIDTH \
{ \
SwTwips nSize = GetFrmFmt()->GetFrmSize().GetWidth(); \

View File

@ -49,6 +49,7 @@
#include <tabcol.hxx>
#include <cellatr.hxx>
#include <pam.hxx>
#include <pamtyp.hxx>
#include <viscrs.hxx>
#include <tblsel.hxx>
#include <swtblfmt.hxx>

View File

@ -20,6 +20,8 @@
#ifndef INCLUDED_SW_SOURCE_CORE_INC_FLOWFRM_HXX
#define INCLUDED_SW_SOURCE_CORE_INC_FLOWFRM_HXX
#include "frmtool.hxx"
class SwPageFrm;
class SwRect;
class SwBorderAttrs;
@ -28,8 +30,6 @@ class SwNodeIndex;
// #i44049#
class SwObjectFormatterTxtFrm;
void MakeFrms( SwDoc *, const SwNodeIndex &, const SwNodeIndex & );
/** Base class that provides the general functionalities for frames that are
allowed at page breaks (flow) and shall continue on the next page (can be
split), e.g. paragraphs (CntntFrm) or tables (TabFrm).

View File

@ -110,10 +110,6 @@ css::uno::Sequence< OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames()
OUString SAL_CALL SwXMailMerge_getImplementationName() throw();
css::uno::Reference< css::uno::XInterface > SAL_CALL SwXMailMerge_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory > & rSMgr) throw( css::uno::Exception );
css::uno::Sequence< OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames() throw();
OUString SAL_CALL SwXMailMerge_getImplementationName() throw();
css::uno::Reference< css::uno::XInterface > SAL_CALL SwXMailMerge_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory > & rSMgr) throw( css::uno::Exception );
// Layout dump filter
css::uno::Sequence< OUString > SAL_CALL LayoutDumpFilter_getSupportedServiceNames() throw();
OUString SAL_CALL LayoutDumpFilter_getImplementationName() throw();

View File

@ -1003,8 +1003,6 @@ void SwTable::SetTabCols( const SwTabCols &rNew, const SwTabCols &rOld,
#ifdef DBG_UTIL
{
// to be found in tblrwcl.cxx
extern void _CheckBoxWidth( const SwTableLine&, SwTwips );
// do some checking for correct table widths
SwTwips nSize = GetFrmFmt()->GetFrmSize().GetWidth();
for (size_t n = 0; n < aLines.size(); ++n)

View File

@ -27,6 +27,7 @@
#include <docary.hxx>
#include <swundo.hxx>
#include <pam.hxx>
#include <pamtyp.hxx>
#include <ndtxt.hxx>
#include <UndoCore.hxx>
#include <rolbck.hxx>

View File

@ -47,9 +47,6 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
using namespace ::rtl;
//impl in envimg.cxx
extern SW_DLLPUBLIC OUString MakeSender();
SwEnvPreview::SwEnvPreview(Window* pParent, WinBits nStyle)
: Window(pParent, nStyle)
{

View File

@ -66,8 +66,6 @@
#include <svx/dialogs.hrc>
#include <svx/flagsdef.hxx>
extern SW_DLLPUBLIC SwWrtShell* GetActiveWrtShell();
// the dialog's carrier
SwTemplateDlg::SwTemplateDlg(Window* pParent,
SfxStyleSheetBase& rBase,

View File

@ -54,21 +54,6 @@ protected:
virtual void _ExportContent() SAL_OVERRIDE;
};
// global functions to support the component
::com::sun::star::uno::Sequence< OUString > SAL_CALL
XMLMetaExportComponent_getSupportedServiceNames()
throw();
OUString SAL_CALL XMLMetaExportComponent_getImplementationName()
throw();
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
XMLMetaExportComponent_createInstance(
const ::com::sun::star::uno::Reference<
::com::sun::star::lang::XMultiServiceFactory > & )
throw( ::com::sun::star::uno::Exception );
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -97,36 +97,6 @@ protected:
virtual void _ExportContent() SAL_OVERRIDE;
};
// global functions to support the component
::com::sun::star::uno::Sequence< OUString > SAL_CALL
XMLAutoTextEventExport_getSupportedServiceNames()
throw();
OUString SAL_CALL XMLAutoTextEventExport_getImplementationName()
throw();
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
XMLAutoTextEventExportOOO_createInstance(
const ::com::sun::star::uno::Reference<
::com::sun::star::lang::XMultiServiceFactory > & )
throw( ::com::sun::star::uno::Exception );
::com::sun::star::uno::Sequence< OUString > SAL_CALL
XMLAutoTextEventExportOOO_getSupportedServiceNames()
throw();
OUString SAL_CALL XMLAutoTextEventExportOOO_getImplementationName()
throw();
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
XMLAutoTextEventExportOOO_createInstance(
const ::com::sun::star::uno::Reference<
::com::sun::star::lang::XMultiServiceFactory > & )
throw( ::com::sun::star::uno::Exception );
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -47,8 +47,6 @@ using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::xml::sax;
using namespace ::com::sun::star::beans;
OUString SAL_CALL OOo2OasisTransformer_getImplementationName() throw();
enum XMLUserDefinedTransformerAction
{
XML_ETACTION_DOCUMENT=XML_ETACTION_USER_DEFINED,

View File

@ -52,8 +52,6 @@ using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::xml::sax;
using namespace ::com::sun::star::beans;
OUString SAL_CALL Oasis2OOoTransformer_getImplementationName() throw();
enum XMLUserDefinedTransformerAction
{
XML_ETACTION_META=XML_ETACTION_USER_DEFINED,