Replaced make_container by C++11 initializer lists
This commit is contained in:
parent
ae3e649cc4
commit
e2002db78d
|
@ -319,21 +319,21 @@ static bool IsAddressOnStack(const void* ptr)
|
|||
* For now we only want to detect abnormal behaviour for a few selected signals:
|
||||
*/
|
||||
|
||||
#define DECLARE_SIGNAL(x) << std::make_pair(x, #x)
|
||||
#define DECLARE_SIGNAL(x) std::make_pair(x, #x)
|
||||
typedef std::map<int, std::string> Signalmap_t;
|
||||
static const Signalmap_t listofsignals = make_container< Signalmap_t > ()
|
||||
DECLARE_SIGNAL(SIGABRT)
|
||||
DECLARE_SIGNAL(SIGBUS)
|
||||
DECLARE_SIGNAL(SIGFPE)
|
||||
DECLARE_SIGNAL(SIGILL)
|
||||
DECLARE_SIGNAL(SIGINT)
|
||||
DECLARE_SIGNAL(SIGQUIT)
|
||||
DECLARE_SIGNAL(SIGSEGV)
|
||||
DECLARE_SIGNAL(SIGSYS)
|
||||
static const Signalmap_t listofsignals = {
|
||||
DECLARE_SIGNAL(SIGABRT),
|
||||
DECLARE_SIGNAL(SIGBUS),
|
||||
DECLARE_SIGNAL(SIGFPE),
|
||||
DECLARE_SIGNAL(SIGILL),
|
||||
DECLARE_SIGNAL(SIGINT),
|
||||
DECLARE_SIGNAL(SIGQUIT),
|
||||
DECLARE_SIGNAL(SIGSEGV),
|
||||
DECLARE_SIGNAL(SIGSYS),
|
||||
// don't care: SIGTERM
|
||||
DECLARE_SIGNAL(SIGUSR1)
|
||||
DECLARE_SIGNAL(SIGUSR1),
|
||||
//DECLARE_SIGNAL(SIGUSR2) no usage currently
|
||||
;
|
||||
};
|
||||
#undef DECLARE_SIGNAL
|
||||
/*
|
||||
* Entry pointer for signal handlers
|
||||
|
|
|
@ -1898,7 +1898,7 @@ bool CheckClass::isConstMemberFunc(const Scope *scope, const Token *tok) const
|
|||
|
||||
namespace {
|
||||
// The container contains the STL types whose operator[] is not a const.
|
||||
const std::set<std::string> stl_containers_not_const = make_container< std::set<std::string> >() << "map" << "unordered_map";
|
||||
const std::set<std::string> stl_containers_not_const = { "map", "unordered_map" };
|
||||
}
|
||||
|
||||
bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, bool& memberAccessed) const
|
||||
|
|
|
@ -129,7 +129,7 @@ private:
|
|||
/** Missing exception specification */
|
||||
void unhandledExceptionSpecificationError(const Token * const tok1, const Token * const tok2, const std::string & funcname) {
|
||||
const std::string str1(tok1 ? tok1->str() : "foo");
|
||||
const std::list<const Token*> locationList = make_container< std::list<const Token*> > () << tok1 << tok2;
|
||||
const std::list<const Token*> locationList = { tok1, tok2 };
|
||||
reportError(locationList, Severity::style, "unhandledExceptionSpecification",
|
||||
"Unhandled exception specification when calling function " + str1 + "().\n"
|
||||
"Unhandled exception specification when calling function " + str1 + "(). "
|
||||
|
|
|
@ -191,22 +191,23 @@ void CheckInternal::checkTokenSimpleMatchPatterns()
|
|||
}
|
||||
|
||||
namespace {
|
||||
const std::set<std::string> knownPatterns = make_container< std::set<std::string> > ()
|
||||
<< "%any%"
|
||||
<< "%assign%"
|
||||
<< "%bool%"
|
||||
<< "%char%"
|
||||
<< "%comp%"
|
||||
<< "%num%"
|
||||
<< "%op%"
|
||||
<< "%cop%"
|
||||
<< "%or%"
|
||||
<< "%oror%"
|
||||
<< "%str%"
|
||||
<< "%type%"
|
||||
<< "%name%"
|
||||
<< "%var%"
|
||||
<< "%varid%";
|
||||
const std::set<std::string> knownPatterns = {
|
||||
"%any%"
|
||||
, "%assign%"
|
||||
, "%bool%"
|
||||
, "%char%"
|
||||
, "%comp%"
|
||||
, "%num%"
|
||||
, "%op%"
|
||||
, "%cop%"
|
||||
, "%or%"
|
||||
, "%oror%"
|
||||
, "%str%"
|
||||
, "%type%"
|
||||
, "%name%"
|
||||
, "%var%"
|
||||
, "%varid%"
|
||||
};
|
||||
}
|
||||
|
||||
void CheckInternal::checkMissingPercentCharacter()
|
||||
|
|
|
@ -114,8 +114,7 @@ struct Filepointer {
|
|||
};
|
||||
|
||||
namespace {
|
||||
const std::set<std::string> whitelist = make_container< std::set<std::string> > ()
|
||||
<< "clearerr" << "feof" << "ferror" << "fgetpos" << "ftell" << "setbuf" << "setvbuf" << "ungetc" << "ungetwc";
|
||||
const std::set<std::string> whitelist = { "clearerr", "feof", "ferror", "fgetpos", "ftell", "setbuf", "setvbuf", "ungetc", "ungetwc" };
|
||||
}
|
||||
|
||||
void CheckIO::checkFileUsage()
|
||||
|
@ -1544,8 +1543,8 @@ CheckIO::ArgumentInfo::~ArgumentInfo()
|
|||
}
|
||||
|
||||
namespace {
|
||||
const std::set<std::string> stl_vector = make_container< std::set<std::string> >() << "array" << "vector";
|
||||
const std::set<std::string> stl_string = make_container< std::set<std::string> >() << "string" << "u16string" << "u32string" << "wstring";
|
||||
const std::set<std::string> stl_vector = { "array", "vector" };
|
||||
const std::set<std::string> stl_string = { "string", "u16string", "u32string", "wstring" };
|
||||
}
|
||||
|
||||
bool CheckIO::ArgumentInfo::isStdVectorOrString()
|
||||
|
@ -1605,13 +1604,13 @@ bool CheckIO::ArgumentInfo::isStdVectorOrString()
|
|||
}
|
||||
|
||||
namespace {
|
||||
const std::set<std::string> stl_container = make_container< std::set<std::string> >() <<
|
||||
"array" << "bitset" << "deque" << "forward_list" <<
|
||||
"hash_map" << "hash_multimap" << "hash_set" <<
|
||||
"list" << "map" << "multimap" << "multiset" <<
|
||||
"priority_queue" << "queue" << "set" << "stack" <<
|
||||
"unordered_map" << "unordered_multimap" << "unordered_multiset" << "unordered_set" << "vector"
|
||||
;
|
||||
const std::set<std::string> stl_container = {
|
||||
"array", "bitset", "deque", "forward_list",
|
||||
"hash_map", "hash_multimap", "hash_set",
|
||||
"list", "map", "multimap", "multiset",
|
||||
"priority_queue", "queue", "set", "stack",
|
||||
"unordered_map", "unordered_multimap", "unordered_multiset", "unordered_set", "vector"
|
||||
};
|
||||
}
|
||||
|
||||
bool CheckIO::ArgumentInfo::isStdContainer(const Token *tok)
|
||||
|
|
|
@ -75,21 +75,22 @@ static unsigned int countParameters(const Token *tok)
|
|||
* This list contains function names with const parameters e.g.: atof(const char *)
|
||||
* TODO: This list should be replaced by <leak-ignore/> in .cfg files.
|
||||
*/
|
||||
static const std::set<std::string> call_func_white_list = make_container < std::set<std::string> > ()
|
||||
<< "_open" << "_wopen" << "access" << "adjtime" << "asctime_r" << "asprintf" << "chdir" << "chmod" << "chown"
|
||||
<< "creat" << "ctime_r" << "execl" << "execle" << "execlp" << "execv" << "execve" << "fchmod" << "fcntl"
|
||||
<< "fdatasync" << "fclose" << "flock" << "fmemopen" << "fnmatch" << "fopen" << "fopencookie" << "for" << "free"
|
||||
<< "freopen"<< "fseeko" << "fstat" << "fsync" << "ftello" << "ftruncate" << "getgrnam" << "gethostbyaddr" << "gethostbyname"
|
||||
<< "getnetbyname" << "getopt" << "getopt_long" << "getprotobyname" << "getpwnam" << "getservbyname" << "getservbyport"
|
||||
<< "glob" << "gmtime" << "gmtime_r" << "if" << "index" << "inet_addr" << "inet_aton" << "inet_network" << "initgroups"
|
||||
<< "ioctl" << "link" << "localtime_r" << "lockf" << "lseek" << "lstat" << "mkdir" << "mkfifo" << "mknod" << "mkstemp"
|
||||
<< "obstack_printf" << "obstack_vprintf" << "open" << "opendir" << "parse_printf_format" << "pathconf"
|
||||
<< "perror" << "popen" << "posix_fadvise" << "posix_fallocate" << "pread" << "psignal" << "pwrite" << "read" << "readahead"
|
||||
<< "readdir" << "readdir_r" << "readlink" << "readv" << "realloc" << "regcomp" << "return" << "rewinddir" << "rindex"
|
||||
<< "rmdir" << "scandir" << "seekdir" << "setbuffer" << "sethostname" << "setlinebuf" << "sizeof" << "strdup"
|
||||
<< "stat" << "stpcpy" << "strcasecmp" << "stricmp" << "strncasecmp" << "switch"
|
||||
<< "symlink" << "sync_file_range" << "telldir" << "tempnam" << "time" << "typeid" << "unlink"
|
||||
<< "utime" << "utimes" << "vasprintf" << "while" << "wordexp" << "write" << "writev";
|
||||
static const std::set<std::string> call_func_white_list = {
|
||||
"_open", "_wopen", "access", "adjtime", "asctime_r", "asprintf", "chdir", "chmod", "chown"
|
||||
, "creat", "ctime_r", "execl", "execle", "execlp", "execv", "execve", "fchmod", "fcntl"
|
||||
, "fdatasync", "fclose", "flock", "fmemopen", "fnmatch", "fopen", "fopencookie", "for", "free"
|
||||
, "freopen", "fseeko", "fstat", "fsync", "ftello", "ftruncate", "getgrnam", "gethostbyaddr", "gethostbyname"
|
||||
, "getnetbyname", "getopt", "getopt_long", "getprotobyname", "getpwnam", "getservbyname", "getservbyport"
|
||||
, "glob", "gmtime", "gmtime_r", "if", "index", "inet_addr", "inet_aton", "inet_network", "initgroups"
|
||||
, "ioctl", "link", "localtime_r", "lockf", "lseek", "lstat", "mkdir", "mkfifo", "mknod", "mkstemp"
|
||||
, "obstack_printf", "obstack_vprintf", "open", "opendir", "parse_printf_format", "pathconf"
|
||||
, "perror", "popen", "posix_fadvise", "posix_fallocate", "pread", "psignal", "pwrite", "read", "readahead"
|
||||
, "readdir", "readdir_r", "readlink", "readv", "realloc", "regcomp", "return", "rewinddir", "rindex"
|
||||
, "rmdir", "scandir", "seekdir", "setbuffer", "sethostname", "setlinebuf", "sizeof", "strdup"
|
||||
, "stat", "stpcpy", "strcasecmp", "stricmp", "strncasecmp", "switch"
|
||||
, "symlink", "sync_file_range", "telldir", "tempnam", "time", "typeid", "unlink"
|
||||
, "utime", "utimes", "vasprintf", "while", "wordexp", "write", "writev"
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
@ -506,18 +507,19 @@ bool CheckMemoryLeakInFunction::test_white_list(const std::string &funcname, con
|
|||
}
|
||||
|
||||
namespace {
|
||||
const std::set<std::string> call_func_keywords = make_container < std::set<std::string> > ()
|
||||
<< "asprintf"
|
||||
<< "delete"
|
||||
<< "fclose"
|
||||
<< "for"
|
||||
<< "free"
|
||||
<< "if"
|
||||
<< "realloc"
|
||||
<< "return"
|
||||
<< "switch"
|
||||
<< "while"
|
||||
<< "sizeof";
|
||||
const std::set<std::string> call_func_keywords = {
|
||||
"asprintf"
|
||||
, "delete"
|
||||
, "fclose"
|
||||
, "for"
|
||||
, "free"
|
||||
, "if"
|
||||
, "realloc"
|
||||
, "return"
|
||||
, "switch"
|
||||
, "while"
|
||||
, "sizeof"
|
||||
};
|
||||
}
|
||||
|
||||
const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<const Token *> callstack, const unsigned int varid, AllocType &alloctype, AllocType &dealloctype, bool &allocpar, unsigned int sz)
|
||||
|
|
|
@ -144,10 +144,11 @@ void CheckNullPointer::parseFunctionCall(const Token &tok, std::list<const Token
|
|||
}
|
||||
|
||||
namespace {
|
||||
const std::set<std::string> stl_stream = make_container< std::set<std::string> >() <<
|
||||
"fstream" << "ifstream" << "iostream" << "istream" <<
|
||||
"istringstream" << "ofstream" << "ostream" << "ostringstream" <<
|
||||
"stringstream" << "wistringstream" << "wostringstream" << "wstringstream";
|
||||
const std::set<std::string> stl_stream = {
|
||||
"fstream", "ifstream", "iostream", "istream",
|
||||
"istringstream", "ofstream", "ostream", "ostringstream",
|
||||
"stringstream", "wistringstream", "wostringstream", "wstringstream"
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -375,9 +376,10 @@ void CheckNullPointer::nullPointer()
|
|||
}
|
||||
|
||||
namespace {
|
||||
const std::set<std::string> stl_istream = make_container< std::set<std::string> >() <<
|
||||
"fstream" << "ifstream" << "iostream" << "istream" <<
|
||||
"istringstream" << "stringstream" << "wistringstream" << "wstringstream";
|
||||
const std::set<std::string> stl_istream = {
|
||||
"fstream", "ifstream", "iostream", "istream",
|
||||
"istringstream", "stringstream", "wistringstream", "wstringstream"
|
||||
};
|
||||
}
|
||||
|
||||
/** Dereferencing null constant (simplified token list) */
|
||||
|
|
|
@ -709,21 +709,21 @@ void CheckOther::checkRedundantAssignment()
|
|||
|
||||
void CheckOther::redundantCopyError(const Token *tok1, const Token* tok2, const std::string& var)
|
||||
{
|
||||
const std::list<const Token *> callstack = make_container< std::list<const Token *> >() << tok1 << tok2;
|
||||
const std::list<const Token *> callstack = { tok1, tok2 };
|
||||
reportError(callstack, Severity::performance, "redundantCopy",
|
||||
"Buffer '" + var + "' is being written before its old content has been used.", CWE563, false);
|
||||
}
|
||||
|
||||
void CheckOther::redundantCopyInSwitchError(const Token *tok1, const Token* tok2, const std::string &var)
|
||||
{
|
||||
const std::list<const Token *> callstack = make_container< std::list<const Token *> >() << tok1 << tok2;
|
||||
const std::list<const Token *> callstack = { tok1, tok2 };
|
||||
reportError(callstack, Severity::warning, "redundantCopyInSwitch",
|
||||
"Buffer '" + var + "' is being written before its old content has been used. 'break;' missing?", CWE563, false);
|
||||
}
|
||||
|
||||
void CheckOther::redundantAssignmentError(const Token *tok1, const Token* tok2, const std::string& var, bool inconclusive)
|
||||
{
|
||||
const std::list<const Token *> callstack = make_container< std::list<const Token *> >() << tok1 << tok2;
|
||||
const std::list<const Token *> callstack = { tok1, tok2 };
|
||||
if (inconclusive)
|
||||
reportError(callstack, Severity::style, "redundantAssignment",
|
||||
"Variable '" + var + "' is reassigned a value before the old one has been used if variable is no semaphore variable.\n"
|
||||
|
@ -735,7 +735,7 @@ void CheckOther::redundantAssignmentError(const Token *tok1, const Token* tok2,
|
|||
|
||||
void CheckOther::redundantAssignmentInSwitchError(const Token *tok1, const Token* tok2, const std::string &var)
|
||||
{
|
||||
const std::list<const Token *> callstack = make_container< std::list<const Token *> >() << tok1 << tok2;
|
||||
const std::list<const Token *> callstack = { tok1, tok2 };
|
||||
reportError(callstack, Severity::warning, "redundantAssignInSwitch",
|
||||
"Variable '" + var + "' is reassigned a value before the old one has been used. 'break;' missing?", CWE563, false);
|
||||
}
|
||||
|
@ -1788,7 +1788,7 @@ void CheckOther::checkDuplicateBranch()
|
|||
|
||||
void CheckOther::duplicateBranchError(const Token *tok1, const Token *tok2)
|
||||
{
|
||||
const std::list<const Token *> toks = make_container< std::list<const Token *> >() << tok2 << tok1;
|
||||
const std::list<const Token *> toks = { tok2, tok1 };
|
||||
|
||||
reportError(toks, Severity::style, "duplicateBranch", "Found duplicate branches for 'if' and 'else'.\n"
|
||||
"Finding the same code in an 'if' and related 'else' branch is suspicious and "
|
||||
|
@ -2008,7 +2008,7 @@ void CheckOther::checkDuplicateExpression()
|
|||
|
||||
void CheckOther::duplicateExpressionError(const Token *tok1, const Token *tok2, const std::string &op)
|
||||
{
|
||||
const std::list<const Token *> toks = make_container< std::list<const Token *> >() << tok2 << tok1;
|
||||
const std::list<const Token *> toks = { tok2, tok1 };
|
||||
|
||||
reportError(toks, Severity::style, "duplicateExpression", "Same expression on both sides of \'" + op + "\'.\n"
|
||||
"Finding the same expression on both sides of an operator is suspicious and might "
|
||||
|
@ -2018,7 +2018,7 @@ void CheckOther::duplicateExpressionError(const Token *tok1, const Token *tok2,
|
|||
|
||||
void CheckOther::duplicateAssignExpressionError(const Token *tok1, const Token *tok2)
|
||||
{
|
||||
const std::list<const Token *> toks = make_container< std::list<const Token *> >() << tok2 << tok1;
|
||||
const std::list<const Token *> toks = { tok2, tok1 };
|
||||
|
||||
reportError(toks, Severity::style, "duplicateAssignExpression",
|
||||
"Same expression used in consecutive assignments of '" + tok1->str() + "' and '" + tok2->str() + "'.\n"
|
||||
|
|
|
@ -301,20 +301,23 @@ void CheckStl::mismatchingContainersError(const Token *tok)
|
|||
reportError(tok, Severity::error, "mismatchingContainers", "Iterators of different containers are used together.", CWE664, false);
|
||||
}
|
||||
|
||||
static const std::set<std::string> algorithm2 = make_container< std::set<std::string> >() // func(begin1, end1
|
||||
<< "binary_search" << "copy" << "copy_if" << "equal_range"
|
||||
<< "generate" << "is_heap" << "is_heap_until" << "is_partitioned"
|
||||
<< "is_permutation" << "is_sorted" << "is_sorted_until" << "lower_bound" << "make_heap" << "max_element" << "minmax_element"
|
||||
<< "min_element" << "mismatch" << "move" << "move_backward" << "next_permutation" << "partition" << "partition_copy"
|
||||
<< "partition_point" << "pop_heap" << "prev_permutation" << "push_heap" << "random_shuffle" << "remove" << "remove_copy"
|
||||
<< "remove_copy_if" << "remove_if" << "replace" << "replace_copy" << "replace_copy_if" << "replace_if" << "reverse" << "reverse_copy"
|
||||
<< "shuffle" << "sort" << "sort_heap" << "stable_partition" << "stable_sort" << "swap_ranges" << "transform" << "unique"
|
||||
<< "unique_copy" << "upper_bound" << "string" << "wstring" << "u16string" << "u32string";
|
||||
static const std::set<std::string> algorithm22 = make_container< std::set<std::string> >() // func(begin1 << end1 << begin2 << end2
|
||||
<< "includes" << "lexicographical_compare" << "merge" << "partial_sort_copy"
|
||||
<< "set_difference" << "set_intersection" << "set_symmetric_difference" << "set_union";
|
||||
static const std::set<std::string> algorithm1x1 = make_container< std::set<std::string> >() // func(begin1 << x << end1
|
||||
<< "nth_element" << "partial_sort" << "rotate" << "rotate_copy";
|
||||
static const std::set<std::string> algorithm2 = { // func(begin1, end1
|
||||
"binary_search", "copy", "copy_if", "equal_range"
|
||||
, "generate", "is_heap", "is_heap_until", "is_partitioned"
|
||||
, "is_permutation", "is_sorted", "is_sorted_until", "lower_bound", "make_heap", "max_element", "minmax_element"
|
||||
, "min_element", "mismatch", "move", "move_backward", "next_permutation", "partition", "partition_copy"
|
||||
, "partition_point", "pop_heap", "prev_permutation", "push_heap", "random_shuffle", "remove", "remove_copy"
|
||||
, "remove_copy_if", "remove_if", "replace", "replace_copy", "replace_copy_if", "replace_if", "reverse", "reverse_copy"
|
||||
, "shuffle", "sort", "sort_heap", "stable_partition", "stable_sort", "swap_ranges", "transform", "unique"
|
||||
, "unique_copy", "upper_bound", "string", "wstring", "u16string", "u32string"
|
||||
};
|
||||
static const std::set<std::string> algorithm22 = { // func(begin1, end1, begin2, end2
|
||||
"includes", "lexicographical_compare", "merge", "partial_sort_copy"
|
||||
, "set_difference", "set_intersection", "set_symmetric_difference", "set_union"
|
||||
};
|
||||
static const std::set<std::string> algorithm1x1 = { // func(begin1, x, end1
|
||||
"nth_element", "partial_sort", "rotate", "rotate_copy"
|
||||
};
|
||||
|
||||
static const std::string iteratorBeginFuncPattern = "begin|cbegin|rbegin|crbegin";
|
||||
static const std::string iteratorEndFuncPattern = "end|cend|rend|crend";
|
||||
|
@ -1040,8 +1043,9 @@ static bool isLocal(const Token *tok)
|
|||
}
|
||||
|
||||
namespace {
|
||||
const std::set<std::string> stl_string_stream = make_container< std::set<std::string> >() <<
|
||||
"istringstream" << "ostringstream" << "stringstream" << "wstringstream" ;
|
||||
const std::set<std::string> stl_string_stream = {
|
||||
"istringstream", "ostringstream", "stringstream", "wstringstream"
|
||||
};
|
||||
}
|
||||
|
||||
void CheckStl::string_c_str()
|
||||
|
@ -1375,11 +1379,12 @@ void CheckStl::autoPointerMallocError(const Token *tok, const std::string& alloc
|
|||
}
|
||||
|
||||
namespace {
|
||||
const std::set<std::string> stl_containers_with_empty_and_clear = make_container< std::set<std::string> >() <<
|
||||
"deque" << "forward_list" << "list" <<
|
||||
"map" << "multimap" << "multiset" << "set" << "string" <<
|
||||
"unordered_map" << "unordered_multimap" << "unordered_multiset" <<
|
||||
"unordered_set" << "vector" << "wstring";
|
||||
const std::set<std::string> stl_containers_with_empty_and_clear = {
|
||||
"deque", "forward_list", "list",
|
||||
"map", "multimap", "multiset", "set", "string",
|
||||
"unordered_map", "unordered_multimap", "unordered_multiset",
|
||||
"unordered_set", "vector", "wstring"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -271,11 +271,9 @@ static bool isOperatorFunction(const std::string & funcName)
|
|||
return true;
|
||||
}
|
||||
|
||||
const std::vector<std::string> additionalOperators = make_container< std::vector<std::string> >()
|
||||
<< "new"
|
||||
<< "new[]"
|
||||
<< "delete"
|
||||
<< "delete[]";
|
||||
const std::vector<std::string> additionalOperators = {
|
||||
"new", "new[]", "delete", "delete[]"
|
||||
};
|
||||
|
||||
|
||||
return std::find(additionalOperators.begin(), additionalOperators.end(), funcName.substr(operatorPrefix.length())) != additionalOperators.end();;
|
||||
|
|
|
@ -493,8 +493,7 @@ void ErrorLogger::reportUnmatchedSuppressions(const std::list<Suppressions::Supp
|
|||
if (suppressed)
|
||||
continue;
|
||||
|
||||
const std::list<ErrorLogger::ErrorMessage::FileLocation> callStack = make_container< std::list<ErrorLogger::ErrorMessage::FileLocation> > ()
|
||||
<< ErrorLogger::ErrorMessage::FileLocation(i->file, i->line);
|
||||
const std::list<ErrorLogger::ErrorMessage::FileLocation> callStack = { ErrorLogger::ErrorMessage::FileLocation(i->file, i->line) };
|
||||
reportErr(ErrorLogger::ErrorMessage(callStack, emptyString, Severity::information, "Unmatched suppression: " + i->id, "unmatchedSuppression", false));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4712,25 +4712,29 @@ Function * SymbolDatabase::findFunctionInScope(const Token *func, const Scope *n
|
|||
//---------------------------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
const std::set<std::string> c_keywords = make_container< std::set<std::string> >() <<
|
||||
"_Bool" << "auto" << "break" << "case" << "char" << "const" << "continue" << "default" << "do" <<
|
||||
"double" << "else" << "enum" << "extern" << "float" << "for" << "goto" << "if" << "inline" <<
|
||||
"int" << "long" << "register" << "restrict" << "return" << "short" << "signed" << "sizeof" <<
|
||||
"static" << "struct" << "switch" << "typedef" << "union" << "unsigned" << "void" << "volatile" <<
|
||||
"while";
|
||||
const std::set<std::string> cpp_keywords = make_container< std::set<std::string> >() <<
|
||||
c_keywords <<
|
||||
"alignas" << "alignof" << "and" << "and_eq" << "asm" << "auto" << "bitand" << "bitor" << "bool" <<
|
||||
"break" << "case" << "catch" << "char" << "class" << "compl" <<
|
||||
"concept" << "const" << "constexpr" << "const_cast" << "continue" << "decltype" << "default" <<
|
||||
"delete" << "do" << "double" << "dynamic_cast" << "else" << "enum" << "explicit" << "export" <<
|
||||
"extern" << "false" << "float" << "for" << "friend" << "goto" << "if" << "inline" << "int" << "long" <<
|
||||
"mutable" << "namespace" << "new" << "noexcept" << "not" << "not_eq" << "nullptr" << "operator" <<
|
||||
"or" << "or_eq" << "private" << "protected" << "public" << "register" << "reinterpret_cast" <<
|
||||
"requires" << "return" << "short" << "signed" << "sizeof" << "static" << "static_assert" <<
|
||||
"static_cast" << "struct" << "switch" << "template" << "this" << "thread_local" << "throw" <<
|
||||
"true" << "try" << "typedef" << "typeid" << "typename" << "union" << "unsigned" << "using" <<
|
||||
"virtual" << "void" << "volatile" << "wchar_t" << "while" << "xor" << "xor_eq";
|
||||
|
||||
#define C_KEYWORDS\
|
||||
"_Bool", "auto", "break", "case", "char", "const", "continue", "default", "do",\
|
||||
"double", "else", "enum", "extern", "float", "for", "goto", "if", "inline",\
|
||||
"int", "long", "register", "restrict", "return", "short", "signed", "sizeof",\
|
||||
"static", "struct", "switch", "typedef", "union", "unsigned", "void", "volatile",\
|
||||
"while"
|
||||
|
||||
const std::set<std::string> c_keywords = { C_KEYWORDS };
|
||||
const std::set<std::string> cpp_keywords = {
|
||||
C_KEYWORDS,
|
||||
"alignas", "alignof", "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool",
|
||||
"break", "case", "catch", "char", "class", "compl",
|
||||
"concept", "const", "constexpr", "const_cast", "continue", "decltype", "default",
|
||||
"delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", "export",
|
||||
"extern", "false", "float", "for", "friend", "goto", "if", "inline", "int", "long",
|
||||
"mutable", "namespace", "new", "noexcept", "not", "not_eq", "nullptr", "operator",
|
||||
"or", "or_eq", "private", "protected", "public", "register", "reinterpret_cast",
|
||||
"requires", "return", "short", "signed", "sizeof", "static", "static_assert",
|
||||
"static_cast", "struct", "switch", "template", "this", "thread_local", "throw",
|
||||
"true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using",
|
||||
"virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq"
|
||||
};
|
||||
}
|
||||
|
||||
bool SymbolDatabase::isReservedName(const std::string& iName) const
|
||||
|
|
|
@ -65,18 +65,19 @@ Token::~Token()
|
|||
delete _values;
|
||||
}
|
||||
|
||||
static const std::set<std::string> controlFlowKeywords = make_container< std::set<std::string> > () <<
|
||||
"goto" <<
|
||||
"do" <<
|
||||
"if" <<
|
||||
"else" <<
|
||||
"for" <<
|
||||
"while" <<
|
||||
"switch" <<
|
||||
"case" <<
|
||||
"break" <<
|
||||
"continue" <<
|
||||
"return";
|
||||
static const std::set<std::string> controlFlowKeywords = {
|
||||
"goto",
|
||||
"do",
|
||||
"if",
|
||||
"else",
|
||||
"for",
|
||||
"while",
|
||||
"switch",
|
||||
"case",
|
||||
"break",
|
||||
"continue",
|
||||
"return"
|
||||
};
|
||||
|
||||
void Token::update_property_info()
|
||||
{
|
||||
|
@ -133,18 +134,18 @@ void Token::update_property_info()
|
|||
update_property_isStandardType();
|
||||
}
|
||||
|
||||
static const std::set<std::string> stdTypes =
|
||||
make_container<std::set<std::string> >() << "bool"
|
||||
<< "_Bool"
|
||||
<< "char"
|
||||
<< "double"
|
||||
<< "float"
|
||||
<< "int"
|
||||
<< "long"
|
||||
<< "short"
|
||||
<< "size_t"
|
||||
<< "void"
|
||||
<< "wchar_t";
|
||||
static const std::set<std::string> stdTypes = { "bool"
|
||||
, "_Bool"
|
||||
, "char"
|
||||
, "double"
|
||||
, "float"
|
||||
, "int"
|
||||
, "long"
|
||||
, "short"
|
||||
, "size_t"
|
||||
, "void"
|
||||
, "wchar_t"
|
||||
};
|
||||
|
||||
void Token::update_property_isStandardType()
|
||||
{
|
||||
|
|
221
lib/tokenize.cpp
221
lib/tokenize.cpp
|
@ -2568,11 +2568,11 @@ void Tokenizer::setVarId()
|
|||
|
||||
|
||||
// Variable declarations can't start with "return" etc.
|
||||
static const std::set<std::string> notstart_c = make_container< std::set<std::string> > ()
|
||||
<< "goto" << "NOT" << "return" << "sizeof"<< "typedef";
|
||||
static const std::set<std::string> notstart_cpp = make_container< std::set<std::string> > ()
|
||||
<< notstart_c
|
||||
<< "delete" << "friend" << "new" << "throw" << "using" << "virtual" << "explicit" << "const_cast" << "dynamic_cast" << "reinterpret_cast" << "static_cast" << "template";
|
||||
#define NOTSTART_C "goto", "NOT", "return", "sizeof", "typedef"
|
||||
static const std::set<std::string> notstart_c = { NOTSTART_C };
|
||||
static const std::set<std::string> notstart_cpp = { NOTSTART_C,
|
||||
"delete", "friend", "new", "throw", "using", "virtual", "explicit", "const_cast", "dynamic_cast", "reinterpret_cast", "static_cast", "template"
|
||||
};
|
||||
|
||||
void Tokenizer::setVarIdPass1()
|
||||
{
|
||||
|
@ -6164,16 +6164,17 @@ void Tokenizer::simplifyVariableMultipleAssign()
|
|||
}
|
||||
|
||||
// Binary operators simplification map
|
||||
static const std::map<std::string, std::string> cAlternativeTokens = make_container< std::map<std::string, std::string> >()
|
||||
<< std::make_pair("and", "&&")
|
||||
<< std::make_pair("and_eq", "&=")
|
||||
<< std::make_pair("bitand", "&")
|
||||
<< std::make_pair("bitor", "|")
|
||||
<< std::make_pair("not_eq", "!=")
|
||||
<< std::make_pair("or", "||")
|
||||
<< std::make_pair("or_eq", "|=")
|
||||
<< std::make_pair("xor", "^")
|
||||
<< std::make_pair("xor_eq", "^=") ;
|
||||
static const std::map<std::string, std::string> cAlternativeTokens = {
|
||||
std::make_pair("and", "&&")
|
||||
, std::make_pair("and_eq", "&=")
|
||||
, std::make_pair("bitand", "&")
|
||||
, std::make_pair("bitor", "|")
|
||||
, std::make_pair("not_eq", "!=")
|
||||
, std::make_pair("or", "||")
|
||||
, std::make_pair("or_eq", "|=")
|
||||
, std::make_pair("xor", "^")
|
||||
, std::make_pair("xor_eq", "^=")
|
||||
};
|
||||
|
||||
// Simplify the C alternative tokens:
|
||||
// and => &&
|
||||
|
@ -7486,14 +7487,15 @@ bool Tokenizer::duplicateDefinition(Token ** tokPtr)
|
|||
return false;
|
||||
}
|
||||
|
||||
static const std::set<std::string> stdFunctionsPresentInC = make_container< std::set<std::string> > () <<
|
||||
"strcat" <<
|
||||
"strcpy" <<
|
||||
"strncat" <<
|
||||
"strncpy" <<
|
||||
"free" <<
|
||||
"malloc" <<
|
||||
"strdup";
|
||||
static const std::set<std::string> stdFunctionsPresentInC = {
|
||||
"strcat",
|
||||
"strcpy",
|
||||
"strncat",
|
||||
"strncpy",
|
||||
"free",
|
||||
"malloc",
|
||||
"strdup"
|
||||
};
|
||||
|
||||
void Tokenizer::simplifyStd()
|
||||
{
|
||||
|
@ -8942,15 +8944,16 @@ void Tokenizer::simplifyCPPAttribute()
|
|||
}
|
||||
}
|
||||
|
||||
static const std::set<std::string> keywords = make_container< std::set<std::string> >()
|
||||
<< "volatile"
|
||||
<< "inline"
|
||||
<< "_inline"
|
||||
<< "__inline"
|
||||
<< "__forceinline"
|
||||
<< "register"
|
||||
<< "__restrict"
|
||||
<< "__restrict__" ;
|
||||
static const std::set<std::string> keywords = {
|
||||
"volatile"
|
||||
, "inline"
|
||||
, "_inline"
|
||||
, "__inline"
|
||||
, "__forceinline"
|
||||
, "register"
|
||||
, "__restrict"
|
||||
, "__restrict__"
|
||||
};
|
||||
// Remove "volatile", "inline", "register", "restrict", "override", "final", "static" and "constexpr"
|
||||
// "restrict" keyword
|
||||
// - New to 1999 ANSI/ISO C standard
|
||||
|
@ -9335,49 +9338,52 @@ void Tokenizer::simplifyBitfields()
|
|||
|
||||
|
||||
// Types and objects in std namespace that are neither functions nor templates
|
||||
static const std::set<std::string> stdTypes = make_container<std::set<std::string> >() <<
|
||||
"string"<< "wstring"<< "u16string"<< "u32string" <<
|
||||
"iostream"<< "ostream"<< "ofstream"<< "ostringstream" <<
|
||||
"istream"<< "ifstream"<< "istringstream"<< "fstream"<< "stringstream" <<
|
||||
"wstringstream"<< "wistringstream"<< "wostringstream"<< "wstringbuf" <<
|
||||
"stringbuf"<< "streambuf"<< "ios"<< "filebuf"<< "ios_base" <<
|
||||
"exception"<< "bad_exception"<< "bad_alloc" <<
|
||||
"logic_error"<< "domain_error"<< "invalid_argument_"<< "length_error" <<
|
||||
"out_of_range"<< "runtime_error"<< "range_error"<< "overflow_error"<< "underflow_error" <<
|
||||
"locale" <<
|
||||
"cout"<< "cerr"<< "clog"<< "cin" <<
|
||||
"wcerr"<< "wcin"<< "wclog"<< "wcout" <<
|
||||
"endl"<< "ends"<< "flush" <<
|
||||
"boolalpha"<< "noboolalpha"<< "showbase"<< "noshowbase" <<
|
||||
"showpoint"<< "noshowpoint"<< "showpos"<< "noshowpos" <<
|
||||
"skipws"<< "noskipws"<< "unitbuf"<< "nounitbuf"<< "uppercase"<< "nouppercase" <<
|
||||
"dec"<< "hex"<< "oct" <<
|
||||
"fixed"<< "scientific" <<
|
||||
"internal"<< "left"<< "right" <<
|
||||
"fpos"<< "streamoff"<< "streampos"<< "streamsize";
|
||||
static const std::set<std::string> stdTypes = {
|
||||
"string", "wstring", "u16string", "u32string",
|
||||
"iostream", "ostream", "ofstream", "ostringstream",
|
||||
"istream", "ifstream", "istringstream", "fstream", "stringstream",
|
||||
"wstringstream", "wistringstream", "wostringstream", "wstringbuf",
|
||||
"stringbuf", "streambuf", "ios", "filebuf", "ios_base",
|
||||
"exception", "bad_exception", "bad_alloc",
|
||||
"logic_error", "domain_error", "invalid_argument_", "length_error",
|
||||
"out_of_range", "runtime_error", "range_error", "overflow_error", "underflow_error",
|
||||
"locale",
|
||||
"cout", "cerr", "clog", "cin",
|
||||
"wcerr", "wcin", "wclog", "wcout",
|
||||
"endl", "ends", "flush",
|
||||
"boolalpha", "noboolalpha", "showbase", "noshowbase",
|
||||
"showpoint", "noshowpoint", "showpos", "noshowpos",
|
||||
"skipws", "noskipws", "unitbuf", "nounitbuf", "uppercase", "nouppercase",
|
||||
"dec", "hex", "oct",
|
||||
"fixed", "scientific",
|
||||
"internal", "left", "right",
|
||||
"fpos", "streamoff", "streampos", "streamsize"
|
||||
};
|
||||
|
||||
static const std::set<std::string> stdTemplates = make_container<std::set<std::string> >() <<
|
||||
"array"<< "basic_string"<< "bitset"<< "deque"<< "list"<< "map"<< "multimap" <<
|
||||
"priority_queue"<< "queue"<< "set"<< "multiset"<< "stack"<< "vector"<< "pair" <<
|
||||
"iterator"<< "iterator_traits" <<
|
||||
"unordered_map"<< "unordered_multimap"<< "unordered_set"<< "unordered_multiset" <<
|
||||
"tuple"<< "function";
|
||||
static const std::set<std::string> stdFunctions = make_container<std::set<std::string> >() <<
|
||||
"getline" <<
|
||||
"for_each"<< "find"<< "find_if"<< "find_end"<< "find_first_of" <<
|
||||
"adjacent_find"<< "count"<< "count_if"<< "mismatch"<< "equal"<< "search"<< "search_n" <<
|
||||
"copy"<< "copy_backward"<< "swap"<< "swap_ranges"<< "iter_swap"<< "transform"<< "replace" <<
|
||||
"replace_if"<< "replace_copy"<< "replace_copy_if"<< "fill"<< "fill_n"<< "generate"<< "generate_n"<< "remove" <<
|
||||
"remove_if"<< "remove_copy"<< "remove_copy_if" <<
|
||||
"unique"<< "unique_copy"<< "reverse"<< "reverse_copy" <<
|
||||
"rotate"<< "rotate_copy"<< "random_shuffle"<< "partition"<< "stable_partition" <<
|
||||
"sort"<< "stable_sort"<< "partial_sort"<< "partial_sort_copy"<< "nth_element" <<
|
||||
"lower_bound"<< "upper_bound"<< "equal_range"<< "binary_search"<< "merge"<< "inplace_merge"<< "includes" <<
|
||||
"set_union"<< "set_intersection"<< "set_difference" <<
|
||||
"set_symmetric_difference"<< "push_heap"<< "pop_heap"<< "make_heap"<< "sort_heap" <<
|
||||
"min"<< "max"<< "min_element"<< "max_element"<< "lexicographical_compare"<< "next_permutation"<< "prev_permutation" <<
|
||||
"advance"<< "back_inserter"<< "distance"<< "front_inserter"<< "inserter" <<
|
||||
"make_pair"<< "make_shared"<< "make_tuple";
|
||||
static const std::set<std::string> stdTemplates = {
|
||||
"array", "basic_string", "bitset", "deque", "list", "map", "multimap",
|
||||
"priority_queue", "queue", "set", "multiset", "stack", "vector", "pair",
|
||||
"iterator", "iterator_traits",
|
||||
"unordered_map", "unordered_multimap", "unordered_set", "unordered_multiset",
|
||||
"tuple", "function"
|
||||
};
|
||||
static const std::set<std::string> stdFunctions = {
|
||||
"getline",
|
||||
"for_each", "find", "find_if", "find_end", "find_first_of",
|
||||
"adjacent_find", "count", "count_if", "mismatch", "equal", "search", "search_n",
|
||||
"copy", "copy_backward", "swap", "swap_ranges", "iter_swap", "transform", "replace",
|
||||
"replace_if", "replace_copy", "replace_copy_if", "fill", "fill_n", "generate", "generate_n", "remove",
|
||||
"remove_if", "remove_copy", "remove_copy_if",
|
||||
"unique", "unique_copy", "reverse", "reverse_copy",
|
||||
"rotate", "rotate_copy", "random_shuffle", "partition", "stable_partition",
|
||||
"sort", "stable_sort", "partial_sort", "partial_sort_copy", "nth_element",
|
||||
"lower_bound", "upper_bound", "equal_range", "binary_search", "merge", "inplace_merge", "includes",
|
||||
"set_union", "set_intersection", "set_difference",
|
||||
"set_symmetric_difference", "push_heap", "pop_heap", "make_heap", "sort_heap",
|
||||
"min", "max", "min_element", "max_element", "lexicographical_compare", "next_permutation", "prev_permutation",
|
||||
"advance", "back_inserter", "distance", "front_inserter", "inserter",
|
||||
"make_pair", "make_shared", "make_tuple"
|
||||
};
|
||||
|
||||
|
||||
// Add std:: in front of std classes, when using namespace std; was given
|
||||
|
@ -9482,39 +9488,40 @@ namespace {
|
|||
std::string mbcs, unicode;
|
||||
};
|
||||
|
||||
const std::map<std::string, triplet> apis = make_container< std::map<std::string, triplet> >() <<
|
||||
std::make_pair("_topen", triplet("open", "_wopen")) <<
|
||||
std::make_pair("_tsopen_s", triplet("_sopen_s", "_wsopen_s")) <<
|
||||
std::make_pair("_tfopen", triplet("fopen", "_wfopen")) <<
|
||||
std::make_pair("_tfopen_s", triplet("fopen_s", "_wfopen_s")) <<
|
||||
std::make_pair("_tfreopen", triplet("freopen", "_wfreopen")) <<
|
||||
std::make_pair("_tfreopen_s", triplet("freopen_s", "_wfreopen_s")) <<
|
||||
std::make_pair("_tcscat", triplet("strcat", "wcscat")) <<
|
||||
std::make_pair("_tcschr", triplet("strchr", "wcschr")) <<
|
||||
std::make_pair("_tcscmp", triplet("strcmp", "wcscmp")) <<
|
||||
std::make_pair("_tcsdup", triplet("strdup", "wcsdup")) <<
|
||||
std::make_pair("_tcscpy", triplet("strcpy", "wcscpy")) <<
|
||||
std::make_pair("_tcslen", triplet("strlen", "wcslen")) <<
|
||||
std::make_pair("_tcsncat", triplet("strncat", "wcsncat")) <<
|
||||
std::make_pair("_tcsncpy", triplet("strncpy", "wcsncpy")) <<
|
||||
std::make_pair("_tcsnlen", triplet("strnlen", "wcsnlen")) <<
|
||||
std::make_pair("_tcsrchr", triplet("strrchr", "wcsrchr")) <<
|
||||
std::make_pair("_tcsstr", triplet("strstr", "wcsstr")) <<
|
||||
std::make_pair("_tcstok", triplet("strtok", "wcstok")) <<
|
||||
std::make_pair("_ftprintf", triplet("fprintf", "fwprintf")) <<
|
||||
std::make_pair("_tprintf", triplet("printf", "wprintf")) <<
|
||||
std::make_pair("_stprintf", triplet("sprintf", "swprintf")) <<
|
||||
std::make_pair("_sntprintf", triplet("_snprintf", "_snwprintf")) <<
|
||||
std::make_pair("_ftscanf", triplet("fscanf", "fwscanf")) <<
|
||||
std::make_pair("_tscanf", triplet("scanf", "wscanf")) <<
|
||||
std::make_pair("_stscanf", triplet("sscanf", "swscanf")) <<
|
||||
std::make_pair("_ftprintf_s", triplet("fprintf_s", "fwprintf_s")) <<
|
||||
std::make_pair("_tprintf_s", triplet("printf_s", "wprintf_s")) <<
|
||||
std::make_pair("_stprintf_s", triplet("sprintf_s", "swprintf_s")) <<
|
||||
std::make_pair("_sntprintf_s", triplet("_snprintf_s", "_snwprintf_s")) <<
|
||||
std::make_pair("_ftscanf_s", triplet("fscanf_s", "fwscanf_s")) <<
|
||||
std::make_pair("_tscanf_s", triplet("scanf_s", "wscanf_s")) <<
|
||||
std::make_pair("_stscanf_s", triplet("sscanf_s", "swscanf_s"));
|
||||
const std::map<std::string, triplet> apis = {
|
||||
std::make_pair("_topen", triplet("open", "_wopen")),
|
||||
std::make_pair("_tsopen_s", triplet("_sopen_s", "_wsopen_s")),
|
||||
std::make_pair("_tfopen", triplet("fopen", "_wfopen")),
|
||||
std::make_pair("_tfopen_s", triplet("fopen_s", "_wfopen_s")),
|
||||
std::make_pair("_tfreopen", triplet("freopen", "_wfreopen")),
|
||||
std::make_pair("_tfreopen_s", triplet("freopen_s", "_wfreopen_s")),
|
||||
std::make_pair("_tcscat", triplet("strcat", "wcscat")),
|
||||
std::make_pair("_tcschr", triplet("strchr", "wcschr")),
|
||||
std::make_pair("_tcscmp", triplet("strcmp", "wcscmp")),
|
||||
std::make_pair("_tcsdup", triplet("strdup", "wcsdup")),
|
||||
std::make_pair("_tcscpy", triplet("strcpy", "wcscpy")),
|
||||
std::make_pair("_tcslen", triplet("strlen", "wcslen")),
|
||||
std::make_pair("_tcsncat", triplet("strncat", "wcsncat")),
|
||||
std::make_pair("_tcsncpy", triplet("strncpy", "wcsncpy")),
|
||||
std::make_pair("_tcsnlen", triplet("strnlen", "wcsnlen")),
|
||||
std::make_pair("_tcsrchr", triplet("strrchr", "wcsrchr")),
|
||||
std::make_pair("_tcsstr", triplet("strstr", "wcsstr")),
|
||||
std::make_pair("_tcstok", triplet("strtok", "wcstok")),
|
||||
std::make_pair("_ftprintf", triplet("fprintf", "fwprintf")),
|
||||
std::make_pair("_tprintf", triplet("printf", "wprintf")),
|
||||
std::make_pair("_stprintf", triplet("sprintf", "swprintf")),
|
||||
std::make_pair("_sntprintf", triplet("_snprintf", "_snwprintf")),
|
||||
std::make_pair("_ftscanf", triplet("fscanf", "fwscanf")),
|
||||
std::make_pair("_tscanf", triplet("scanf", "wscanf")),
|
||||
std::make_pair("_stscanf", triplet("sscanf", "swscanf")),
|
||||
std::make_pair("_ftprintf_s", triplet("fprintf_s", "fwprintf_s")),
|
||||
std::make_pair("_tprintf_s", triplet("printf_s", "wprintf_s")),
|
||||
std::make_pair("_stprintf_s", triplet("sprintf_s", "swprintf_s")),
|
||||
std::make_pair("_sntprintf_s", triplet("_snprintf_s", "_snwprintf_s")),
|
||||
std::make_pair("_ftscanf_s", triplet("fscanf_s", "fwscanf_s")),
|
||||
std::make_pair("_tscanf_s", triplet("scanf_s", "wscanf_s")),
|
||||
std::make_pair("_stscanf_s", triplet("sscanf_s", "swscanf_s"))
|
||||
};
|
||||
}
|
||||
|
||||
void Tokenizer::simplifyMicrosoftStringFunctions()
|
||||
|
|
32
lib/utils.h
32
lib/utils.h
|
@ -26,38 +26,6 @@
|
|||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
/*! Helper class to aid in the initializing global const data */
|
||||
template < typename Cont >
|
||||
class make_container {
|
||||
public:
|
||||
typedef make_container< Cont > my_type;
|
||||
typedef typename Cont::value_type T;
|
||||
|
||||
my_type& operator<< (const T& val) {
|
||||
data_.insert(data_.end(), val);
|
||||
return *this;
|
||||
}
|
||||
my_type& operator<< (const Cont& other_container) {
|
||||
for (typename Cont::const_iterator it=other_container.begin(); it!=other_container.end(); ++it) {
|
||||
data_.insert(data_.end(), *it);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
my_type& operator<< (T&& val) {
|
||||
data_.insert(data_.end(), val);
|
||||
return *this;
|
||||
}
|
||||
my_type& operator<< (const char* val) {
|
||||
data_.insert(data_.end(), val);
|
||||
return *this;
|
||||
}
|
||||
operator Cont() const {
|
||||
return data_;
|
||||
}
|
||||
private:
|
||||
Cont data_;
|
||||
};
|
||||
|
||||
inline bool endsWith(const std::string &str, char c)
|
||||
{
|
||||
return str[str.size()-1U] == c;
|
||||
|
|
|
@ -798,10 +798,8 @@ private:
|
|||
bool result = si.isVariableDeclaration(list.front(), vartok, typetok);
|
||||
ASSERT_EQUALS(true, result);
|
||||
Variable v(vartok, list.front(), list.back(), 0, Public, 0, 0, &settings1.library);
|
||||
static const std::set<std::string> types = make_container< std::set<std::string> >() <<
|
||||
"string" << "wstring" ;
|
||||
static const std::set<std::string> no_types = make_container< std::set<std::string> >() <<
|
||||
"set" ;
|
||||
static const std::set<std::string> types = { "string", "wstring" };
|
||||
static const std::set<std::string> no_types = { "set" };
|
||||
ASSERT_EQUALS(true, v.isStlType());
|
||||
ASSERT_EQUALS(true, v.isStlType(types));
|
||||
ASSERT_EQUALS(false, v.isStlType(no_types));
|
||||
|
@ -816,10 +814,8 @@ private:
|
|||
bool result = si.isVariableDeclaration(list.front(), vartok, typetok);
|
||||
ASSERT_EQUALS(true, result);
|
||||
Variable v(vartok, list.front(), list.back(), 0, Public, 0, 0, &settings1.library);
|
||||
static const std::set<std::string> types = make_container< std::set<std::string> >() <<
|
||||
"bitset" << "set" << "vector" << "wstring" ;
|
||||
static const std::set<std::string> no_types = make_container< std::set<std::string> >() <<
|
||||
"bitset" << "map" << "set" ;
|
||||
static const std::set<std::string> types = { "bitset", "set", "vector", "wstring" };
|
||||
static const std::set<std::string> no_types = { "bitset", "map", "set" };
|
||||
ASSERT_EQUALS(true, v.isStlType());
|
||||
ASSERT_EQUALS(true, v.isStlType(types));
|
||||
ASSERT_EQUALS(false, v.isStlType(no_types));
|
||||
|
@ -833,8 +829,7 @@ private:
|
|||
bool result = si.isVariableDeclaration(list.front(), vartok, typetok);
|
||||
ASSERT_EQUALS(true, result);
|
||||
Variable v(vartok, list.front(), list.back(), 0, Public, 0, 0, &settings1.library);
|
||||
static const std::set<std::string> types = make_container< std::set<std::string> >() <<
|
||||
"bitset" << "set" << "vector" ;
|
||||
static const std::set<std::string> types = { "bitset", "set", "vector" };
|
||||
ASSERT_EQUALS(false, v.isStlType());
|
||||
ASSERT_EQUALS(false, v.isStlType(types));
|
||||
ASSERT_EQUALS(false, v.isStlStringType());
|
||||
|
|
Loading…
Reference in New Issue