mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-07 13:30:45 -05:00
Gnu Demangler - fixed parsing of template cast to a pointer
This commit is contained in:
+15
-1
@@ -162,13 +162,27 @@ public class GnuDemanglerParser {
|
||||
* --the text can have "::" namespace separators (non-capturing group) and
|
||||
* must be followed by more text
|
||||
* --the text can have multiple words, such as (unsigned long)
|
||||
* --the text may be followed by 0 or more asterisks
|
||||
*
|
||||
* \(
|
||||
* (?:\\w+\s)* non-capturing letters with a space, optional
|
||||
* \\w+[*]* 1 or more letters
|
||||
* [*]* optional asterisk
|
||||
* (?:::\w+[*]*)* namespace delimiter with 1 or more word characters, optional
|
||||
* [*]* optional asterisk
|
||||
* \)
|
||||
*
|
||||
* \s* optional space
|
||||
* -{0,1} 0 or 1 minus sign
|
||||
* \\w+ 1 or more letters
|
||||
*
|
||||
* -optional space
|
||||
* -optional '-' character (a negative sign character)
|
||||
* -followed by more text (with optional spaces)
|
||||
* </pre>
|
||||
*/
|
||||
private static final Pattern CAST_PATTERN =
|
||||
Pattern.compile("\\((?:\\w+\\s)*\\w+(?:::\\w+)*\\)\\s*-{0,1}\\w+");
|
||||
Pattern.compile("\\((?:\\w+\\s)*\\w+[*]*(?:::\\w+[*]*)*\\)\\s*-{0,1}\\w+");
|
||||
|
||||
/*
|
||||
* Sample: Magick::operator<(Magick::Coordinate const&, Magick::Coordinate const&)
|
||||
|
||||
+20
@@ -107,6 +107,26 @@ public class GnuDemanglerParserTest extends AbstractGenericTest {
|
||||
object.getSignature(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse_CastInTemplates_ToPointer() throws Exception {
|
||||
|
||||
String mangled =
|
||||
"_ZN3ndk4impl15ScopedAResourceIP7AStatusXadL_Z14AStatus_deleteEELS3_0EEaSEOS4_";
|
||||
String demangled = process.demangle(mangled);
|
||||
assertEquals(
|
||||
"ndk::impl::ScopedAResource<AStatus*, &AStatus_delete, (AStatus*)0>::operator=(ndk::impl::ScopedAResource<AStatus*, &AStatus_delete, (AStatus*)0>&&)",
|
||||
demangled);
|
||||
|
||||
DemangledObject object = parser.parse(mangled, demangled);
|
||||
assertType(object, DemangledFunction.class);
|
||||
assertName(object, "operator=", "ndk", "impl",
|
||||
"ScopedAResource<AStatus*,&AStatus_delete,(AStatus*)0>");
|
||||
|
||||
assertEquals(
|
||||
"undefined ndk::impl::ScopedAResource<AStatus*,&AStatus_delete,(AStatus*)0>::operator=(ndk::impl::ScopedAResource<AStatus *,&AStatus_delete,(AStatus*)0> &&)",
|
||||
object.getSignature(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse_MultiDimensionalArray() throws Exception {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user