GP-1 Always use BadDataType.datatype instance

This commit is contained in:
ghidra1 2025-07-10 12:04:01 -04:00
parent 894e65589a
commit 8938cc3478
2 changed files with 9 additions and 21 deletions

View file

@ -158,7 +158,6 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
private LinkedList<Long> idsToDelete = new LinkedList<>();
private LinkedList<Pair<DataType, DataType>> typesToReplace = new LinkedList<>();
private List<DataType> favoritesList = new ArrayList<>();
private BadDataType myBadDataType = new BadDataType(this);
/**
* Set of {@link AbstractIntegerDataType} IDs whose removal has been blocked
@ -1242,7 +1241,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
if (dataType instanceof BadDataType) {
// Avoid adding BAD data type to the manager which
// will appear when needed for a missing datatype
return myBadDataType;
return BadDataType.dataType;
}
if (dataType instanceof BitFieldDataType) {
@ -2301,7 +2300,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
return DataType.DEFAULT;
}
if (dataTypeID == BAD_DATATYPE_ID) {
return myBadDataType;
return BadDataType.dataType;
}
return getDataType(dataTypeID, null);
}

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.
@ -17,26 +17,23 @@ package ghidra.program.model.data;
import ghidra.docking.settings.Settings;
import ghidra.program.model.mem.MemBuffer;
import ghidra.util.classfinder.ClassSearcher;
/**
* Provides an implementation of a data type that is not valid (bad) as it is used in
* the program. For example, the class for the underlying data type may no longer be
* available or the data type may not fit where it has been placed in the program.
* <P>
* This field is not meant to be loaded by the {@link ClassSearcher}, hence the X in the name.
*/
public class BadDataType extends BuiltIn implements Dynamic {
private final static long serialVersionUID = 1;
public static final BadDataType dataType = new BadDataType();
public BadDataType() {
this(null);
private BadDataType() {
super(CategoryPath.ROOT, "-BAD-", null);
}
public BadDataType(DataTypeManager dtm) {
super(null, "-BAD-", dtm);
@Override
public DataType clone(DataTypeManager dtm) {
return this;
}
/**
@ -89,14 +86,6 @@ public class BadDataType extends BuiltIn implements Dynamic {
return getDescription();
}
@Override
public DataType clone(DataTypeManager dtm) {
if (dtm == getDataTypeManager()) {
return this;
}
return new BadDataType(dtm);
}
@Override
public boolean canSpecifyLength() {
return true;