Merge branch 'master' of git@github.com:danmar/cppcheck

This commit is contained in:
Daniel Marjamäki 2009-10-10 22:11:00 +02:00
commit e52c36788f
3 changed files with 13 additions and 11 deletions

View File

@ -1027,7 +1027,7 @@ std::string Preprocessor::getcode(const std::string &filedata, std::string cfg,
std::map<std::string, std::string> cfgmap; std::map<std::string, std::string> cfgmap;
{ {
std::string::size_type pos = 0; std::string::size_type pos = 0;
while (true) for (;;)
{ {
std::string::size_type pos2 = cfg.find_first_of(";=", pos); std::string::size_type pos2 = cfg.find_first_of(";=", pos);
if (pos2 == std::string::npos) if (pos2 == std::string::npos)
@ -1314,6 +1314,8 @@ private:
/** The macro has parantheses but no parameters.. "AAA()" */ /** The macro has parantheses but no parameters.. "AAA()" */
bool _nopar; bool _nopar;
/** disabled assignment operator */
void operator=(const PreprocessorMacro &);
public: public:
/** /**
* @param macro The code after #define, until end of line, * @param macro The code after #define, until end of line,

View File

@ -123,7 +123,7 @@ void Tokenizer::addtoken(const char str[], const unsigned int lineno, const unsi
int Tokenizer::sizeOfType(const Token *type) const unsigned int Tokenizer::sizeOfType(const Token *type) const
{ {
if (!type || !type->strAt(0)) if (!type || !type->strAt(0))
return 0; return 0;
@ -1435,8 +1435,8 @@ void Tokenizer::simplifySizeof()
Token::Match(tok->tokAt(-2), "[;{}(,] %type% %var% [;),]") || Token::Match(tok->tokAt(-2), "[;{}(,] %type% %var% [;),]") ||
Token::Match(tok->tokAt(-3), "[;{}(,] const %type% %var% [;),]")) Token::Match(tok->tokAt(-3), "[;{}(,] const %type% %var% [;),]"))
{ {
const int size = sizeOfType(tok->previous()); const unsigned int size = sizeOfType(tok->previous());
if (size <= 0) if (size == 0)
{ {
continue; continue;
} }
@ -1447,8 +1447,8 @@ void Tokenizer::simplifySizeof()
else if (Token::Match(tok->tokAt(-1), "%type% %var% [ %num% ] [;=]") || else if (Token::Match(tok->tokAt(-1), "%type% %var% [ %num% ] [;=]") ||
Token::Match(tok->tokAt(-2), "%type% * %var% [ %num% ] [;=]")) Token::Match(tok->tokAt(-2), "%type% * %var% [ %num% ] [;=]"))
{ {
int size = sizeOfType(tok->tokAt(-1)); unsigned int size = sizeOfType(tok->tokAt(-1));
if (size <= 0) if (size == 0)
continue; continue;
sizeOfVar[varId] = MathLib::toString<long>(size * MathLib::toLongNumber(tok->strAt(2))); sizeOfVar[varId] = MathLib::toString<long>(size * MathLib::toLongNumber(tok->strAt(2)));
@ -1464,8 +1464,8 @@ void Tokenizer::simplifySizeof()
else if (Token::Match(tok->tokAt(-1), "%type% %var% [ ] = %str% ;")) else if (Token::Match(tok->tokAt(-1), "%type% %var% [ ] = %str% ;"))
{ {
int size = sizeOfType(tok->tokAt(4)); unsigned int size = sizeOfType(tok->tokAt(4));
if (size <= 0) if (size == 0)
continue; continue;
sizeOfVar[varId] = MathLib::toString<long>(size); sizeOfVar[varId] = MathLib::toString<long>(size);
@ -1574,7 +1574,7 @@ void Tokenizer::simplifySizeof()
else if (Token::Match(tok, "sizeof ( %type% )")) else if (Token::Match(tok, "sizeof ( %type% )"))
{ {
int size = sizeOfType(tok->tokAt(2)); unsigned int size = sizeOfType(tok->tokAt(2));
if (size > 0) if (size > 0)
{ {
tok->str(MathLib::toString<long>(size)); tok->str(MathLib::toString<long>(size));
@ -1585,7 +1585,7 @@ void Tokenizer::simplifySizeof()
else if (Token::Match(tok, "sizeof ( * %var% )") || Token::Match(tok, "sizeof ( %var% [ %num% ] )")) else if (Token::Match(tok, "sizeof ( * %var% )") || Token::Match(tok, "sizeof ( %var% [ %num% ] )"))
{ {
// Some default value.. // Some default value..
int sz = 100; unsigned int sz = 100;
unsigned int varid = tok->tokAt((tok->tokAt(2)->str() == "*") ? 3 : 2)->varId(); unsigned int varid = tok->tokAt((tok->tokAt(2)->str() == "*") ? 3 : 2)->varId();
if (varid != 0) if (varid != 0)

View File

@ -90,7 +90,7 @@ public:
* @param type Token which will contain e.g. "int", "*", or string. * @param type Token which will contain e.g. "int", "*", or string.
* @return sizeof for given type, or 0 if it can't be calculated. * @return sizeof for given type, or 0 if it can't be calculated.
*/ */
int sizeOfType(const Token *type) const; unsigned int sizeOfType(const Token *type) const;
const std::vector<std::string> *getFiles() const; const std::vector<std::string> *getFiles() const;