remove c keywords when parsing function signatures

This commit is contained in:
Andrew Strelsky 2024-04-27 05:44:09 -04:00
parent e6c8f5b53c
commit 943b7b0440
No known key found for this signature in database
GPG Key ID: F33EB9033EFF4FDE

View File

@ -161,6 +161,9 @@ public class FunctionSignatureParser {
throw new ParseException("Can't parse function arguments");
}
String trailingText = newSignatureText.substring(endIndex + 1);
// remove any trailing whitespace and semicolon
trailingText = trailingText.replaceAll("\\s*;?\\s*$", "");
if (trailingText.trim().length() > 0) {
throw new ParseException(
"Unexpected trailing text at end of function: " + trailingText);
@ -192,6 +195,9 @@ public class FunctionSignatureParser {
throw new ParseException("Missing parameter");
}
// remove c keywords that Ghidra doesn't support
arg = arg.replaceAll("\\b((const)|(volatile)|(restrict)|(struct)|(union))\\b", "");
// Attempt to resolve parameter assuming only a datatype is specified
DataType dt = resolveDataType(arg);
if (dt != null) {
@ -260,6 +266,9 @@ public class FunctionSignatureParser {
throw new ParseException("Can't find return type");
}
String returnTypeName = StringUtils.join(split, " ", 0, split.length - 1);
// remove any c keywords from the return type name
returnTypeName = returnTypeName.replaceAll("\\b((static)|(inline)|(const)|(volatile)|(restrict)|(struct)|(union))\\b", "");
DataType dt = resolveDataType(returnTypeName);
if (dt == null) {