loplugin:salbool: sal_Bool[] -> bool[]

Change-Id: I3c5bf7a53c9ae173f8fce885ecf022f092aa43a9
This commit is contained in:
Stephan Bergmann
2016-04-21 17:29:40 +02:00
parent 8c423eeb49
commit 783419657c
14 changed files with 132 additions and 65 deletions

View File

@@ -24,6 +24,13 @@ bool isSalBool(QualType type) {
return t != nullptr && t->getDecl()->getNameAsString() == "sal_Bool";
}
bool isSalBoolArray(QualType type) {
auto t = type->getAsArrayTypeUnsafe();
return t != nullptr
&& (isSalBool(t->getElementType())
|| isSalBoolArray(t->getElementType()));
}
// Clang 3.2 FunctionDecl::isInlined doesn't work as advertised ("Determine
// whether this function should be inlined, because it is either marked 'inline'
// or 'constexpr' or is a member function of a class that was defined in the
@@ -136,6 +143,8 @@ public:
bool VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr * expr);
bool VisitReturnStmt(ReturnStmt const * stmt);
bool WalkUpFromParmVarDecl(ParmVarDecl const * decl);
bool VisitParmVarDecl(ParmVarDecl const * decl);
@@ -248,12 +257,23 @@ bool SalBool::VisitCallExpr(CallExpr * expr) {
if (ft != nullptr) {
for (unsigned i = 0; i != compat::getNumParams(*ft); ++i) {
QualType t(compat::getParamType(*ft, i));
bool b = false;
if (t->isLValueReferenceType()) {
t = t.getNonReferenceType();
if (!t.isConstQualified() && isSalBool(t)
&& i < expr->getNumArgs())
{
DeclRefExpr * ref = dyn_cast<DeclRefExpr>(expr->getArg(i));
b = !t.isConstQualified() && isSalBool(t);
} else if (t->isPointerType()) {
for (;;) {
auto t2 = t->getAs<PointerType>();
if (t2 == nullptr) {
break;
}
t = t2->getPointeeType();
}
b = isSalBool(t);
}
if (b && i < expr->getNumArgs()) {
DeclRefExpr * ref = dyn_cast<DeclRefExpr>(
expr->getArg(i)->IgnoreParenImpCasts());
if (ref != nullptr) {
VarDecl const * d = dyn_cast<VarDecl>(ref->getDecl());
if (d != nullptr) {
@@ -263,7 +283,6 @@ bool SalBool::VisitCallExpr(CallExpr * expr) {
}
}
}
}
return true;
}
@@ -363,6 +382,53 @@ bool SalBool::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr * expr) {
return true;
}
bool SalBool::VisitReturnStmt(ReturnStmt const * stmt) {
// Just enough to avoid warnings in rtl_getUriCharClass (sal/rtl/uri.cxx),
// which has
//
// static sal_Bool const aCharClass[][nCharClassSize] = ...;
//
// and
//
// return aCharClass[eCharClass];
//
if (ignoreLocation(stmt)) {
return true;
}
auto e = stmt->getRetValue();
if (e == nullptr) {
return true;
}
auto t = e->getType();
if (!t->isPointerType()) {
return true;
}
for (;;) {
auto t2 = t->getAs<PointerType>();
if (t2 == nullptr) {
break;
}
t = t2->getPointeeType();
}
if (!isSalBool(t)) {
return true;
}
auto e2 = dyn_cast<ArraySubscriptExpr>(e->IgnoreParenImpCasts());
if (e2 == nullptr) {
return true;
}
auto e3 = dyn_cast<DeclRefExpr>(e2->getBase()->IgnoreParenImpCasts());
if (e3 == nullptr) {
return true;
}
auto d = dyn_cast<VarDecl>(e3->getDecl());
if (d == nullptr) {
return true;
}
varDecls_.erase(d);
return true;
}
bool SalBool::WalkUpFromParmVarDecl(ParmVarDecl const * decl) {
return VisitParmVarDecl(decl);
}
@@ -467,7 +533,8 @@ bool SalBool::VisitVarDecl(VarDecl const * decl) {
if (ignoreLocation(decl)) {
return true;
}
if (!decl->isExternC() && isSalBool(decl->getType())
if (!decl->isExternC()
&& (isSalBool(decl->getType()) || isSalBoolArray(decl->getType()))
&& !isInSpecialMainFile(
compiler.getSourceManager().getSpellingLoc(decl->getLocStart())))
{
@@ -484,7 +551,7 @@ bool SalBool::VisitFieldDecl(FieldDecl const * decl) {
if (ignoreLocation(decl)) {
return true;
}
if (isSalBool(decl->getType())
if ((isSalBool(decl->getType()) || isSalBoolArray(decl->getType()))
&& !isInSpecialMainFile(
compiler.getSourceManager().getSpellingLoc(decl->getLocStart())))
{

View File

@@ -2321,20 +2321,20 @@ extern "C" void SAL_CALL typelib_setCacheSize( sal_Int32 nNewSize )
}
static const sal_Bool s_aAssignableFromTab[11][11] =
static const bool s_aAssignableFromTab[11][11] =
{
/* from CH,BO,BY,SH,US,LO,UL,HY,UH,FL,DO */
/* TypeClass_CHAR */ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
/* TypeClass_BOOLEAN */ { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
/* TypeClass_BYTE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
/* TypeClass_SHORT */ { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
/* TypeClass_UNSIGNED_SHORT */ { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
/* TypeClass_LONG */ { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
/* TypeClass_UNSIGNED_LONG */ { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
/* TypeClass_HYPER */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 },
/* TypeClass_UNSIGNED_HYPER */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 },
/* TypeClass_FLOAT */ { 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0 },
/* TypeClass_DOUBLE */ { 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1 }
/* from CH, BO, BY, SH, US, LO, UL, HY, UH, FL, DO */
/* TypeClass_CHAR */ { true, false, false, false, false, false, false, false, false, false, false },
/* TypeClass_BOOLEAN */ { false, true, false, false, false, false, false, false, false, false, false },
/* TypeClass_BYTE */ { false, false, true, false, false, false, false, false, false, false, false },
/* TypeClass_SHORT */ { false, false, true, true, true, false, false, false, false, false, false },
/* TypeClass_UNSIGNED_SHORT */ { false, false, true, true, true, false, false, false, false, false, false },
/* TypeClass_LONG */ { false, false, true, true, true, true, true, false, false, false, false },
/* TypeClass_UNSIGNED_LONG */ { false, false, true, true, true, true, true, false, false, false, false },
/* TypeClass_HYPER */ { false, false, true, true, true, true, true, true, true, false, false },
/* TypeClass_UNSIGNED_HYPER */ { false, false, true, true, true, true, true, true, true, false, false },
/* TypeClass_FLOAT */ { false, false, true, true, true, false, false, false, false, true, false },
/* TypeClass_DOUBLE */ { false, false, true, true, true, true, true, false, false, true, true }
};

View File

@@ -62,7 +62,7 @@ struct SvxSaveTabPage_Impl
Sequence< sal_Bool > aODFArr[APP_COUNT];
Sequence< OUString > aUIFilterArr[APP_COUNT];
OUString aDefaultArr[APP_COUNT];
sal_Bool aDefaultReadonlyArr[APP_COUNT];
bool aDefaultReadonlyArr[APP_COUNT];
bool bInitialized;
SvxSaveTabPage_Impl();

View File

@@ -99,7 +99,7 @@ static const sal_uInt16 dev_cell_check[14][14] = {
/* 13 */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } /* HD */
};
sal_Bool DEV_Composible[2][2] = {
bool DEV_Composible[2][2] = {
/* Mode 0 */ {true, true }, // PASSTHROUGH = 0
/* Mode 1 */ {false, true} // STRICT = 1
};

View File

@@ -55,7 +55,7 @@ sal_Char TAC_celltype_inputcheck[17][17] = {
{ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', 'R', 'R', 'C', 'R', 'C', 'R', 'R', 'R', 'R' }
};
sal_Bool TAC_Composible[3][5] = {
bool TAC_Composible[3][5] = {
/* 'A', 'C', 'S', 'R', 'X' */
/* Mode 0 */ {true, true, true, true, true}, // PASSTHROUGH = 0
/* Mode 1 */ {true, true, true, false, true}, // BASIC = 1

View File

@@ -165,13 +165,13 @@ public:
inline void clearBuffer() throw( SAXException );
};
const sal_Bool g_bValidCharsBelow32[32] =
const bool g_bValidCharsBelow32[32] =
{
// 0 1 2 3 4 5 6 7
0,0,0,0,0,0,0,0, //0
0,1,1,0,0,1,0,0, //8
0,0,0,0,0,0,0,0, //16
0,0,0,0,0,0,0,0
false,false,false,false,false,false,false,false, //0
false,true, true, false,false,true, false,false, //8
false,false,false,false,false,false,false,false, //16
false,false,false,false,false,false,false,false
};
inline bool IsInvalidChar(const sal_Unicode aChar)

View File

@@ -92,7 +92,7 @@ class FormCache
{
private:
FormIdent aIdents[ nSize_ ]; //gepufferte Formate
sal_Bool bValid[ nSize_ ];
bool bValid[ nSize_ ];
FormIdent aCompareIdent; // zum Vergleichen
sal_uInt8 nDefaultFormat; // Defaultformat der Datei
SvNumberFormatter* pFormTable; // Value-Format-Table-Anker
@@ -128,7 +128,7 @@ inline const SfxUInt32Item* FormCache::GetAttr( sal_uInt8 nFormat, sal_uInt8 nSt
OSL_ENSURE( pAttr, "FormCache::GetAttr(): Nothing to save" );
aIdents[ nIndex ] = FormIdent( nFormat, nSt, *pAttr );
bValid[ nIndex ] = sal_True;
bValid[ nIndex ] = true;
pRet = pAttr;
}

View File

@@ -376,7 +376,7 @@ VCL_BUILDER_DECL_FACTORY(TableValueSet)
void TableDesignWidget::updateControls()
{
static const sal_Bool gDefaults[CB_COUNT] = { true, false, true, false, false, false };
static const bool gDefaults[CB_COUNT] = { true, false, true, false, false, false };
const bool bHasTable = mxSelectedTable.is();
const OUString* pPropNames = getPropertyNames();

View File

@@ -108,20 +108,20 @@ sal_Bool IdlClassImpl::equals( const Reference< XIdlClass >& xType )
(xType->getTypeClass() == _eTypeClass) && (xType->getName() == _aName));
}
static const sal_Bool s_aAssignableFromTab[11][11] =
static const bool s_aAssignableFromTab[11][11] =
{
/* from CH,BO,BY,SH,US,LO,UL,HY,UH,FL,DO */
/* TypeClass_CHAR */ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
/* TypeClass_BOOLEAN */ { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
/* TypeClass_BYTE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
/* TypeClass_SHORT */ { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
/* TypeClass_UNSIGNED_SHORT */ { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
/* TypeClass_LONG */ { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
/* TypeClass_UNSIGNED_LONG */ { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
/* TypeClass_HYPER */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 },
/* TypeClass_UNSIGNED_HYPER */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 },
/* TypeClass_FLOAT */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
/* TypeClass_DOUBLE */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
/* from CH, BO, BY, SH, US, LO, UL, HY, UH, FL, DO */
/* TypeClass_CHAR */ { true, false, false, false, false, false, false, false, false, false, false },
/* TypeClass_BOOLEAN */ { false, true, false, false, false, false, false, false, false, false, false },
/* TypeClass_BYTE */ { false, false, true, false, false, false, false, false, false, false, false },
/* TypeClass_SHORT */ { false, false, true, true, true, false, false, false, false, false, false },
/* TypeClass_UNSIGNED_SHORT */ { false, false, true, true, true, false, false, false, false, false, false },
/* TypeClass_LONG */ { false, false, true, true, true, true, true, false, false, false, false },
/* TypeClass_UNSIGNED_LONG */ { false, false, true, true, true, true, true, false, false, false, false },
/* TypeClass_HYPER */ { false, false, true, true, true, true, true, true, true, false, false },
/* TypeClass_UNSIGNED_HYPER */ { false, false, true, true, true, true, true, true, true, false, false },
/* TypeClass_FLOAT */ { false, false, true, true, true, true, true, true, true, true, false },
/* TypeClass_DOUBLE */ { false, false, true, true, true, true, true, true, true, true, true }
};
sal_Bool IdlClassImpl::isAssignableFrom( const Reference< XIdlClass > & xType )

View File

@@ -1183,7 +1183,7 @@ void FmXGridPeer::removeModifyListener(const Reference< css::util::XModifyListen
Sequence< sal_Bool > SAL_CALL FmXGridPeer::queryFieldDataType( const Type& xType ) throw(RuntimeException, std::exception)
{
// eine 'Konvertierungstabelle'
static const sal_Bool bCanConvert[LAST_KNOWN_TYPE][4] =
static const bool bCanConvert[LAST_KNOWN_TYPE][4] =
{
{ false, false, false, false }, // FormComponentType::CONTROL
{ false, false, false, false }, // FormComponentType::COMMANDBUTTON

View File

@@ -619,7 +619,7 @@ public:
private:
SvXMLImportContextRef mxTableImportContext;
OUString msTemplateStyleName;
sal_Bool maTemplateStylesUsed[6];
bool maTemplateStylesUsed[6];
};
#endif // INCLUDED_XMLOFF_SOURCE_DRAW_XIMPSHAP_HXX

View File

@@ -2180,7 +2180,7 @@ namespace xmloff
{
FormSubmitEncoding_URL, FormSubmitMethod_GET, CommandType::COMMAND, NavigationBarMode_CURRENT, TabulatorCycle_RECORDS
};
static const sal_Bool nEnumPropertyAttrDefaultFlags[] =
static const bool nEnumPropertyAttrDefaultFlags[] =
{
false, false, false, false, true
};

View File

@@ -67,7 +67,7 @@ XMLIndexTemplateContext::XMLIndexTemplateContext(
const SvXMLEnumMapEntry* pLevelNameMap,
enum XMLTokenEnum eLevelAttrName,
const sal_Char** pLevelStylePropMap,
const sal_Bool* pAllowedTokenTypes,
const bool* pAllowedTokenTypes,
bool bT )
: SvXMLImportContext(rImport, nPrfx, rLocalName)
, pOutlineLevelNameMap(pLevelNameMap)
@@ -352,7 +352,7 @@ const sal_Char* aLevelStylePropNameTOCMap[] =
"ParaStyleLevel7", "ParaStyleLevel8", "ParaStyleLevel9",
"ParaStyleLevel10", nullptr };
const sal_Bool aAllowedTokenTypesTOC[] =
const bool aAllowedTokenTypesTOC[] =
{
true, // XML_TOK_INDEX_TYPE_ENTRY_TEXT =
true, // XML_TOK_INDEX_TYPE_TAB_STOP,
@@ -364,7 +364,7 @@ const sal_Bool aAllowedTokenTypesTOC[] =
false // XML_TOK_INDEX_TYPE_BIBLIOGRAPHY
};
const sal_Bool aAllowedTokenTypesUser[] =
const bool aAllowedTokenTypesUser[] =
{
true, // XML_TOK_INDEX_TYPE_ENTRY_TEXT =
true, // XML_TOK_INDEX_TYPE_TAB_STOP,
@@ -392,7 +392,7 @@ const sal_Char* aLevelStylePropNameAlphaMap[] =
{ nullptr, "ParaStyleSeparator", "ParaStyleLevel1", "ParaStyleLevel2",
"ParaStyleLevel3", nullptr };
const sal_Bool aAllowedTokenTypesAlpha[] =
const bool aAllowedTokenTypesAlpha[] =
{
true, // XML_TOK_INDEX_TYPE_ENTRY_TEXT =
true, // XML_TOK_INDEX_TYPE_TAB_STOP,
@@ -446,7 +446,7 @@ const sal_Char* aLevelStylePropNameBibliographyMap[] =
"ParaStyleLevel1", "ParaStyleLevel1", "ParaStyleLevel1",
"ParaStyleLevel1", nullptr };
const sal_Bool aAllowedTokenTypesBibliography[] =
const bool aAllowedTokenTypesBibliography[] =
{
true, // XML_TOK_INDEX_TYPE_ENTRY_TEXT =
true, // XML_TOK_INDEX_TYPE_TAB_STOP,
@@ -467,7 +467,7 @@ const SvXMLEnumMapEntry* aLevelNameTableMap = nullptr;
const sal_Char* aLevelStylePropNameTableMap[] =
{ nullptr, "ParaStyleLevel1", nullptr };
const sal_Bool aAllowedTokenTypesTable[] =
const bool aAllowedTokenTypesTable[] =
{
true, // XML_TOK_INDEX_TYPE_ENTRY_TEXT =
true, // XML_TOK_INDEX_TYPE_TAB_STOP,

View File

@@ -40,23 +40,23 @@ struct SvXMLEnumMapEntry;
// TOC and user defined index:
extern const SvXMLEnumMapEntry aSvLevelNameTOCMap[];
extern const sal_Char* aLevelStylePropNameTOCMap[];
extern const sal_Bool aAllowedTokenTypesTOC[];
extern const sal_Bool aAllowedTokenTypesUser[];
extern const bool aAllowedTokenTypesTOC[];
extern const bool aAllowedTokenTypesUser[];
// alphabetical index:
extern const SvXMLEnumMapEntry aLevelNameAlphaMap[];
extern const sal_Char* aLevelStylePropNameAlphaMap[];
extern const sal_Bool aAllowedTokenTypesAlpha[];
extern const bool aAllowedTokenTypesAlpha[];
// bibliography:
extern const SvXMLEnumMapEntry aLevelNameBibliographyMap[];
extern const sal_Char* aLevelStylePropNameBibliographyMap[];
extern const sal_Bool aAllowedTokenTypesBibliography[];
extern const bool aAllowedTokenTypesBibliography[];
// table, illustration and object tables:
extern const SvXMLEnumMapEntry* aLevelNameTableMap; // NULL: no outline-level
extern const sal_Char* aLevelStylePropNameTableMap[];
extern const sal_Bool aAllowedTokenTypesTable[];
extern const bool aAllowedTokenTypesTable[];
/**
@@ -72,7 +72,7 @@ class XMLIndexTemplateContext : public SvXMLImportContext
const SvXMLEnumMapEntry* pOutlineLevelNameMap;
enum ::xmloff::token::XMLTokenEnum eOutlineLevelAttrName;
const sal_Char** pOutlineLevelStylePropMap;
const sal_Bool* pAllowedTokenTypesMap;
const bool* pAllowedTokenTypesMap;
sal_Int32 nOutlineLevel;
bool bStyleNameOK;
@@ -117,7 +117,7 @@ public:
const SvXMLEnumMapEntry* aLevelNameMap,
enum ::xmloff::token::XMLTokenEnum eLevelAttrName,
const sal_Char** aLevelStylePropNameMap,
const sal_Bool* aAllowedTokenTypes,
const bool* aAllowedTokenTypes,
bool bTOC=false);
virtual ~XMLIndexTemplateContext();