GP-6008 Changed SourceType examination to base upon priorty instead of specific value equality when appropriate

This commit is contained in:
ghidra1 2025-09-24 09:16:04 -04:00
parent edea7dfd65
commit a3bd708160
20 changed files with 131 additions and 144 deletions

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -106,8 +106,7 @@ public class SimilarSymbolNameProgramCorrelator extends VTAbstractProgramCorrela
if (!addressSet.contains(symbol.getAddress())) {
continue;
}
if (symbol.getSource() == SourceType.DEFAULT ||
symbol.getSource() == SourceType.ANALYSIS) {
if (symbol.getSource().isLowerOrEqualPriorityThan(SourceType.ANALYSIS)) {
continue;
}

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -979,38 +979,29 @@ public class FunctionSignatureStringable extends Stringable {
private boolean isFirstHigherPriorityWhenUserPriority(SourceType first, SourceType second,
boolean replaceSamePriorityNames) {
if (first == second && first != SourceType.DEFAULT) {
if (first == SourceType.DEFAULT) {
return false;
}
if (first == second) {
return replaceSamePriorityNames;
}
if (first == SourceType.USER_DEFINED) {
return (second == SourceType.IMPORTED || second == SourceType.ANALYSIS ||
second == SourceType.DEFAULT);
}
if (first == SourceType.IMPORTED) {
return (second == SourceType.ANALYSIS || second == SourceType.DEFAULT);
}
if (first == SourceType.ANALYSIS) {
return (second == SourceType.DEFAULT);
}
return false;
return first.isHigherPriorityThan(second);
}
private boolean isFirstHigherPriorityWhenImportedPriority(SourceType first, SourceType second,
boolean replaceSamePriorityNames) {
if (first == second && first != SourceType.DEFAULT) {
if (first == SourceType.DEFAULT) {
return false;
}
if (first == second) {
return replaceSamePriorityNames;
}
// NOTE: If a new SourceType is added with a priority in between IMPORTED and USER_DEFINED
// VT and this code will need to change.
if (first == SourceType.IMPORTED) {
return (second == SourceType.USER_DEFINED || second == SourceType.ANALYSIS ||
second == SourceType.DEFAULT);
return true; // IMPORTED is highest priority
}
if (first == SourceType.USER_DEFINED) {
return (second == SourceType.ANALYSIS || second == SourceType.DEFAULT);
}
if (first == SourceType.ANALYSIS) {
return (second == SourceType.DEFAULT);
}
return false;
return first.isHigherPriorityThan(second);
}
private void replaceParameterComments(Function toFunction, CommentChoices commentChoice) {