Kaydet (Commit) ad278c2b authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:unusedfields in basctl

and improve the plugin to search for only WARN_UNUSED and fundamental
types

Change-Id: Ic06207758e28d44d64d76d8119fd76b5b098bb05
üst 6f5c6cf4
...@@ -418,7 +418,7 @@ void LanguageBox::FillBox() ...@@ -418,7 +418,7 @@ void LanguageBox::FillBox()
sLanguage += m_sDefaultLanguageStr; sLanguage += m_sDefaultLanguageStr;
} }
sal_Int32 nPos = InsertEntry( sLanguage ); sal_Int32 nPos = InsertEntry( sLanguage );
SetEntryData( nPos, new LanguageEntry( sLanguage, pLocale[i], bIsDefault ) ); SetEntryData( nPos, new LanguageEntry( pLocale[i], bIsDefault ) );
if ( bIsCurrent ) if ( bIsCurrent )
nSelPos = nPos; nSelPos = nPos;
......
...@@ -732,7 +732,7 @@ void LibInfos::InsertInfo ( ...@@ -732,7 +732,7 @@ void LibInfos::InsertInfo (
{ {
Key aKey(rDocument, rLibName); Key aKey(rDocument, rLibName);
m_aMap.erase(aKey); m_aMap.erase(aKey);
m_aMap.insert(Map::value_type(aKey, Item(rDocument, rLibName, rCurrentName, eCurrentType))); m_aMap.insert(Map::value_type(aKey, Item(rDocument, rCurrentName, eCurrentType)));
} }
void LibInfos::RemoveInfoFor (ScriptDocument const& rDocument) void LibInfos::RemoveInfoFor (ScriptDocument const& rDocument)
...@@ -772,12 +772,10 @@ size_t LibInfos::Key::Hash::operator () (Key const& rKey) const ...@@ -772,12 +772,10 @@ size_t LibInfos::Key::Hash::operator () (Key const& rKey) const
LibInfos::Item::Item ( LibInfos::Item::Item (
ScriptDocument const& rDocument, ScriptDocument const& rDocument,
OUString const& rLibName,
OUString const& rCurrentName, OUString const& rCurrentName,
ItemType eCurrentType ItemType eCurrentType
) : ) :
m_aDocument(rDocument), m_aDocument(rDocument),
m_aLibName(rLibName),
m_aCurrentName(rCurrentName), m_aCurrentName(rCurrentName),
m_eCurrentType(eCurrentType) m_eCurrentType(eCurrentType)
{ } { }
......
...@@ -126,7 +126,7 @@ void ManageLanguageDialog::FillLanguageBox() ...@@ -126,7 +126,7 @@ void ManageLanguageDialog::FillLanguageBox()
sLanguage += " " + m_sDefLangStr; sLanguage += " " + m_sDefLangStr;
} }
const sal_Int32 nPos = m_pLanguageLB->InsertEntry( sLanguage ); const sal_Int32 nPos = m_pLanguageLB->InsertEntry( sLanguage );
m_pLanguageLB->SetEntryData( nPos, new LanguageEntry( sLanguage, pLocale[i], bIsDefault ) ); m_pLanguageLB->SetEntryData( nPos, new LanguageEntry( pLocale[i], bIsDefault ) );
} }
} }
else else
......
...@@ -273,12 +273,11 @@ public: ...@@ -273,12 +273,11 @@ public:
{ {
private: private:
ScriptDocument m_aDocument; ScriptDocument m_aDocument;
OUString m_aLibName;
OUString m_aCurrentName; OUString m_aCurrentName;
ItemType m_eCurrentType; ItemType m_eCurrentType;
public: public:
Item (ScriptDocument const&, OUString const& rLibName, OUString const& rCurrentName, ItemType eCurrentType); Item (ScriptDocument const&, OUString const& rCurrentName, ItemType eCurrentType);
~Item (); ~Item ();
const OUString& GetCurrentName() const { return m_aCurrentName; } const OUString& GetCurrentName() const { return m_aCurrentName; }
ItemType GetCurrentType() const { return m_eCurrentType; } ItemType GetCurrentType() const { return m_eCurrentType; }
......
...@@ -34,14 +34,11 @@ class LocalizationMgr; ...@@ -34,14 +34,11 @@ class LocalizationMgr;
struct LanguageEntry struct LanguageEntry
{ {
OUString m_sLanguage;
css::lang::Locale m_aLocale; css::lang::Locale m_aLocale;
bool m_bIsDefault; bool m_bIsDefault;
LanguageEntry( const OUString& _rLanguage, LanguageEntry( const css::lang::Locale& _rLocale,
const css::lang::Locale& _rLocale,
bool _bIsDefault ) : bool _bIsDefault ) :
m_sLanguage( _rLanguage ),
m_aLocale( _rLocale ), m_aLocale( _rLocale ),
m_bIsDefault( _bIsDefault ) {} m_bIsDefault( _bIsDefault ) {}
}; };
......
...@@ -170,8 +170,49 @@ bool UnusedFields::VisitFieldDecl( const FieldDecl* fieldDecl ) ...@@ -170,8 +170,49 @@ bool UnusedFields::VisitFieldDecl( const FieldDecl* fieldDecl )
{ {
fieldDecl = fieldDecl->getCanonicalDecl(); fieldDecl = fieldDecl->getCanonicalDecl();
if( !ignoreLocation( fieldDecl )) if( ignoreLocation( fieldDecl ))
definitionSet.insert(niceName(fieldDecl)); return true;
QualType type = fieldDecl->getType();
// unwrap array types
while (type->isArrayType())
type = type->getAsArrayTypeUnsafe()->getElementType();
if( CXXRecordDecl* recordDecl = type->getAsCXXRecordDecl() )
{
bool warn_unused = false;
if( recordDecl->hasAttrs())
{
// Clang currently has no support for custom attributes, but
// the annotate attribute comes close, so check for __attribute__((annotate("lo_warn_unused")))
for( specific_attr_iterator<AnnotateAttr> i = recordDecl->specific_attr_begin<AnnotateAttr>(),
e = recordDecl->specific_attr_end<AnnotateAttr>();
i != e;
++i )
{
if( (*i)->getAnnotation() == "lo_warn_unused" )
{
warn_unused = true;
break;
}
}
}
if( !warn_unused )
{
string n = recordDecl->getQualifiedNameAsString();
if( n == "rtl::OUString" )
warn_unused = true;
// Check some common non-LO types.
if( n == "std::string" || n == "std::basic_string"
|| n == "std::list" || n == "std::__debug::list"
|| n == "std::vector" || n == "std::__debug::vector" )
warn_unused = true;
}
if (!warn_unused)
return true;
}
definitionSet.insert(niceName(fieldDecl));
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment