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:
parent
36ef8e771f
commit
df5d26901c
2
Makefile
2
Makefile
|
@ -6,7 +6,7 @@ ifndef HAVE_RULES
|
|||
endif
|
||||
|
||||
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
|
||||
|
||||
ifeq ($(HAVE_RULES),yes)
|
||||
|
|
|
@ -30,7 +30,9 @@
|
|||
|
||||
Token::Token(Token **t) :
|
||||
tokensBack(t),
|
||||
_str(""),
|
||||
_next(0),
|
||||
_previous(0),
|
||||
_link(0),
|
||||
_isName(false),
|
||||
_isNumber(false),
|
||||
_isBoolean(false),
|
||||
|
@ -40,12 +42,10 @@ Token::Token(Token **t) :
|
|||
_isLong(false),
|
||||
_isUnused(false),
|
||||
_varId(0),
|
||||
_next(0),
|
||||
_previous(0),
|
||||
_link(0),
|
||||
_fileIndex(0),
|
||||
_linenr(0),
|
||||
_progressValue(0)
|
||||
_progressValue(0),
|
||||
_str("")
|
||||
{
|
||||
}
|
||||
|
||||
|
|
10
lib/token.h
10
lib/token.h
|
@ -428,7 +428,10 @@ private:
|
|||
static int firstWordLen(const char *str);
|
||||
|
||||
|
||||
std::string _str;
|
||||
Token *_next;
|
||||
Token *_previous;
|
||||
Token *_link;
|
||||
|
||||
bool _isName;
|
||||
bool _isNumber;
|
||||
bool _isBoolean;
|
||||
|
@ -438,9 +441,6 @@ private:
|
|||
bool _isLong;
|
||||
bool _isUnused;
|
||||
unsigned int _varId;
|
||||
Token *_next;
|
||||
Token *_previous;
|
||||
Token *_link;
|
||||
unsigned int _fileIndex;
|
||||
unsigned int _linenr;
|
||||
|
||||
|
@ -453,6 +453,8 @@ private:
|
|||
* list this token is located.
|
||||
*/
|
||||
unsigned int _progressValue;
|
||||
|
||||
std::string _str;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
|
|
@ -42,41 +42,28 @@
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
Tokenizer::Tokenizer()
|
||||
: _settings(0), _errorLogger(0)
|
||||
Tokenizer::Tokenizer() :
|
||||
_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)
|
||||
: _settings(settings), _errorLogger(errorLogger)
|
||||
Tokenizer::Tokenizer(const 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
|
||||
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()
|
||||
|
@ -738,9 +725,9 @@ Token * Tokenizer::deleteInvalidTypedef(Token *typeDef)
|
|||
}
|
||||
|
||||
struct Space {
|
||||
bool isNamespace;
|
||||
std::string className;
|
||||
const Token * classEnd;
|
||||
bool isNamespace;
|
||||
};
|
||||
|
||||
static Token *splitDefinitionFromTypedef(Token *tok)
|
||||
|
|
|
@ -728,33 +728,33 @@ private:
|
|||
/** Token list */
|
||||
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 */
|
||||
const Settings * _settings;
|
||||
|
||||
/** 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
|
||||
print additional information in error situations. */
|
||||
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
|
||||
* removed from the token list
|
||||
*/
|
||||
bool _codeWithTemplates;
|
||||
|
||||
/** Symbol database that all checks etc can use */
|
||||
mutable SymbolDatabase *_symbolDatabase;
|
||||
|
||||
/** variable count */
|
||||
unsigned int _varId;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
|
|
@ -216,21 +216,22 @@ int main(int argc, char **argv)
|
|||
|
||||
// The _GLIBCXX_DEBUG doesn't work in cygwin
|
||||
makeConditionalVariable(fout, "CXXFLAGS",
|
||||
"-pedantic "
|
||||
"-Wall "
|
||||
"-Wextra "
|
||||
"-Wshadow "
|
||||
"-pedantic "
|
||||
"-Wno-long-long "
|
||||
"-Wfloat-equal "
|
||||
"-Wcast-qual "
|
||||
"-Woverloaded-virtual "
|
||||
"-Wsign-promo "
|
||||
"-Wabi "
|
||||
"-Wcast-qual "
|
||||
"-Wfloat-equal "
|
||||
"-Winline "
|
||||
"-Wredundant-decls "
|
||||
"-Wpacked "
|
||||
"-Wmissing-format-attribute "
|
||||
"-Wmissing-declarations "
|
||||
"-Wmissing-format-attribute "
|
||||
"-Wno-long-long "
|
||||
"-Woverloaded-virtual "
|
||||
"-Wpacked "
|
||||
"-Wredundant-decls "
|
||||
"-Wshadow "
|
||||
"-Wsign-promo "
|
||||
"-Wunreachable-code "
|
||||
// "-Wsign-conversion "
|
||||
// "-Wconversion "
|
||||
"-D_GLIBCXX_DEBUG "
|
||||
|
|
Loading…
Reference in New Issue