Gnu Demangler - fixed parsing of template cast to a pointer

This commit is contained in:
dragonmacher
2026-01-27 15:57:57 -05:00
parent 38d2ba6a64
commit 83059b3b8d
2 changed files with 35 additions and 1 deletions
@@ -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&)
@@ -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 {