Minor updates:
* Refactoring. * don't warn for 'memset(this,..'
This commit is contained in:
parent
476d424712
commit
b4d5ee5d15
27
main.cpp
27
main.cpp
|
@ -48,6 +48,8 @@ void WarningRedundantCode();
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void CppCheck(const char FileName[]);
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
|
@ -56,8 +58,16 @@ int main(int argc, char* argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CppCheck(argv[argc - 1]);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CppCheck(const char FileName[])
|
||||||
|
{
|
||||||
tokens = tokens_back = NULL;
|
tokens = tokens_back = NULL;
|
||||||
Tokenize(argv[argc - 1]);
|
Files.clear();
|
||||||
|
Tokenize(FileName);
|
||||||
|
|
||||||
//std::ofstream f("tokens.txt");
|
//std::ofstream f("tokens.txt");
|
||||||
//for (TOKEN *tok = tokens; tok; tok = tok->next)
|
//for (TOKEN *tok = tokens; tok; tok = tok->next)
|
||||||
|
@ -90,7 +100,14 @@ int main(int argc, char* argv[])
|
||||||
// if (a) delete a;
|
// if (a) delete a;
|
||||||
WarningRedundantCode();
|
WarningRedundantCode();
|
||||||
|
|
||||||
return 0;
|
// Clean up tokens..
|
||||||
|
while (tokens)
|
||||||
|
{
|
||||||
|
TOKEN *next = tokens->next;
|
||||||
|
free(tokens->str);
|
||||||
|
delete tokens;
|
||||||
|
tokens = next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -810,9 +827,15 @@ void CheckMemset()
|
||||||
else if (match(tok, "memset ( & var , num , sizeof ( struct type ) )"))
|
else if (match(tok, "memset ( & var , num , sizeof ( struct type ) )"))
|
||||||
type = getstr(tok, 10);
|
type = getstr(tok, 10);
|
||||||
|
|
||||||
|
// No type defined => The tokens didn't match
|
||||||
if (!(type && type[0]))
|
if (!(type && type[0]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// It will be assumed that memset can be used upon 'this'.
|
||||||
|
// Todo: Check this too
|
||||||
|
if (strcmp(getstr(tok,2),"this") == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
// Warn if type is a class..
|
// Warn if type is a class..
|
||||||
const char *pattern1[] = {"class","",NULL};
|
const char *pattern1[] = {"class","",NULL};
|
||||||
pattern1[1] = type;
|
pattern1[1] = type;
|
||||||
|
|
Loading…
Reference in New Issue