Add new warning option to check for dead code and change the order of some struct members to reduce structure padding.

This commit is contained in:
Edoardo Prezioso 2011-10-24 02:52:55 +02:00
parent 36ef8e771f
commit df5d26901c
6 changed files with 52 additions and 62 deletions

View File

@ -6,7 +6,7 @@ ifndef HAVE_RULES
endif endif
ifndef CXXFLAGS ifndef CXXFLAGS
CXXFLAGS=-Wall -Wextra -Wshadow -pedantic -Wno-long-long -Wfloat-equal -Wcast-qual -Woverloaded-virtual -Wsign-promo -Wabi -Winline -Wredundant-decls -Wpacked -Wmissing-format-attribute -Wmissing-declarations -D_GLIBCXX_DEBUG -g CXXFLAGS=-pedantic -Wall -Wextra -Wabi -Wcast-qual -Wfloat-equal -Winline -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Woverloaded-virtual -Wpacked -Wredundant-decls -Wshadow -Wsign-promo -Wunreachable-code -D_GLIBCXX_DEBUG -g
endif endif
ifeq ($(HAVE_RULES),yes) ifeq ($(HAVE_RULES),yes)

View File

@ -30,7 +30,9 @@
Token::Token(Token **t) : Token::Token(Token **t) :
tokensBack(t), tokensBack(t),
_str(""), _next(0),
_previous(0),
_link(0),
_isName(false), _isName(false),
_isNumber(false), _isNumber(false),
_isBoolean(false), _isBoolean(false),
@ -40,12 +42,10 @@ Token::Token(Token **t) :
_isLong(false), _isLong(false),
_isUnused(false), _isUnused(false),
_varId(0), _varId(0),
_next(0),
_previous(0),
_link(0),
_fileIndex(0), _fileIndex(0),
_linenr(0), _linenr(0),
_progressValue(0) _progressValue(0),
_str("")
{ {
} }

View File

@ -428,7 +428,10 @@ private:
static int firstWordLen(const char *str); static int firstWordLen(const char *str);
std::string _str; Token *_next;
Token *_previous;
Token *_link;
bool _isName; bool _isName;
bool _isNumber; bool _isNumber;
bool _isBoolean; bool _isBoolean;
@ -438,9 +441,6 @@ private:
bool _isLong; bool _isLong;
bool _isUnused; bool _isUnused;
unsigned int _varId; unsigned int _varId;
Token *_next;
Token *_previous;
Token *_link;
unsigned int _fileIndex; unsigned int _fileIndex;
unsigned int _linenr; unsigned int _linenr;
@ -453,6 +453,8 @@ private:
* list this token is located. * list this token is located.
*/ */
unsigned int _progressValue; unsigned int _progressValue;
std::string _str;
}; };
/// @} /// @}

View File

@ -42,41 +42,28 @@
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
Tokenizer::Tokenizer() Tokenizer::Tokenizer() :
: _settings(0), _errorLogger(0) _tokens(0), //no tokens to start with
_tokensBack(0),
_settings(0),
_errorLogger(0),
_symbolDatabase(0),
_varId(0),
_codeWithTemplates(false) //is there any templates?
{ {
// No tokens to start with
_tokens = 0;
_tokensBack = 0;
// is there any templates?
_codeWithTemplates = false;
// symbol database
_symbolDatabase = NULL;
// variable count
_varId = 0;
} }
Tokenizer::Tokenizer(const Settings *settings, ErrorLogger *errorLogger) Tokenizer::Tokenizer(const Settings *settings, ErrorLogger *errorLogger) :
: _settings(settings), _errorLogger(errorLogger) _tokens(0), //no tokens to start with
_tokensBack(0),
_settings(settings),
_errorLogger(errorLogger),
_symbolDatabase(0),
_varId(0),
_codeWithTemplates(false) //is there any templates?
{ {
// make sure settings are specified // make sure settings are specified
assert(_settings); assert(_settings);
// No tokens to start with
_tokens = 0;
_tokensBack = 0;
// is there any templates?
_codeWithTemplates = false;
// symbol database
_symbolDatabase = NULL;
// variable count
_varId = 0;
} }
Tokenizer::~Tokenizer() Tokenizer::~Tokenizer()
@ -738,9 +725,9 @@ Token * Tokenizer::deleteInvalidTypedef(Token *typeDef)
} }
struct Space { struct Space {
bool isNamespace;
std::string className; std::string className;
const Token * classEnd; const Token * classEnd;
bool isNamespace;
}; };
static Token *splitDefinitionFromTypedef(Token *tok) static Token *splitDefinitionFromTypedef(Token *tok)

View File

@ -728,33 +728,33 @@ private:
/** Token list */ /** Token list */
Token *_tokens, *_tokensBack; Token *_tokens, *_tokensBack;
/** sizeof information for known types */
std::map<std::string, unsigned int> _typeSize;
/** filenames for the tokenized source code (source + included) */
std::vector<std::string> _files;
/** settings */ /** settings */
const Settings * _settings; const Settings * _settings;
/** errorlogger */ /** errorlogger */
ErrorLogger * const _errorLogger; ErrorLogger * const _errorLogger;
/** Symbol database that all checks etc can use */
mutable SymbolDatabase *_symbolDatabase;
/** E.g. "A" for code where "#ifdef A" is true. This is used to /** E.g. "A" for code where "#ifdef A" is true. This is used to
print additional information in error situations. */ print additional information in error situations. */
std::string _configuration; std::string _configuration;
/** sizeof information for known types */
std::map<std::string, unsigned int> _typeSize;
/** filenames for the tokenized source code (source + included) */
std::vector<std::string> _files;
/** variable count */
unsigned int _varId;
/** /**
* was there any templates? templates that are "unused" are * was there any templates? templates that are "unused" are
* removed from the token list * removed from the token list
*/ */
bool _codeWithTemplates; bool _codeWithTemplates;
/** Symbol database that all checks etc can use */
mutable SymbolDatabase *_symbolDatabase;
/** variable count */
unsigned int _varId;
}; };
/// @} /// @}

View File

@ -216,21 +216,22 @@ int main(int argc, char **argv)
// The _GLIBCXX_DEBUG doesn't work in cygwin // The _GLIBCXX_DEBUG doesn't work in cygwin
makeConditionalVariable(fout, "CXXFLAGS", makeConditionalVariable(fout, "CXXFLAGS",
"-pedantic "
"-Wall " "-Wall "
"-Wextra " "-Wextra "
"-Wshadow "
"-pedantic "
"-Wno-long-long "
"-Wfloat-equal "
"-Wcast-qual "
"-Woverloaded-virtual "
"-Wsign-promo "
"-Wabi " "-Wabi "
"-Wcast-qual "
"-Wfloat-equal "
"-Winline " "-Winline "
"-Wredundant-decls "
"-Wpacked "
"-Wmissing-format-attribute "
"-Wmissing-declarations " "-Wmissing-declarations "
"-Wmissing-format-attribute "
"-Wno-long-long "
"-Woverloaded-virtual "
"-Wpacked "
"-Wredundant-decls "
"-Wshadow "
"-Wsign-promo "
"-Wunreachable-code "
// "-Wsign-conversion " // "-Wsign-conversion "
// "-Wconversion " // "-Wconversion "
"-D_GLIBCXX_DEBUG " "-D_GLIBCXX_DEBUG "