astyle FTW (should have read about that sooner)

This commit is contained in:
booga 2009-07-24 19:23:30 -04:00
parent 52e2e775b2
commit 9fa8c0ee9c
4 changed files with 49 additions and 48 deletions

View File

@ -1160,7 +1160,7 @@ void CheckOther::postIncrement()
if (decltok && Token::Match(decltok->previous(), "iterator|const_iterator"))
postIncrementError(tok2, tok2->strAt(1), (std::string("++") == tok2->strAt(2)));
// Is the variable a class?
else if (Token::findmatch( _tokenizer->tokens(), classDef.c_str() ))
else if (Token::findmatch(_tokenizer->tokens(), classDef.c_str()))
postIncrementError(tok2, tok2->strAt(1), (std::string("++") == tok2->strAt(2)));
break;
@ -1264,6 +1264,6 @@ void CheckOther::zerodivError(const Token *tok)
void CheckOther::postIncrementError(const Token *tok, const std::string &var_name, const bool isIncrement)
{
std::string type = ( isIncrement ? "Incrementing" : "Decrementing" );
reportError(tok, Severity::possibleStyle, "postIncrementDecrement", ("Pre-" + type + " variable '" + var_name + "' is preferred to Post-" + type) );
std::string type = (isIncrement ? "Incrementing" : "Decrementing");
reportError(tok, Severity::possibleStyle, "postIncrementDecrement", ("Pre-" + type + " variable '" + var_name + "' is preferred to Post-" + type));
}

View File

@ -370,9 +370,9 @@ void CheckStl::stlBoundries()
{
// Declaring iterator..
const std::string checkStr = (std::string(STL_CONTAINER_LIST) + " <");
if (Token::Match( tok, checkStr.c_str() ))
if (Token::Match(tok, checkStr.c_str()))
{
const std::string container_name( tok->strAt(0) );
const std::string container_name(tok->strAt(0));
while (tok && tok->str() != ">")
tok = tok->next();
if (!tok)

View File

@ -378,18 +378,19 @@ private:
const int STL_CONTAINER_LIST = 10;
const std::string stlCont[STL_CONTAINER_LIST] =
{"vector", "deque", "list", "set", "multiset", "map",
"multimap", "hash_map", "hash_multimap", "hash_set"};
"multimap", "hash_map", "hash_multimap", "hash_set"
};
for(int i = 0; i < STL_CONTAINER_LIST; ++i)
for (int i = 0; i < STL_CONTAINER_LIST; ++i)
{
const std::string checkStr( "void f()\n"
const std::string checkStr("void f()\n"
"{\n"
" std::" + stlCont[i] + "<int>::iterator it;\n"
" for (it = ab.begin(); it < ab.end(); ++it)\n"
" ;\n"
"}\n" );
"}\n");
check( checkStr.c_str() );
check(checkStr.c_str());
ASSERT_EQUALS("[test.cpp:4]: (error) " + stlCont[i] + " range check should use != and not < since the order of the pointers isn't guaranteed\n", errout.str());
}