compilerplugins/clang/bodynotinblock.cxx | 17 +-- compilerplugins/clang/bodynotinblock.hxx | 3 rsc/source/parser/rscyacc.y | 26 ++--- rsc/source/res/rsccont.cxx | 148 +++++++++++++++---------------- rsc/source/rsc/rsc.cxx | 2 rsc/source/rscpp/cpp5.c | 102 ++++++++++----------- rsc/source/rscpp/cpp6.c | 2 7 files changed, 151 insertions(+), 149 deletions(-)
New commits: commit 1ed9af9a4419b50a76eea56eb2e4c684e616673b Author: LuboÅ¡ LuÅák <l.lu...@suse.cz> Date: Tue Nov 20 16:26:53 2012 +0100 skip 'else' from a macro expansion too Change-Id: I1a6d70d1554dc5bf8f46940ed62b47ab34983aa7 diff --git a/compilerplugins/clang/bodynotinblock.cxx b/compilerplugins/clang/bodynotinblock.cxx index b6572bf..90f7933 100644 --- a/compilerplugins/clang/bodynotinblock.cxx +++ b/compilerplugins/clang/bodynotinblock.cxx @@ -56,15 +56,15 @@ void BodyNotInBlock::traverseStatement( const Stmt* stmt, StmtParents& parents ) parents.push_back( *it ); if( const IfStmt* ifstmt = dyn_cast< IfStmt >( *it )) { - checkBody( ifstmt->getThen(), parents, 0, ifstmt->getElse() != NULL ); - checkBody( ifstmt->getElse(), parents, 0 ); + checkBody( ifstmt->getThen(), ifstmt->getIfLoc(), parents, 0, ifstmt->getElse() != NULL ); + checkBody( ifstmt->getElse(), ifstmt->getElseLoc(), parents, 0 ); } else if( const WhileStmt* whilestmt = dyn_cast< WhileStmt >( *it )) - checkBody( whilestmt->getBody(), parents, 1 ); + checkBody( whilestmt->getBody(), whilestmt->getWhileLoc(), parents, 1 ); else if( const ForStmt* forstmt = dyn_cast< ForStmt >( *it )) - checkBody( forstmt->getBody(), parents, 2 ); + checkBody( forstmt->getBody(), forstmt->getForLoc(), parents, 2 ); else if( const CXXForRangeStmt* forstmt = dyn_cast< CXXForRangeStmt >( *it )) - checkBody( forstmt->getBody(), parents, 2 ); + checkBody( forstmt->getBody(), forstmt->getForLoc(), parents, 2 ); parents.pop_back(); } } @@ -72,16 +72,17 @@ void BodyNotInBlock::traverseStatement( const Stmt* stmt, StmtParents& parents ) parents.pop_back(); } -void BodyNotInBlock::checkBody( const Stmt* body, const StmtParents& parents, int stmtType, bool dontGoUp ) +void BodyNotInBlock::checkBody( const Stmt* body, SourceLocation stmtLocation, const StmtParents& parents, + int stmtType, bool dontGoUp ) { if( body == NULL || parents.size() < 2 ) return; - // TODO: If the if/while/for comes from a macro expansion, ignore it completely for + // TODO: If the if/else/while/for comes from a macro expansion, ignore it completely for // now. The code below could assume everything is in the same place (and thus also column) // and give a false warning. Moreover some macros are rather lousily written and would // result in poor formatting. To be evaluated later, maybe this could be handled // including macro expansion. - if( parents.back()->getLocStart().isMacroID()) + if( stmtLocation.isMacroID()) return; if( dyn_cast< CompoundStmt >( body )) return; // if body is a compound statement, then it is in {} diff --git a/compilerplugins/clang/bodynotinblock.hxx b/compilerplugins/clang/bodynotinblock.hxx index 304bbf0..3cfc9ba 100644 --- a/compilerplugins/clang/bodynotinblock.hxx +++ b/compilerplugins/clang/bodynotinblock.hxx @@ -27,7 +27,8 @@ class BodyNotInBlock private: typedef vector< const Stmt* > StmtParents; void traverseStatement( const Stmt* stmt, StmtParents& parents ); - void checkBody( const Stmt* body, const StmtParents& parents, int stmtType, bool dontGoUp = false ); + void checkBody( const Stmt* body, SourceLocation stmtLocation, const StmtParents& parents, + int stmtType, bool dontGoUp = false ); }; } // namespace commit 13cca3de54265b884fc80a10450096c7e1061b36 Author: LuboÅ¡ LuÅák <l.lu...@suse.cz> Date: Tue Nov 20 16:12:57 2012 +0100 incorrect body alignment Change-Id: Ie62113f0018e71c984845f1684a4876809b901c4 diff --git a/rsc/source/parser/rscyacc.y b/rsc/source/parser/rscyacc.y index 2efc6ff..4fbf0fd 100644 --- a/rsc/source/parser/rscyacc.y +++ b/rsc/source/parser/rscyacc.y @@ -160,7 +160,7 @@ sal_Bool DoClassHeader( RSCHEADER * pHeader, sal_Bool bMember ) RSCINST aTmpI( S.Top() ); aTmpI.pClass->Destroy( aTmpI ); aTmpI.pClass->Create( &aTmpI, aCopyInst ); - }; + } } else pTC->pEH->Error( ERR_FALSETYPE, S.Top().pClass, aName1, @@ -213,8 +213,8 @@ sal_Bool DoClassHeader( RSCHEADER * pHeader, sal_Bool bMember ) return( sal_False ); } S.Push( aTmpI ); - }; - }; + } + } if( TYPE_REF == pHeader->nTyp ) { ERRTYPE aError; @@ -770,7 +770,7 @@ var_header_class pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), pHS->getString( $1 ).getStr() ); return( ERR_ERROR ); - }; + } if( !DoClassHeader( &$3, sal_True ) ) return( ERR_ERROR ); @@ -799,7 +799,7 @@ var_header_class pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), pHS->getString( $1 ).getStr() ); return( ERR_ERROR ); - }; + } if( !DoClassHeader( &$6, sal_True ) ) return( ERR_ERROR ); $$ = $6; @@ -828,7 +828,7 @@ var_header_class pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), pHS->getString( $1 ).getStr() ); return( ERR_ERROR ); - }; + } if( !DoClassHeader( &$6, sal_True ) ) return( ERR_ERROR ); $$ = $6; @@ -848,7 +848,7 @@ var_header pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), pHS->getString( $1 ).getStr() ); return( ERR_ERROR ); - }; + } } | VARNAME '[' CONSTNAME ']' '=' { @@ -872,7 +872,7 @@ var_header pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), pHS->getString( $1 ).getStr() ); return( ERR_ERROR ); - }; + } } | VARNAME '[' SYMBOL ']' '=' { @@ -897,7 +897,7 @@ var_header pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), pHS->getString( $1 ).getStr() ); return( ERR_ERROR ); - }; + } } ; tupel_header0 @@ -912,7 +912,7 @@ tupel_header0 { pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() ); return( ERR_ERROR ); - }; + } } ; @@ -928,7 +928,7 @@ tupel_header1 { pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() ); return( ERR_ERROR ); - }; + } } ; @@ -944,7 +944,7 @@ tupel_header2 { pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() ); return( ERR_ERROR ); - }; + } } ; @@ -958,7 +958,7 @@ tupel_header3 { pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() ); return( ERR_ERROR ); - }; + } S.Push( aInst ); } ; diff --git a/rsc/source/res/rsccont.cxx b/rsc/source/res/rsccont.cxx index 5411c34..9ead877 100644 --- a/rsc/source/res/rsccont.cxx +++ b/rsc/source/res/rsccont.cxx @@ -407,24 +407,24 @@ ERRTYPE RscBaseCont::SetString( const RSCINST & rInst, const char * pStr ) //?B 040991 //?W 040991 sonst Endlosrekursion moeglich -if( RSC_NOTYPE == pTypeClass->GetTypId() ){ - aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); - aError = aTmpI.pClass->GetString( aTmpI, &pTmpStr ); - if( aError.IsOk() ) - aError = aTmpI.pClass->SetString( aTmpI, pStr ); - else { - aError.Clear(); - DeletePos( rInst, pClassData->nEntries -1 ); - aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); + if( RSC_NOTYPE == pTypeClass->GetTypId() ){ + aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); aError = aTmpI.pClass->GetString( aTmpI, &pTmpStr ); if( aError.IsOk() ) aError = aTmpI.pClass->SetString( aTmpI, pStr ); + else { + aError.Clear(); + DeletePos( rInst, pClassData->nEntries -1 ); + aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); + aError = aTmpI.pClass->GetString( aTmpI, &pTmpStr ); + if( aError.IsOk() ) + aError = aTmpI.pClass->SetString( aTmpI, pStr ); + } + if( aError.IsError() ) + DeletePos( rInst, pClassData->nEntries -1 ); } - if( aError.IsError() ) - DeletePos( rInst, pClassData->nEntries -1 ); -} -else - aError = ERR_UNKNOWN_METHOD; + else + aError = ERR_UNKNOWN_METHOD; return( aError ); } @@ -444,24 +444,24 @@ ERRTYPE RscBaseCont::SetNumber( const RSCINST & rInst, sal_Int32 lValue ){ //?B 040991 //?W 040991 sonst Endlosrekursion moeglich -if( RSC_NOTYPE == pTypeClass->GetTypId() ){ - aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); - aError = aTmpI.pClass->GetNumber( aTmpI, &lNumber ); - if( aError.IsOk() ) - aError = aTmpI.pClass->SetNumber( aTmpI, lValue ); - else { - aError.Clear(); - DeletePos( rInst, pClassData->nEntries -1 ); - aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); + if( RSC_NOTYPE == pTypeClass->GetTypId() ){ + aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); aError = aTmpI.pClass->GetNumber( aTmpI, &lNumber ); if( aError.IsOk() ) aError = aTmpI.pClass->SetNumber( aTmpI, lValue ); + else { + aError.Clear(); + DeletePos( rInst, pClassData->nEntries -1 ); + aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); + aError = aTmpI.pClass->GetNumber( aTmpI, &lNumber ); + if( aError.IsOk() ) + aError = aTmpI.pClass->SetNumber( aTmpI, lValue ); + } + if( aError.IsError() ) + DeletePos( rInst, pClassData->nEntries -1 ); } - if( aError.IsError() ) - DeletePos( rInst, pClassData->nEntries -1 ); -} -else - aError = ERR_UNKNOWN_METHOD; + else + aError = ERR_UNKNOWN_METHOD; return( aError ); } @@ -480,27 +480,27 @@ ERRTYPE RscBaseCont::SetBool pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); -//?B 040991 -//?W 040991 sonst Endlosrekursion moeglich -if( RSC_NOTYPE == pTypeClass->GetTypId() ) -{ - aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); - aError = aTmpI.pClass->GetBool( aTmpI, &bBool ); - if( aError.IsOk() ) - aError = aTmpI.pClass->SetBool( aTmpI, bValue ); - else { - aError.Clear(); - DeletePos( rInst, pClassData->nEntries -1 ); - aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); + //?B 040991 + //?W 040991 sonst Endlosrekursion moeglich + if( RSC_NOTYPE == pTypeClass->GetTypId() ) + { + aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); aError = aTmpI.pClass->GetBool( aTmpI, &bBool ); if( aError.IsOk() ) aError = aTmpI.pClass->SetBool( aTmpI, bValue ); + else { + aError.Clear(); + DeletePos( rInst, pClassData->nEntries -1 ); + aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); + aError = aTmpI.pClass->GetBool( aTmpI, &bBool ); + if( aError.IsOk() ) + aError = aTmpI.pClass->SetBool( aTmpI, bValue ); + } + if( aError.IsError() ) + DeletePos( rInst, pClassData->nEntries -1 ); } - if( aError.IsError() ) - DeletePos( rInst, pClassData->nEntries -1 ); -} -else - aError = ERR_UNKNOWN_METHOD; + else + aError = ERR_UNKNOWN_METHOD; return( aError ); } @@ -522,24 +522,24 @@ ERRTYPE RscBaseCont::SetConst //?B 040991 //?W 040991 sonst Endlosrekursion moeglich -if( RSC_NOTYPE == pTypeClass->GetTypId() ){ - aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); - aError = aTmpI.pClass->GetConst( aTmpI, &nConst ); - if( aError.IsOk() ) - aError = aTmpI.pClass->SetConst( aTmpI, nValueId, lValue ); - else { - aError.Clear(); - DeletePos( rInst, pClassData->nEntries -1 ); - aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); + if( RSC_NOTYPE == pTypeClass->GetTypId() ){ + aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); aError = aTmpI.pClass->GetConst( aTmpI, &nConst ); if( aError.IsOk() ) aError = aTmpI.pClass->SetConst( aTmpI, nValueId, lValue ); + else { + aError.Clear(); + DeletePos( rInst, pClassData->nEntries -1 ); + aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); + aError = aTmpI.pClass->GetConst( aTmpI, &nConst ); + if( aError.IsOk() ) + aError = aTmpI.pClass->SetConst( aTmpI, nValueId, lValue ); + } + if( aError.IsError() ) + DeletePos( rInst, pClassData->nEntries -1 ); } - if( aError.IsError() ) - DeletePos( rInst, pClassData->nEntries -1 ); -} -else - aError = ERR_UNKNOWN_METHOD; + else + aError = ERR_UNKNOWN_METHOD; return( aError ); } @@ -559,24 +559,24 @@ ERRTYPE RscBaseCont::SetRef( const RSCINST & rInst, const RscId & rRefId ){ //?B 040991 //?W 040991 sonst Endlosrekursion moeglich -if( RSC_NOTYPE == pTypeClass->GetTypId() ){ - aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); - aError = aTmpI.pClass->GetRef( aTmpI, &aId ); - if( aError.IsOk() ) - aError = aTmpI.pClass->SetRef( aTmpI, rRefId ); - else { - aError.Clear(); - DeletePos( rInst, pClassData->nEntries -1 ); - aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); + if( RSC_NOTYPE == pTypeClass->GetTypId() ){ + aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); aError = aTmpI.pClass->GetRef( aTmpI, &aId ); if( aError.IsOk() ) - aError = aTmpI.pClass->SetNumber( aTmpI, rRefId ); + aError = aTmpI.pClass->SetRef( aTmpI, rRefId ); + else { + aError.Clear(); + DeletePos( rInst, pClassData->nEntries -1 ); + aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); + aError = aTmpI.pClass->GetRef( aTmpI, &aId ); + if( aError.IsOk() ) + aError = aTmpI.pClass->SetNumber( aTmpI, rRefId ); + } + if( aError.IsError() ) + DeletePos( rInst, pClassData->nEntries -1 ); } - if( aError.IsError() ) - DeletePos( rInst, pClassData->nEntries -1 ); -} -else - aError = ERR_UNKNOWN_METHOD; + else + aError = ERR_UNKNOWN_METHOD; return( aError ); } diff --git a/rsc/source/rscpp/cpp5.c b/rsc/source/rscpp/cpp5.c index b0663fc..42bf271 100644 --- a/rsc/source/rscpp/cpp5.c +++ b/rsc/source/rscpp/cpp5.c @@ -511,37 +511,37 @@ dosizeof() typecode = 0; while (0 != (c = skipws())) { if ((c = macroid(c)) == EOF_CHAR || c == '\n') - goto nogood; /* End of line is a bug */ + goto nogood; /* End of line is a bug */ else if (c == '(') { /* thing (*)() func ptr */ - if (skipws() == '*' - && skipws() == ')') { /* We found (*) */ - if (skipws() != '(') /* Let () be optional */ - unget(); - else if (skipws() != ')') - goto nogood; - typecode |= T_FPTR; /* Function pointer */ - } - else { /* Junk is a bug */ - goto nogood; - } + if (skipws() == '*' + && skipws() == ')') { /* We found (*) */ + if (skipws() != '(') /* Let () be optional */ + unget(); + else if (skipws() != ')') + goto nogood; + typecode |= T_FPTR; /* Function pointer */ + } + else { /* Junk is a bug */ + goto nogood; + } } else if (type[c] != LET) /* Exit if not a type */ - break; - else if (!catenate()) { /* Maybe combine tokens */ - /* - * Look for this unexpandable token in basic_types. - * The code accepts "int long" as well as "long int" - * which is a minor bug as bugs go (and one shared with - * a lot of C compilers). - */ - for (tp = basic_types; tp->name != NULLST; tp++) { - if (streq(token, tp->name)) break; - } - if (tp->name == NULLST) { - cerror("#if sizeof, unknown type \"%s\"", token); - return (OP_FAIL); - } + else if (!catenate()) { /* Maybe combine tokens */ + /* + * Look for this unexpandable token in basic_types. + * The code accepts "int long" as well as "long int" + * which is a minor bug as bugs go (and one shared with + * a lot of C compilers). + */ + for (tp = basic_types; tp->name != NULLST; tp++) { + if (streq(token, tp->name)) + break; + } + if (tp->name == NULLST) { + cerror("#if sizeof, unknown type \"%s\"", token); + return (OP_FAIL); + } typecode |= tp->type; /* Or in the type bit */ } } @@ -554,10 +554,10 @@ dosizeof() } if (c == ')') { /* Last syntax check */ for (testp = test_table; *testp != 0; testp++) { - if (!bittest(typecode & *testp)) { - cerror("#if ... sizeof: illegal type combination", NULLST); - return (OP_FAIL); - } + if (!bittest(typecode & *testp)) { + cerror("#if ... sizeof: illegal type combination", NULLST); + return (OP_FAIL); + } } /* * We assume that all function pointers are the same size: @@ -566,25 +566,25 @@ dosizeof() * sizeof (signed int) == (sizeof unsigned int) */ if ((typecode & T_FPTR) != 0) /* Function pointer */ - typecode = T_FPTR | T_PTR; + typecode = T_FPTR | T_PTR; else { /* Var or var * datum */ - typecode &= ~(T_SIGNED | T_UNSIGNED); - if ((typecode & (T_SHORT | T_LONG)) != 0) - typecode &= ~T_INT; + typecode &= ~(T_SIGNED | T_UNSIGNED); + if ((typecode & (T_SHORT | T_LONG)) != 0) + typecode &= ~T_INT; } if ((typecode & ~T_PTR) == 0) { - cerror("#if sizeof() error, no type specified", NULLST); - return (OP_FAIL); + cerror("#if sizeof() error, no type specified", NULLST); + return (OP_FAIL); } /* * Exactly one bit (and possibly T_PTR) may be set. */ for (sizp = size_table; sizp->bits != 0; sizp++) { - if ((typecode & ~T_PTR) == sizp->bits) { - evalue = ((typecode & T_PTR) != 0) - ? sizp->psize : sizp->size; - return (DIG); - } + if ((typecode & ~T_PTR) == sizp->bits) { + evalue = ((typecode & T_PTR) != 0) + ? sizp->psize : sizp->size; + return (DIG); + } } /* We shouldn't fail */ cierror("#if ... sizeof: bug, unknown type code 0x%x", typecode); return (OP_FAIL); @@ -642,7 +642,7 @@ evalnum(int c) c1 -= ('a' - 10); else c1 -= '0'; if (c1 < 0 || c1 >= base) - break; + break; value *= base; value += c1; c = cget(); @@ -743,7 +743,7 @@ evalchar(int skip) */ while ((c = get()) != '\'' && c != EOF_CHAR && c != '\n') { if (!skip) - ciwarn("multi-byte constant '%c' isn't portable", c); + ciwarn("multi-byte constant '%c' isn't portable", c); value <<= BITS_CHAR; value += c; } @@ -794,16 +794,16 @@ evaleval(int* valp, int op, int skip) case OP_DIV: case OP_MOD: if (v2 == 0) { - if (!skip) { - cwarn("%s by zero in #if, zero result assumed", - (op == OP_DIV) ? "divide" : "mod"); - } - v1 = 0; + if (!skip) { + cwarn("%s by zero in #if, zero result assumed", + (op == OP_DIV) ? "divide" : "mod"); + } + v1 = 0; } else if (op == OP_DIV) - v1 /= v2; + v1 /= v2; else - v1 %= v2; + v1 %= v2; break; case OP_ASL: diff --git a/rsc/source/rscpp/cpp6.c b/rsc/source/rscpp/cpp6.c index 3e2d609..438ea76 100644 --- a/rsc/source/rscpp/cpp6.c +++ b/rsc/source/rscpp/cpp6.c @@ -349,7 +349,7 @@ void (*outfun)() /* BP */ && c != EOF_CHAR) { if (c != DEF_MAGIC) - (*outfun)(c); + (*outfun)(c); if (c == '\\') (*outfun)(get()); } commit 0465fa4a8c60bdac8970762ac4a4b07d92c865c7 Author: LuboÅ¡ LuÅák <l.lu...@suse.cz> Date: Tue Nov 20 16:12:17 2012 +0100 unused variable Change-Id: Id6de037a510b129799c89dc4a7fdb105ac006b2a diff --git a/rsc/source/rsc/rsc.cxx b/rsc/source/rsc/rsc.cxx index 9199659..92da200 100644 --- a/rsc/source/rsc/rsc.cxx +++ b/rsc/source/rsc/rsc.cxx @@ -827,7 +827,7 @@ ERRTYPE RscCompiler::Link() aSysListTmp = lcl_getTempFile(sOilDirUrl); OSL_TRACE("temporary ilst file: %s", aSysListTmp.getStr()); - OUString sIlstUrl, sIlstSys; + OUString sIlstUrl; sIlstUrl = sRcUrl.copy(sRcUrl.lastIndexOf('/')+1); sIlstUrl = sIlstUrl.copy(0,sIlstUrl.lastIndexOf('.')); sIlstUrl += OUString(RTL_CONSTASCII_USTRINGPARAM(".ilst"));
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits