Fix Boolean to integral types conversions.
Bug: 27616343
Change-Id: I050f92045bca1b8b5d6da53547cc617f17be84b1
diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc
index f2e77e2..c790d01 100644
--- a/compiler/optimizing/graph_checker.cc
+++ b/compiler/optimizing/graph_checker.cc
@@ -1005,4 +1005,19 @@
}
}
+void GraphChecker::VisitTypeConversion(HTypeConversion* instruction) {
+ VisitInstruction(instruction);
+ Primitive::Type result_type = instruction->GetResultType();
+ Primitive::Type input_type = instruction->GetInputType();
+ // Invariant: We should never generate a conversion to a Boolean value.
+ if (result_type == Primitive::kPrimBoolean) {
+ AddError(StringPrintf(
+ "%s %d converts to a %s (from a %s).",
+ instruction->DebugName(),
+ instruction->GetId(),
+ Primitive::PrettyDescriptor(result_type),
+ Primitive::PrettyDescriptor(input_type)));
+ }
+}
+
} // namespace art