Skip to content

Commit cc37fd3

Browse files
committed
Merge remote-tracking branch
'origin/GP-1-dragonmacher-gnu-demangler-template-pointer-cast' into patch (#8900)
2 parents 38d2ba6 + 83059b3 commit cc37fd3

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

Ghidra/Features/GnuDemangler/src/main/java/ghidra/app/util/demangler/gnu/GnuDemanglerParser.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,27 @@ public class GnuDemanglerParser {
162162
* --the text can have "::" namespace separators (non-capturing group) and
163163
* must be followed by more text
164164
* --the text can have multiple words, such as (unsigned long)
165+
* --the text may be followed by 0 or more asterisks
166+
*
167+
* \(
168+
* (?:\\w+\s)* non-capturing letters with a space, optional
169+
* \\w+[*]* 1 or more letters
170+
* [*]* optional asterisk
171+
* (?:::\w+[*]*)* namespace delimiter with 1 or more word characters, optional
172+
* [*]* optional asterisk
173+
* \)
174+
*
175+
* \s* optional space
176+
* -{0,1} 0 or 1 minus sign
177+
* \\w+ 1 or more letters
178+
*
165179
* -optional space
166180
* -optional '-' character (a negative sign character)
167181
* -followed by more text (with optional spaces)
168182
* </pre>
169183
*/
170184
private static final Pattern CAST_PATTERN =
171-
Pattern.compile("\\((?:\\w+\\s)*\\w+(?:::\\w+)*\\)\\s*-{0,1}\\w+");
185+
Pattern.compile("\\((?:\\w+\\s)*\\w+[*]*(?:::\\w+[*]*)*\\)\\s*-{0,1}\\w+");
172186

173187
/*
174188
* Sample: Magick::operator<(Magick::Coordinate const&, Magick::Coordinate const&)

Ghidra/Features/GnuDemangler/src/test/java/ghidra/app/util/demangler/GnuDemanglerParserTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,26 @@ public void testParse_CastInTemplates_WithNegativeNumber() throws Exception {
107107
object.getSignature(false));
108108
}
109109

110+
@Test
111+
public void testParse_CastInTemplates_ToPointer() throws Exception {
112+
113+
String mangled =
114+
"_ZN3ndk4impl15ScopedAResourceIP7AStatusXadL_Z14AStatus_deleteEELS3_0EEaSEOS4_";
115+
String demangled = process.demangle(mangled);
116+
assertEquals(
117+
"ndk::impl::ScopedAResource<AStatus*, &AStatus_delete, (AStatus*)0>::operator=(ndk::impl::ScopedAResource<AStatus*, &AStatus_delete, (AStatus*)0>&&)",
118+
demangled);
119+
120+
DemangledObject object = parser.parse(mangled, demangled);
121+
assertType(object, DemangledFunction.class);
122+
assertName(object, "operator=", "ndk", "impl",
123+
"ScopedAResource<AStatus*,&AStatus_delete,(AStatus*)0>");
124+
125+
assertEquals(
126+
"undefined ndk::impl::ScopedAResource<AStatus*,&AStatus_delete,(AStatus*)0>::operator=(ndk::impl::ScopedAResource<AStatus *,&AStatus_delete,(AStatus*)0> &&)",
127+
object.getSignature(false));
128+
}
129+
110130
@Test
111131
public void testParse_MultiDimensionalArray() throws Exception {
112132

0 commit comments

Comments
 (0)