mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GP-3371 Fixed parsing of forward declared enums and certain typedefs declared and used within a function body
This commit is contained in:
parent
1a43822637
commit
ccee80e8ad
5 changed files with 29 additions and 9 deletions
|
@ -46,7 +46,6 @@ Windows.h
|
||||||
accctrl.h
|
accctrl.h
|
||||||
aclapi.h
|
aclapi.h
|
||||||
aclui.h
|
aclui.h
|
||||||
advapi32.h
|
|
||||||
adtgen.h
|
adtgen.h
|
||||||
authz.h
|
authz.h
|
||||||
azroles.h
|
azroles.h
|
||||||
|
|
|
@ -188,7 +188,6 @@ public class CreateExampleGDTArchiveScript extends GhidraScript {
|
||||||
"accctrl.h",
|
"accctrl.h",
|
||||||
"aclapi.h",
|
"aclapi.h",
|
||||||
"aclui.h",
|
"aclui.h",
|
||||||
"advapi32.h",
|
|
||||||
"adtgen.h",
|
"adtgen.h",
|
||||||
"authz.h",
|
"authz.h",
|
||||||
"azroles.h",
|
"azroles.h",
|
||||||
|
|
|
@ -1436,8 +1436,8 @@ void TranslationUnit() : {}
|
||||||
void ExternalDeclaration() : {}
|
void ExternalDeclaration() : {}
|
||||||
{
|
{
|
||||||
(
|
(
|
||||||
LOOKAHEAD(FunctionDefinition() )
|
LOOKAHEAD( FunctionDefinition() "{" )
|
||||||
FunctionDefinition()
|
(FunctionDefinition() "{" [ StatementList() ] "}")
|
||||||
|
|
|
|
||||||
// <INLINE> FunctionDefinition()
|
// <INLINE> FunctionDefinition()
|
||||||
// |
|
// |
|
||||||
|
@ -1492,7 +1492,7 @@ void FunctionDefinition() : {
|
||||||
retDT = DeclarationSpecifiers(retDT)
|
retDT = DeclarationSpecifiers(retDT)
|
||||||
]
|
]
|
||||||
{typedefParsingStack.push(Boolean.FALSE);}
|
{typedefParsingStack.push(Boolean.FALSE);}
|
||||||
dec= Declarator(retDT, null) [ DeclarationList() ] {typedefParsingStack.pop();} CompoundStatement()
|
dec= Declarator(retDT, null) [ DeclarationList() ] {typedefParsingStack.pop();}
|
||||||
{
|
{
|
||||||
if (dec.getDataType() instanceof FunctionDefinition) {
|
if (dec.getDataType() instanceof FunctionDefinition) {
|
||||||
addDef(functions, dec.getName(), dec.getDataType());
|
addDef(functions, dec.getName(), dec.getDataType());
|
||||||
|
@ -2211,7 +2211,16 @@ DataType EnumSpecifier() : {
|
||||||
dt= addDef(enums, enumName, enuum);
|
dt= addDef(enums, enumName, enuum);
|
||||||
}
|
}
|
||||||
|
|
|
|
||||||
t= <IDENTIFIER> { dt= getEnumDef(t.image); }
|
t= <IDENTIFIER>
|
||||||
|
{
|
||||||
|
dt= getEnumDef(t.image);
|
||||||
|
if (dt == null) {
|
||||||
|
String enumName= (t != null ? t.image : ("enum_" + cnt++));
|
||||||
|
EnumDataType enuum= new EnumDataType(getCurrentCategoryPath(), enumName, 4, dtMgr);
|
||||||
|
dt= enuum;
|
||||||
|
dt= addDef(enums, enumName, enuum);
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return dt;
|
return dt;
|
||||||
|
@ -2256,6 +2265,7 @@ int Enumerator(ArrayList<EnumMember> list, int value) : {
|
||||||
if (evalue != null) {
|
if (evalue != null) {
|
||||||
value = evalue;
|
value = evalue;
|
||||||
}
|
}
|
||||||
|
list.add(new EnumMember(t.image, value));
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1278,9 +1278,11 @@ public class PreProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fis == null) {
|
if (fis == null) {
|
||||||
addParseMessage(null, "PreProcessor: File " + filename + " not found.");
|
String msg = "PreProcessor: File " + filename + " not found.";
|
||||||
|
addParseMessage(null, msg);
|
||||||
|
Msg.error(this, msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
fileStack.push(filename);
|
fileStack.push(filename);
|
||||||
alreadyDone = new HashMap<String, Integer>();
|
alreadyDone = new HashMap<String, Integer>();
|
||||||
ReInit(fis);
|
ReInit(fis);
|
||||||
|
|
|
@ -40,7 +40,7 @@ void testFunc()
|
||||||
{
|
{
|
||||||
typedef int InternFunc(int);
|
typedef int InternFunc(int);
|
||||||
|
|
||||||
// TODO InternFunc * func = (InternFunc *) 0;
|
InternFunc * func = (InternFunc *) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -920,6 +920,16 @@ enum options_enum {
|
||||||
TRINARY = (0 ? 10 : 11),
|
TRINARY = (0 ? 10 : 11),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
** Predeclare Enum
|
||||||
|
**/
|
||||||
|
|
||||||
|
typedef enum _PARAM_TYPE PARAM_TYPE;
|
||||||
|
|
||||||
|
typedef int FuncUseEnum(PARAM_TYPE ptype);
|
||||||
|
|
||||||
|
typedef enum _PARAM_TYPE { A, B, C } PARAM_TYPE;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** Casting
|
** Casting
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue