Merge remote-tracking branch 'origin/GP-1602-dragonmacher-decompiler-brace-stack-trace'

This commit is contained in:
Ryan Kurtz 2021-12-15 07:31:03 -05:00
commit 0fc8055c77

View file

@ -354,8 +354,7 @@ public class DecompilerUtils {
public static AddressSet findClosestAddressSet(Program program, AddressSpace functionSpace,
List<ClangToken> tokenList) {
AddressSet addressSet = new AddressSet();
for (int i = 0; i < tokenList.size(); ++i) {
ClangToken tok = tokenList.get(i);
for (ClangToken tok : tokenList) {
addTokenAddressRangeToSet(addressSet, tok, functionSpace);
}
@ -574,12 +573,19 @@ public class DecompilerUtils {
}
Stack<ClangSyntaxToken> braceStack = new Stack<>();
for (int i = 0; i < list.size(); ++i) {
ClangToken token = (ClangToken) list.get(i);
if (token instanceof ClangSyntaxToken) {
ClangSyntaxToken syntaxToken = (ClangSyntaxToken) token;
for (ClangNode element : list) {
ClangToken token = (ClangToken) element;
if (!(token instanceof ClangSyntaxToken)) {
continue;
}
ClangSyntaxToken syntaxToken = (ClangSyntaxToken) token;
if (startToken == syntaxToken) {
if (braceStack.isEmpty()) {
return null; // this can happen if the start token has a bad parent values
}
// found our starting token, take the current value on the stack
ClangSyntaxToken matchingBrace = braceStack.pop();
return matchingBrace;
@ -602,7 +608,6 @@ public class DecompilerUtils {
braceStack.push(syntaxToken);
}
}
}
return null;
}