loplugin: add Dialog to unusedvariablecheck

so that we find dialog that have been instantiated but not actually
executed

Change-Id: Ia308e832780627c0a8de71a9d64dabcb3b861a9c
This commit is contained in:
Noel Grandin
2015-03-17 11:14:36 +02:00
parent bca6b66358
commit 5229726b4d
2 changed files with 29 additions and 2 deletions

View File

@@ -48,6 +48,30 @@ void UnusedVariableCheck::run()
TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
}
bool BaseCheckNotDialogSubclass(const CXXRecordDecl *BaseDefinition, void *) {
if (BaseDefinition && BaseDefinition->getQualifiedNameAsString().compare("Dialog") == 0) {
return false;
}
return true;
}
bool isDerivedFromDialog(const CXXRecordDecl *decl) {
if (!decl)
return false;
if (decl->getQualifiedNameAsString() == "Dialog")
return true;
if (!decl->hasDefinition()) {
return false;
}
if (// not sure what hasAnyDependentBases() does,
// but it avoids classes we don't want, e.g. WeakAggComponentImplHelper1
!decl->hasAnyDependentBases() &&
!decl->forallBases(BaseCheckNotDialogSubclass, nullptr, true)) {
return true;
}
return false;
}
bool UnusedVariableCheck::VisitVarDecl( const VarDecl* var )
{
if( ignoreLocation( var ))
@@ -83,6 +107,9 @@ bool UnusedVariableCheck::VisitVarDecl( const VarDecl* var )
|| n == "std::list" || n == "std::__debug::list"
|| n == "std::vector" || n == "std::__debug::vector" )
warn_unused = true;
// check if this field is derived from Dialog
if (!warn_unused && isDerivedFromDialog(type))
warn_unused = true;
}
if( warn_unused )
{

View File

@@ -933,7 +933,7 @@ void SfxTemplateManagerDlg::OnTemplateImport ()
{
OUString aMsg(SfxResId(STR_MSG_ERROR_IMPORT).toString());
aMsg = aMsg.replaceFirst("$1",pFolder->maTitle);
MessageDialog(this, aMsg.replaceFirst("$2",aTemplateList));
MessageDialog(this, aMsg.replaceFirst("$2",aTemplateList)).Execute();
}
}
}
@@ -956,7 +956,7 @@ void SfxTemplateManagerDlg::OnTemplateImport ()
{
OUString aMsg(SfxResId(STR_MSG_ERROR_IMPORT).toString());
aMsg = aMsg.replaceFirst("$1",mpLocalView->getCurRegionName());
MessageDialog(this, aMsg.replaceFirst("$2",aTemplateList));
MessageDialog(this, aMsg.replaceFirst("$2",aTemplateList)).Execute();
}
}