ART: Change InstructionSetFeatures to return unique_ptr
This makes clear the ownership of the object.
Test: m test-art-host
Change-Id: I55fa734f04bc3046d370f4dcf98ce6b17c59e234
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 8bbe685..28d6289 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -637,9 +637,8 @@
void ParseInstructionSetVariant(const StringPiece& option, ParserOptions* parser_options) {
DCHECK(option.starts_with("--instruction-set-variant="));
StringPiece str = option.substr(strlen("--instruction-set-variant=")).data();
- instruction_set_features_.reset(
- InstructionSetFeatures::FromVariant(
- instruction_set_, str.as_string(), &parser_options->error_msg));
+ instruction_set_features_ = InstructionSetFeatures::FromVariant(
+ instruction_set_, str.as_string(), &parser_options->error_msg);
if (instruction_set_features_.get() == nullptr) {
Usage("%s", parser_options->error_msg.c_str());
}
@@ -648,19 +647,18 @@
void ParseInstructionSetFeatures(const StringPiece& option, ParserOptions* parser_options) {
DCHECK(option.starts_with("--instruction-set-features="));
StringPiece str = option.substr(strlen("--instruction-set-features=")).data();
- if (instruction_set_features_.get() == nullptr) {
- instruction_set_features_.reset(
- InstructionSetFeatures::FromVariant(
- instruction_set_, "default", &parser_options->error_msg));
+ if (instruction_set_features_ == nullptr) {
+ instruction_set_features_ = InstructionSetFeatures::FromVariant(
+ instruction_set_, "default", &parser_options->error_msg);
if (instruction_set_features_.get() == nullptr) {
Usage("Problem initializing default instruction set features variant: %s",
parser_options->error_msg.c_str());
}
}
- instruction_set_features_.reset(
+ instruction_set_features_ =
instruction_set_features_->AddFeaturesFromString(str.as_string(),
- &parser_options->error_msg));
- if (instruction_set_features_.get() == nullptr) {
+ &parser_options->error_msg);
+ if (instruction_set_features_ == nullptr) {
Usage("Error parsing '%s': %s", option.data(), parser_options->error_msg.c_str());
}
}
@@ -828,9 +826,8 @@
// If no instruction set feature was given, use the default one for the target
// instruction set.
if (instruction_set_features_.get() == nullptr) {
- instruction_set_features_.reset(
- InstructionSetFeatures::FromVariant(
- instruction_set_, "default", &parser_options->error_msg));
+ instruction_set_features_ = InstructionSetFeatures::FromVariant(
+ instruction_set_, "default", &parser_options->error_msg);
if (instruction_set_features_.get() == nullptr) {
Usage("Problem initializing default instruction set features variant: %s",
parser_options->error_msg.c_str());