CheckHeaders: Check if all included headers are needed
This commit is contained in:
parent
0525aeb5e4
commit
abc1f6816d
|
@ -148,15 +148,45 @@ void WarningIncludeHeader()
|
||||||
else if (match(tok1,"const type * var ("))
|
else if (match(tok1,"const type * var ("))
|
||||||
funcname = getstr(tok1, 3);
|
funcname = getstr(tok1, 3);
|
||||||
|
|
||||||
|
// typedef..
|
||||||
|
std::string typedefname = "";
|
||||||
|
if (strcmp(tok1->str,"typedef")==0)
|
||||||
|
{
|
||||||
|
int parlevel = 0;
|
||||||
|
while (tok1)
|
||||||
|
{
|
||||||
|
if ( strchr("({", tok1->str[0]) )
|
||||||
|
{
|
||||||
|
parlevel++;
|
||||||
|
}
|
||||||
|
else if ( strchr("({", tok1->str[0]) )
|
||||||
|
{
|
||||||
|
parlevel--;
|
||||||
|
if (parlevel < 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if ( parlevel == 0 )
|
||||||
|
{
|
||||||
|
if (match(tok1,"var ;"))
|
||||||
|
{
|
||||||
|
typedefname = tok1->str;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (tok1->str[0] == ';')
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( varname.empty() && enumname.empty() && funcname.empty() )
|
tok1 = tok1->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( varname.empty() && enumname.empty() && funcname.empty() && typedefname.empty() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Check if the parent contains the enum/var/function..
|
varname = varname + enumname + funcname + typedefname;
|
||||||
if ( ! enumname.empty() )
|
|
||||||
varname = enumname;
|
|
||||||
else if ( ! funcname.empty() )
|
|
||||||
varname = funcname;
|
|
||||||
|
|
||||||
for (TOKEN *tok2 = tokens; tok2; tok2 = tok2->next)
|
for (TOKEN *tok2 = tokens; tok2; tok2 = tok2->next)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
#include "testh6.h"
|
||||||
|
|
||||||
|
onoff a;
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
typedef enum { on, off } onoff;
|
||||||
|
|
Loading…
Reference in New Issue