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

loplugin:staticvar in various

looks for variables that can be declared const and static i.e. they can
be stored in the read-only linker segment and shared between different
processes

Change-Id: I8ddc6e5fa0f6b10d80c75d5952df8ddd311cf892
Reviewed-on: https://gerrit.libreoffice.org/61591
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 78490b45
......@@ -76,7 +76,10 @@ public:
// aHTMLOptionTab is ordered by useful grouping, so let it sort at runtime
|| fn == SRCDIR "/svtools/source/svhtml/htmlkywd.cxx"
// TODO sorting some of these tables will be a lot of work...
|| fn == SRCDIR "/sw/source/filter/ww8/ww8par6.cxx")
|| fn == SRCDIR "/sw/source/filter/ww8/ww8par6.cxx"
// this only triggers on older versions of clang, not sure why
// in any case, it is actually about the array in vcl/inc/units.hrc, which we can't change
|| fn == SRCDIR "/vcl/source/app/svdata.cxx")
return;
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
}
......@@ -198,7 +201,7 @@ bool StaticVar::VisitVarDecl(VarDecl const* varDecl)
return true;
}
loplugin::Plugin::Registration<StaticVar> X("staticvar", false);
loplugin::Plugin::Registration<StaticVar> X("staticvar", true);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -74,7 +74,7 @@ InputSequenceCheckerImpl::correctInputSequence(OUString& Text, sal_Int32 nStartP
return nStartPos;
}
static ScriptTypeList typeList[] = {
static ScriptTypeList const typeList[] = {
//{ UnicodeScript_kHebrew, UnicodeScript_kHebrew }, // 10,
//{ UnicodeScript_kArabic, UnicodeScript_kArabic }, // 11,
{ UnicodeScript_kDevanagari, UnicodeScript_kDevanagari, sal_Int16(UnicodeScript_kDevanagari) }, // 14,
......
......@@ -54,7 +54,7 @@ static struct TMlist {
TransliterationModules tm;
TransliterationModulesNew tmn;
const sal_Char *implName;
} TMlist[] = { // Modules ModulesNew
} const TMlist[] = { // Modules ModulesNew
TmItem1 (IGNORE_CASE), // 0. (1<<8 256) (7)
TmItem1 (IGNORE_WIDTH), // 1. (1<<9 512) (8)
TmItem1 (IGNORE_KANA), // 2. (1<<10 1024) (9)
......
......@@ -35,10 +35,10 @@ struct VendorSupportMapEntry
createInstance_func createFunc;
};
extern VendorSupportMapEntry gVendorMap[];
extern VendorSupportMapEntry const gVendorMap[];
#define BEGIN_VENDOR_MAP() \
VendorSupportMapEntry gVendorMap[] ={
VendorSupportMapEntry const gVendorMap[] ={
#define VENDOR_MAP_ENTRY(x,y) \
{x, & y::getJavaExePaths, & y::createInstance},
......
......@@ -481,7 +481,7 @@ namespace basprov
}
static struct ::cppu::ImplementationEntry s_component_entries [] =
static struct ::cppu::ImplementationEntry const s_component_entries [] =
{
{
create_BasicProviderImpl, getImplementationName_BasicProviderImpl,
......
......@@ -736,7 +736,7 @@ namespace dlgprov
}
static struct ::cppu::ImplementationEntry s_component_entries [] =
static struct ::cppu::ImplementationEntry const s_component_entries [] =
{
{create_DialogProviderImpl, getImplementationName_DialogProviderImpl,getSupportedServiceNames_DialogProviderImpl, ::cppu::createSingleComponentFactory,nullptr, 0},
{ &comp_DialogModelProvider::_create,&comp_DialogModelProvider::_getImplementationName,&comp_DialogModelProvider::_getSupportedServiceNames,&::cppu::createSingleComponentFactory, nullptr, 0 },
......
......@@ -439,7 +439,7 @@ css::uno::Sequence< OUString > getSupportedServiceNames2() {
return s;
}
::cppu::ImplementationEntry entries[] = {
::cppu::ImplementationEntry const entries[] = {
{ &create, &getImplementationName, &getSupportedServiceNames,
&::cppu::createSingleComponentFactory, nullptr, 0 },
{ &create2, &getImplementationName2, &getSupportedServiceNames2,
......
......@@ -360,10 +360,10 @@ namespace
{
static struct _unit_table
{
FieldUnit const eFieldUnit;
sal_Int16 const nMeasurementUnit;
sal_Int16 const nFieldToMeasureFactor;
} aUnits[] = {
FieldUnit eFieldUnit;
sal_Int16 nMeasurementUnit;
sal_Int16 nFieldToMeasureFactor;
} const aUnits[] = {
{ FUNIT_NONE, -1 , -1},
{ FUNIT_MM, MeasureUnit::MM, 1 }, // must precede MM_10TH
{ FUNIT_MM, MeasureUnit::MM_10TH, 10 },
......
......@@ -179,7 +179,7 @@ public:
static ErrCode GetSvError( int nErrno )
{
static struct { int nErr; ErrCode sv; } errArr[] =
static struct { int nErr; ErrCode sv; } const errArr[] =
{
{ 0, ERRCODE_NONE },
{ EACCES, SVSTREAM_ACCESS_DENIED },
......@@ -231,7 +231,7 @@ static ErrCode GetSvError( int nErrno )
static ErrCode GetSvError( oslFileError nErrno )
{
static struct { oslFileError nErr; ErrCode sv; } errArr[] =
static struct { oslFileError nErr; ErrCode sv; } const errArr[] =
{
{ osl_File_E_None, ERRCODE_NONE },
{ osl_File_E_ACCES, SVSTREAM_ACCESS_DENIED },
......
......@@ -30,7 +30,7 @@ namespace ucb { namespace ucp { namespace ext
//= descriptors for the services implemented in this component
static struct ::cppu::ImplementationEntry s_aServiceEntries[] =
static struct ::cppu::ImplementationEntry const s_aServiceEntries[] =
{
{
ContentProvider::Create,
......
......@@ -213,7 +213,7 @@ static struct NamesToHdl
const char *pFullPropName; // full qualified name as used in configuration
const char *pPropName; // property name only (atom) of above
sal_Int32 const nHdl; // numeric handle representing the property
}aNamesToHdl[] =
} const aNamesToHdl[] =
{
{/* 0 */ "General/DefaultLocale", UPN_DEFAULT_LOCALE, UPH_DEFAULT_LOCALE},
{/* 1 */ "General/DictionaryList/ActiveDictionaries", UPN_ACTIVE_DICTIONARIES, UPH_ACTIVE_DICTIONARIES},
......@@ -281,7 +281,7 @@ bool SvtLinguConfigItem::GetHdlByName(
const OUString &rPropertyName,
bool bFullPropName )
{
NamesToHdl *pEntry = &aNamesToHdl[0];
NamesToHdl const *pEntry = &aNamesToHdl[0];
if (bFullPropName)
{
......
......@@ -1135,7 +1135,7 @@ StarSymbolToMSMultiFontImpl::StarSymbolToMSMultiFontImpl()
};
//In order of preference
const ConvertTable aConservativeTable[] =
static const ConvertTable aConservativeTable[] =
{
{Symbol, aAdobeSymbolTab},
{Wingdings, aWingDingsTab},
......@@ -1173,7 +1173,7 @@ StarSymbolToMSMultiFontImpl::StarSymbolToMSMultiFontImpl()
}
//In order of preference
const ExtendedConvertTable aAgressiveTable[] =
static const ExtendedConvertTable aAgressiveTable[] =
{
ExtendedConvertTable(Symbol, aSymbolExtraTab2,
sizeof(aSymbolExtraTab2)),
......
......@@ -15,7 +15,7 @@ namespace writerfilter
namespace rtftok
{
// See RTF spec v1.9.1, page 19
RTFEncoding aRTFEncodings[] = {
RTFEncoding const aRTFEncodings[] = {
// charset codepage Windows / Mac name
{ 0, 1252 }, // ANSI
{ 1, 0 }, // Default
......
......@@ -20,7 +20,7 @@ struct RTFEncoding
int const charset;
int const codepage;
};
extern RTFEncoding aRTFEncodings[];
extern RTFEncoding const aRTFEncodings[];
extern int nRTFEncodings;
} // namespace rtftok
} // namespace writerfilter
......
......@@ -15,7 +15,7 @@ namespace writerfilter
{
namespace rtftok
{
RTFSymbol aRTFControlWords[] = {
RTFSymbol const aRTFControlWords[] = {
// sKeyword nControlType nIndex
{ "'", CONTROL_SYMBOL, RTF_HEXCHAR, 0 },
{ "-", CONTROL_SYMBOL, RTF_OPTHYPH, 0 },
......@@ -1848,7 +1848,7 @@ bool RTFSymbol::operator<(const RTFSymbol& rOther) const
return std::strcmp(sKeyword, rOther.sKeyword) < 0;
}
RTFMathSymbol aRTFMathControlWords[] = {
RTFMathSymbol const aRTFMathControlWords[] = {
// eKeyword nToken eDestination
{ RTF_MOMATH, M_TOKEN(oMath), Destination::MOMATH },
{ RTF_MF, M_TOKEN(f), Destination::MF },
......
......@@ -2001,7 +2001,7 @@ struct RTFSymbol
bool operator<(const RTFSymbol& rOther) const;
};
extern RTFSymbol aRTFControlWords[];
extern RTFSymbol const aRTFControlWords[];
extern int nRTFControlWords;
/// Represents an RTF Math Control Word
......@@ -2013,7 +2013,7 @@ struct RTFMathSymbol
bool operator<(const RTFMathSymbol& rOther) const;
};
extern RTFMathSymbol aRTFMathControlWords[];
extern RTFMathSymbol const aRTFMathControlWords[];
extern int nRTFMathControlWords;
} // namespace rtftok
......
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