summaryrefslogtreecommitdiff
path: root/lang
diff options
context:
space:
mode:
authorRusty Wagner <rusty.wagner@gmail.com>2025-06-24 17:55:48 -0400
committerAlexander Taylor <alex@vector35.com>2025-06-25 18:36:47 -0400
commitc41f264a1dba68c89b4a224a70e3a5783f7fa879 (patch)
tree00bb6e91d86b708bff7265ed7179a6ef2793b7fb /lang
parentb1a7666164a000c5255f90568ed9597b58ce276a (diff)
Remove implicit conversions from Confidence to underlying type, these can cause bugs and also issues with C++20
Diffstat (limited to 'lang')
-rw-r--r--lang/c/pseudoc.cpp63
-rw-r--r--lang/c/pseudoobjc.cpp6
-rw-r--r--lang/rust/pseudorust.cpp83
-rw-r--r--lang/rust/rusttypes.cpp20
4 files changed, 87 insertions, 85 deletions
diff --git a/lang/c/pseudoc.cpp b/lang/c/pseudoc.cpp
index 14a82e9e..86a7b9db 100644
--- a/lang/c/pseudoc.cpp
+++ b/lang/c/pseudoc.cpp
@@ -60,11 +60,11 @@ BNSymbolDisplayResult PseudoCFunction::AppendPointerTextToken(const HighLevelILI
vector<InstructionTextToken>& tokens, DisassemblySettings* settings, BNSymbolDisplayType symbolDisplay, BNOperatorPrecedence precedence)
{
Confidence<Ref<Type>> type = instr.GetType();
- if (type && (type->GetClass() == PointerTypeClass) && type->IsConst())
+ if (type.GetValue() && (type->GetClass() == PointerTypeClass) && type->IsConst())
{
string stringValue;
size_t childWidth = 0;
- if (auto child = type->GetChildType(); child)
+ if (auto child = type->GetChildType(); child.GetValue())
childWidth = child->GetWidth();
if (auto strType = GetFunction()->GetView()->CheckForStringAnnotationType(val, stringValue, false, false, childWidth); strType.has_value())
{
@@ -87,8 +87,9 @@ BNSymbolDisplayResult PseudoCFunction::AppendPointerTextToken(const HighLevelILI
{
// If the pointer has a value of 0, check if it points to a valid address by
// 1. If the binary is relocatable, assign the pointer as nullptr
- // 2. else, check if the constant zero which being referenced is a pointer(display as symbol) or not(display as nullptr)
- if(val == 0x0 && type && (type->GetClass() == PointerTypeClass))
+ // 2. else, check if the constant zero which being referenced is a pointer(display as symbol) or not(display as
+ // nullptr)
+ if (val == 0x0 && type.GetValue() && (type->GetClass() == PointerTypeClass))
{
if (GetFunction()->GetView()->IsRelocatable())
{
@@ -292,10 +293,10 @@ void PseudoCFunction::AppendTwoOperand(const string& operand, const HighLevelILI
if (leftExpr.operation == HLIL_VAR && (operand == " + " || operand == " - "))
{
const auto variableType = GetFunction()->GetVariableType(leftExpr.GetVariable());
- if (variableType)
+ if (variableType.GetValue())
{
const auto childType = variableType->GetChildType();
- if (variableType->IsPointer() && childType && childType->GetWidth() != 1)
+ if (variableType->IsPointer() && childType.GetValue() && childType->GetWidth() != 1)
{
emitter.AppendOpenParen();
emitter.Append(TypeNameToken, "char");
@@ -542,12 +543,12 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
// complex expression can cause the process to crash from a stack overflow.
auto exprGuard = tokens.SetCurrentExpr(instr);
- if (settings && settings->IsOptionSet(ShowILTypes) && instr.GetType())
+ if (settings && settings->IsOptionSet(ShowILTypes) && instr.GetType().GetValue())
{
tokens.AppendOpenParen();
tokens.AppendOpenParen();
auto typeTokens = GetTypePrinter()->GetTypeTokens(
- instr.GetType(), GetArchitecture()->GetStandalonePlatform(), QualifiedName());
+ instr.GetType().GetValue(), GetArchitecture()->GetStandalonePlatform(), QualifiedName());
for (auto& token: typeTokens)
{
tokens.Append(token);
@@ -1004,11 +1005,13 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
const auto variableType = GetHighLevelILFunction()->GetFunction()->GetVariableType(destExpr);
const auto platform = GetHighLevelILFunction()->GetFunction()->GetPlatform();
- const auto prevTypeTokens = variableType ?
- GetTypePrinter()->GetTypeTokensBeforeName(variableType, platform, variableType.GetConfidence()) :
+ const auto prevTypeTokens = variableType.GetValue() ?
+ GetTypePrinter()->GetTypeTokensBeforeName(
+ variableType.GetValue(), platform, variableType.GetConfidence()) :
vector<InstructionTextToken> {};
- const auto postTypeTokens = variableType ?
- GetTypePrinter()->GetTypeTokensAfterName(variableType, platform, variableType.GetConfidence()) :
+ const auto postTypeTokens = variableType.GetValue() ?
+ GetTypePrinter()->GetTypeTokensAfterName(
+ variableType.GetValue(), platform, variableType.GetConfidence()) :
vector<InstructionTextToken> {};
// Check to see if the variable appears live
@@ -1023,7 +1026,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
if (appearsDead)
tokens.BeginForceZeroConfidence();
- if (variableType)
+ if (variableType.GetValue())
{
for (auto typeToken: prevTypeTokens)
{
@@ -1034,7 +1037,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.Append(TextToken, " ");
}
tokens.AppendVarTextToken(destExpr, instr, instr.size);
- if (variableType)
+ if (variableType.GetValue())
{
for (auto typeToken: postTypeTokens)
{
@@ -1068,14 +1071,16 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
const auto variableType = GetHighLevelILFunction()->GetFunction()->GetVariableType(variable);
const auto platform = GetHighLevelILFunction()->GetFunction()->GetPlatform();
- const auto prevTypeTokens = variableType ?
- GetTypePrinter()->GetTypeTokensBeforeName(variableType, platform, variableType.GetConfidence()) :
+ const auto prevTypeTokens = variableType.GetValue() ?
+ GetTypePrinter()->GetTypeTokensBeforeName(
+ variableType.GetValue(), platform, variableType.GetConfidence()) :
vector<InstructionTextToken> {};
- const auto postTypeTokens = variableType ?
- GetTypePrinter()->GetTypeTokensAfterName(variableType, platform, variableType.GetConfidence()) :
+ const auto postTypeTokens = variableType.GetValue() ?
+ GetTypePrinter()->GetTypeTokensAfterName(
+ variableType.GetValue(), platform, variableType.GetConfidence()) :
vector<InstructionTextToken> {};
- if (variableType)
+ if (variableType.GetValue())
{
for (auto typeToken: prevTypeTokens)
{
@@ -1086,7 +1091,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.Append(TextToken, " ");
}
tokens.AppendVarTextToken(variable, instr, instr.size);
- if (variableType)
+ if (variableType.GetValue())
{
for (auto typeToken: postTypeTokens)
{
@@ -1549,7 +1554,8 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
}
else if ((!settings || settings->IsOptionSet(ShowTypeCasts)) && srcExpr.operation == HLIL_VAR)
{
- if (srcExpr.GetType() && srcExpr.GetType()->GetClass() != StructureTypeClass && srcExpr.size > instr.size)
+ if (srcExpr.GetType().GetValue() && srcExpr.GetType()->GetClass() != StructureTypeClass
+ && srcExpr.size > instr.size)
{
tokens.AppendOpenParen();
AppendSizeToken(instr.size, false, tokens);
@@ -1603,7 +1609,8 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
if (AppendPointerTextToken(instr, constant, pointerTokens, settings, DereferenceNonDataSymbols, precedence) == DataSymbolResult)
{
const auto type = srcExpr.GetType();
- if (type && type->GetClass() == PointerTypeClass && instr.size != type->GetChildType()->GetWidth())
+ if (type.GetValue() && type->GetClass() == PointerTypeClass
+ && instr.size != type->GetChildType()->GetWidth())
{
if (!settings || settings->IsOptionSet(ShowTypeCasts))
{
@@ -1948,9 +1955,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
auto var = left.GetVariable<HLIL_VAR>();
auto srcOffset = right.GetConstant<HLIL_CONST>();
auto varType = GetFunction()->GetVariableType(var);
- if (varType
- && varType->GetClass() == PointerTypeClass
- && varType->GetNamedTypeReference()
+ if (varType.GetValue() && varType->GetClass() == PointerTypeClass && varType->GetNamedTypeReference()
&& varType->GetOffset() == srcOffset)
{
// Yes
@@ -2743,7 +2748,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
break;
}
- if (settings && settings->IsOptionSet(ShowILTypes) && instr.GetType())
+ if (settings && settings->IsOptionSet(ShowILTypes) && instr.GetType().GetValue())
{
tokens.AppendCloseParen();
}
@@ -2757,7 +2762,7 @@ void PseudoCFunction::GetExpr_CALL_OR_TAILCALL(const BinaryNinja::HighLevelILIns
const auto parameterExprs = instr.GetParameterExprs();
vector<FunctionParameter> namedParams;
- Ref<Type> functionType = destExpr.GetType();
+ Ref<Type> functionType = destExpr.GetType().GetValue();
if (functionType && (functionType->GetClass() == PointerTypeClass)
&& (functionType->GetChildType()->GetClass() == FunctionTypeClass))
namedParams = functionType->GetChildType()->GetParameters();
@@ -2777,9 +2782,9 @@ void PseudoCFunction::GetExpr_CALL_OR_TAILCALL(const BinaryNinja::HighLevelILIns
if (index < namedParams.size() && parameterExprs[index].operation == HLIL_CONST_PTR)
{
auto exprType = namedParams[index].type;
- if (exprType && (exprType->GetClass() == PointerTypeClass))
+ if (exprType.GetValue() && (exprType->GetClass() == PointerTypeClass))
{
- if (auto child = exprType->GetChildType(); child)
+ if (auto child = exprType->GetChildType(); child.GetValue())
{
if ((child->IsInteger() && child->IsSigned() && child->GetWidth() == 1) || child->IsWideChar())
{
diff --git a/lang/c/pseudoobjc.cpp b/lang/c/pseudoobjc.cpp
index c832e388..c76eabac 100644
--- a/lang/c/pseudoobjc.cpp
+++ b/lang/c/pseudoobjc.cpp
@@ -21,7 +21,7 @@ bool ParameterIsString(const HighLevelILInstruction& expr)
if (!exprType || exprType->GetClass() != PointerTypeClass)
return false;
- if (auto child = exprType->GetChildType(); child)
+ if (auto child = exprType->GetChildType(); child.GetValue())
{
child = child->IsArray() ? child->GetChildType() : child;
return child->IsInteger() && child->IsSigned() && child->GetWidth() == 1;
@@ -215,7 +215,7 @@ bool VariableIsObjCSuperStruct(const Variable& variable, Function& function)
if (variableName != "super")
return false;
- const auto variableType = TypeResolvingNamedTypeReference(function.GetVariableType(variable), function);
+ const auto variableType = TypeResolvingNamedTypeReference(function.GetVariableType(variable).GetValue(), function);
if (!variableType || variableType->GetClass() != StructureTypeClass)
return false;
@@ -453,7 +453,7 @@ void PseudoObjCFunction::GetExpr_CONST_PTR(const BinaryNinja::HighLevelILInstruc
if (!hasVariable)
return PseudoCFunction::GetExpr_CONST_PTR(instr, tokens, settings, precedence, statement);
- auto type = TypeResolvingNamedTypeReference(variable.type, *GetFunction());
+ auto type = TypeResolvingNamedTypeReference(variable.type.GetValue(), *GetFunction());
if (!type || type->GetClass() != StructureTypeClass)
return PseudoCFunction::GetExpr_CONST_PTR(instr, tokens, settings, precedence, statement);
diff --git a/lang/rust/pseudorust.cpp b/lang/rust/pseudorust.cpp
index 380be7c6..2f9b751c 100644
--- a/lang/rust/pseudorust.cpp
+++ b/lang/rust/pseudorust.cpp
@@ -62,11 +62,11 @@ BNSymbolDisplayResult PseudoRustFunction::AppendPointerTextToken(const HighLevel
vector<InstructionTextToken>& tokens, DisassemblySettings* settings, BNSymbolDisplayType symbolDisplay, BNOperatorPrecedence precedence)
{
Confidence<Ref<Type>> type = instr.GetType();
- if (type && (type->GetClass() == PointerTypeClass) && type->IsConst())
+ if (type.GetValue() && (type->GetClass() == PointerTypeClass) && type->IsConst())
{
string stringValue;
size_t childWidth = 0;
- if (auto child = type->GetChildType(); child)
+ if (auto child = type->GetChildType(); child.GetValue())
childWidth = child->GetWidth();
if (auto strType = GetFunction()->GetView()->CheckForStringAnnotationType(val, stringValue, false, false, childWidth); strType.has_value())
{
@@ -89,8 +89,9 @@ BNSymbolDisplayResult PseudoRustFunction::AppendPointerTextToken(const HighLevel
{
// If the pointer has a value of 0, check if it points to a valid address by
// 1. If the binary is relocatable, assign the pointer as nullptr
- // 2. else, check if the constant zero which being referenced is a pointer(display as symbol) or not(display as nullptr)
- if(val == 0x0 && type && (type->GetClass() == PointerTypeClass))
+ // 2. else, check if the constant zero which being referenced is a pointer(display as symbol) or not(display as
+ // nullptr)
+ if (val == 0x0 && type.GetValue() && (type->GetClass() == PointerTypeClass))
{
if (GetFunction()->GetView()->IsRelocatable())
{
@@ -312,7 +313,7 @@ void PseudoRustFunction::AppendTwoOperand(const string& operand, const HighLevel
if (operand == " + " || operand == " - ")
{
const auto exprType = leftExpr.GetType();
- if (exprType && exprType->IsPointer())
+ if (exprType.GetValue() && exprType->IsPointer())
{
GetExprText(leftExpr, emitter, settings, MemberAndFunctionOperatorPrecedence);
emitter.Append(TextToken, ".");
@@ -597,16 +598,13 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
// complex expression can cause the process to crash from a stack overflow.
auto exprGuard = tokens.SetCurrentExpr(instr);
- if (settings && settings->IsOptionSet(ShowILTypes) && instr.GetType())
+ if (settings && settings->IsOptionSet(ShowILTypes) && instr.GetType().GetValue())
{
tokens.AppendOpenParen();
tokens.AppendOpenParen();
RustTypePrinter printer;
auto typeTokens = printer.GetTypeTokens(
- instr.GetType(),
- GetArchitecture()->GetStandalonePlatform(),
- QualifiedName()
- );
+ instr.GetType().GetValue(), GetArchitecture()->GetStandalonePlatform(), QualifiedName());
for (auto& token: typeTokens)
{
tokens.Append(token);
@@ -1035,7 +1033,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
tokens.AppendOpenParen();
vector<FunctionParameter> namedParams;
- Ref<Type> functionType = instr.GetDestExpr<HLIL_CALL>().GetType();
+ Ref<Type> functionType = instr.GetDestExpr<HLIL_CALL>().GetType().GetValue();
if (functionType && (functionType->GetClass() == PointerTypeClass)
&& (functionType->GetChildType()->GetClass() == FunctionTypeClass))
namedParams = functionType->GetChildType()->GetParameters();
@@ -1051,9 +1049,9 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
if (index < namedParams.size() && parameterExprs[index].operation == HLIL_CONST_PTR)
{
auto exprType = namedParams[index].type;
- if (exprType && (exprType->GetClass() == PointerTypeClass))
+ if (exprType.GetValue() && (exprType->GetClass() == PointerTypeClass))
{
- if (auto child = exprType->GetChildType(); child)
+ if (auto child = exprType->GetChildType(); child.GetValue())
{
if ((child->IsInteger() && child->IsSigned() && child->GetWidth() == 1)
|| child->IsWideChar())
@@ -1118,11 +1116,11 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto variableType = GetHighLevelILFunction()->GetFunction()->GetVariableType(destExpr);
const auto platform = GetHighLevelILFunction()->GetFunction()->GetPlatform();
RustTypePrinter printer;
- const auto prevTypeTokens = variableType ?
- printer.GetTypeTokensBeforeName(variableType, platform, variableType.GetConfidence()) :
+ const auto prevTypeTokens = variableType.GetValue() ?
+ printer.GetTypeTokensBeforeName(variableType.GetValue(), platform, variableType.GetConfidence()) :
vector<InstructionTextToken> {};
- const auto postTypeTokens = variableType ?
- printer.GetTypeTokensAfterName(variableType, platform, variableType.GetConfidence()) :
+ const auto postTypeTokens = variableType.GetValue() ?
+ printer.GetTypeTokensAfterName(variableType.GetValue(), platform, variableType.GetConfidence()) :
vector<InstructionTextToken> {};
// Check to see if the variable appears live
@@ -1143,7 +1141,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
if (IsMutable(destExpr))
tokens.Append(KeywordToken, "mut ");
- if (variableType)
+ if (variableType.GetValue())
{
for (auto typeToken : prevTypeTokens)
{
@@ -1153,7 +1151,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
}
}
tokens.AppendVarTextToken(destExpr, instr, instr.size);
- if (variableType)
+ if (variableType.GetValue())
{
for (auto typeToken : postTypeTokens)
{
@@ -1188,14 +1186,12 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto variableType = GetHighLevelILFunction()->GetFunction()->GetVariableType(variable);
const auto platform = GetHighLevelILFunction()->GetFunction()->GetPlatform();
RustTypePrinter printer;
- const auto prevTypeTokens =
- variableType ?
- printer.GetTypeTokensBeforeName(variableType, platform, variableType.GetConfidence()) :
- vector<InstructionTextToken>{};
- const auto postTypeTokens =
- variableType ?
- printer.GetTypeTokensAfterName(variableType, platform, variableType.GetConfidence()) :
- vector<InstructionTextToken>{};
+ const auto prevTypeTokens = variableType.GetValue() ?
+ printer.GetTypeTokensBeforeName(variableType.GetValue(), platform, variableType.GetConfidence()) :
+ vector<InstructionTextToken> {};
+ const auto postTypeTokens = variableType.GetValue() ?
+ printer.GetTypeTokensAfterName(variableType.GetValue(), platform, variableType.GetConfidence()) :
+ vector<InstructionTextToken> {};
tokens.Append(KeywordToken, "let ");
@@ -1203,7 +1199,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
if (IsMutable(variable))
tokens.Append(KeywordToken, "mut ");
- if (variableType)
+ if (variableType.GetValue())
{
for (auto typeToken: prevTypeTokens)
{
@@ -1213,7 +1209,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
}
}
tokens.AppendVarTextToken(variable, instr, instr.size);
- if (variableType)
+ if (variableType.GetValue())
{
for (auto typeToken: postTypeTokens)
{
@@ -1628,7 +1624,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
{
tokens.Append(KeywordToken, " as ");
tokens.Append(TextToken, "*");
- Ref<Type> srcType = srcExpr.GetType();
+ Ref<Type> srcType = srcExpr.GetType().GetValue();
if (srcType && srcType->IsPointer() && srcType->GetChildType()->IsConst())
tokens.Append(KeywordToken, "const ");
else
@@ -1658,7 +1654,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
{
tokens.Append(KeywordToken, " as ");
tokens.Append(TextToken, "*");
- Ref<Type> srcType = srcExpr.GetType();
+ Ref<Type> srcType = srcExpr.GetType().GetValue();
if (srcType && srcType->IsPointer() && srcType->GetChildType()->IsConst())
tokens.Append(KeywordToken, "const ");
else
@@ -1691,7 +1687,8 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
}
else if ((!settings || settings->IsOptionSet(ShowTypeCasts)) && srcExpr.operation == HLIL_VAR)
{
- if (srcExpr.GetType() && srcExpr.GetType()->GetClass() != StructureTypeClass && srcExpr.size > instr.size)
+ if (srcExpr.GetType().GetValue() && srcExpr.GetType()->GetClass() != StructureTypeClass
+ && srcExpr.size > instr.size)
{
GetExprText(srcExpr, tokens, settings, MemberAndFunctionOperatorPrecedence);
tokens.Append(KeywordToken, " as ");
@@ -1745,14 +1742,16 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto type = srcExpr.GetType();
BNOperatorPrecedence srcPrecedence = UnaryOperatorPrecedence;
- if (type && type->GetClass() == PointerTypeClass && instr.size != type->GetChildType()->GetWidth() &&
- (!settings || settings->IsOptionSet(ShowTypeCasts)))
+ if (type.GetValue() && type->GetClass() == PointerTypeClass
+ && instr.size != type->GetChildType()->GetWidth()
+ && (!settings || settings->IsOptionSet(ShowTypeCasts)))
srcPrecedence = LowUnaryOperatorPrecedence;
vector<InstructionTextToken> pointerTokens{};
if (AppendPointerTextToken(instr, constant, pointerTokens, settings, DereferenceNonDataSymbols, srcPrecedence) == DataSymbolResult)
{
- if (type && type->GetClass() == PointerTypeClass && instr.size != type->GetChildType()->GetWidth())
+ if (type.GetValue() && type->GetClass() == PointerTypeClass
+ && instr.size != type->GetChildType()->GetWidth())
{
tokens.Append(OperationToken, "*");
if (!settings || settings->IsOptionSet(ShowTypeCasts))
@@ -1767,7 +1766,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
{
tokens.Append(KeywordToken, " as ");
tokens.Append(TextToken, "*");
- Ref<Type> srcType = srcExpr.GetType();
+ Ref<Type> srcType = srcExpr.GetType().GetValue();
if (srcType && srcType->IsPointer() && srcType->GetChildType()->IsConst())
tokens.Append(KeywordToken, "const ");
else
@@ -2052,7 +2051,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto leftType = instr.GetLeftExpr().GetType();
bool parens;
BNOperatorPrecedence opPrecedence = AddOperatorPrecedence;
- if (leftType && leftType->IsPointer())
+ if (leftType.GetValue() && leftType->IsPointer())
{
parens = false;
opPrecedence = MemberAndFunctionOperatorPrecedence;
@@ -2084,9 +2083,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
auto var = left.GetVariable<HLIL_VAR>();
auto srcOffset = right.GetConstant<HLIL_CONST>();
auto varType = GetFunction()->GetVariableType(var);
- if (varType
- && varType->GetClass() == PointerTypeClass
- && varType->GetNamedTypeReference()
+ if (varType.GetValue() && varType->GetClass() == PointerTypeClass && varType->GetNamedTypeReference()
&& varType->GetOffset() == srcOffset)
{
// Yes
@@ -2101,7 +2098,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto leftType = instr.GetLeftExpr().GetType();
bool parens;
BNOperatorPrecedence opPrecedence = SubOperatorPrecedence;
- if (leftType && leftType->IsPointer())
+ if (leftType.GetValue() && leftType->IsPointer())
{
parens = false;
opPrecedence = MemberAndFunctionOperatorPrecedence;
@@ -2659,7 +2656,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
{
tokens.Append(KeywordToken, " as ");
tokens.Append(TextToken, "*");
- Ref<Type> srcType = srcExpr.GetType();
+ Ref<Type> srcType = srcExpr.GetType().GetValue();
if (srcType && srcType->IsPointer() && srcType->GetChildType()->IsConst())
tokens.Append(KeywordToken, "const ");
else
@@ -2839,7 +2836,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
break;
}
- if (settings && settings->IsOptionSet(ShowILTypes) && instr.GetType())
+ if (settings && settings->IsOptionSet(ShowILTypes) && instr.GetType().GetValue())
{
tokens.AppendCloseParen();
}
diff --git a/lang/rust/rusttypes.cpp b/lang/rust/rusttypes.cpp
index c43817ab..70bf3162 100644
--- a/lang/rust/rusttypes.cpp
+++ b/lang/rust/rusttypes.cpp
@@ -13,8 +13,8 @@ RustTypePrinter::RustTypePrinter(): TypePrinter("RustTypePrinter")
void RustTypePrinter::AppendCallingConventionTokens(Type* type, Platform* platform, uint8_t baseConfidence,
vector<InstructionTextToken>& tokens)
{
- if (type->GetCallingConvention() && platform &&
- type->GetCallingConvention().GetValue() != platform->GetDefaultCallingConvention())
+ if (type->GetCallingConvention().GetValue() && platform
+ && type->GetCallingConvention().GetValue() != platform->GetDefaultCallingConvention())
{
uint8_t ccConfidence = type->GetCallingConvention().GetCombinedConfidence(baseConfidence);
tokens.emplace_back(baseConfidence, KeywordToken, "extern");
@@ -83,7 +83,7 @@ void RustTypePrinter::GetStructureMemberTokens(Platform* platform, Type* type, u
}
vector<InstructionTextToken> after =
- GetTypeTokensAfterName(members[i].type, platform, BN_FULL_CONFIDENCE, nullptr, escaping);
+ GetTypeTokensAfterName(members[i].type.GetValue(), platform, BN_FULL_CONFIDENCE, nullptr, escaping);
out.emplace_back(baseConfidence, FieldNameToken,
NameList::EscapeTypeName(members[i].name, escaping));
@@ -144,7 +144,7 @@ vector<InstructionTextToken> RustTypePrinter::GetTypeTokensAfterNameInternal(
if (i != 0)
tokens.emplace_back(baseConfidence, TextToken, ", ");
- vector<InstructionTextToken> paramTokens = GetTypeTokensAfterName(params[i].type, platform,
+ vector<InstructionTextToken> paramTokens = GetTypeTokensAfterName(params[i].type.GetValue(), platform,
params[i].type.GetCombinedConfidence(baseConfidence), type, escaping);
if (functionHeader)
@@ -219,10 +219,10 @@ vector<InstructionTextToken> RustTypePrinter::GetTypeTokensAfterNameInternal(
tokens.emplace_back(baseConfidence, TextToken, " -> ");
tokens.emplace_back(type->CanReturn().GetCombinedConfidence(baseConfidence), TextToken, "!");
}
- else if (type->GetChildType() && type->GetChildType()->GetClass() != VoidTypeClass)
+ else if (type->GetChildType().GetValue() && type->GetChildType()->GetClass() != VoidTypeClass)
{
tokens.emplace_back(baseConfidence, TextToken, " -> ");
- vector<InstructionTextToken> retn = GetTypeTokensAfterName(type->GetChildType(), platform,
+ vector<InstructionTextToken> retn = GetTypeTokensAfterName(type->GetChildType().GetValue(), platform,
type->GetChildType().GetCombinedConfidence(baseConfidence), type, escaping);
if (functionHeader)
{
@@ -287,8 +287,8 @@ vector<InstructionTextToken> RustTypePrinter::GetTypeTokensAfterNameInternal(
{
if (type->GetChildType()->GetClass() == FunctionTypeClass)
{
- vector<InstructionTextToken> inner = GetTypeTokensAfterName(
- type->GetChildType(), platform, baseConfidence, type, escaping);
+ vector<InstructionTextToken> inner =
+ GetTypeTokensAfterName(type->GetChildType().GetValue(), platform, baseConfidence, type, escaping);
tokens.insert(tokens.end(), inner.begin(), inner.end());
return tokens;
}
@@ -299,7 +299,7 @@ vector<InstructionTextToken> RustTypePrinter::GetTypeTokensAfterNameInternal(
else
tokens.emplace_back(baseConfidence, KeywordToken, "mut");
tokens.emplace_back(baseConfidence, TextToken, " ");
- vector<InstructionTextToken> inner = GetTypeTokensAfterName(type->GetChildType(), platform,
+ vector<InstructionTextToken> inner = GetTypeTokensAfterName(type->GetChildType().GetValue(), platform,
type->GetChildType().GetCombinedConfidence(baseConfidence), type, escaping);
tokens.insert(tokens.end(), inner.begin(), inner.end());
break;
@@ -307,7 +307,7 @@ vector<InstructionTextToken> RustTypePrinter::GetTypeTokensAfterNameInternal(
case ArrayTypeClass:
{
tokens.emplace_back(baseConfidence, BraceToken, "[");
- vector<InstructionTextToken> inner = GetTypeTokensAfterName(type->GetChildType(), platform,
+ vector<InstructionTextToken> inner = GetTypeTokensAfterName(type->GetChildType().GetValue(), platform,
type->GetChildType().GetCombinedConfidence(baseConfidence), type, escaping);
tokens.insert(tokens.end(), inner.begin(), inner.end());
tokens.emplace_back(baseConfidence, TextToken, "; ");