diff options
author | 2014-05-28 21:41:35 +0100 | |
---|---|---|
committer | 2014-05-29 09:54:08 +0100 | |
commit | a9f1ce6fbe8a9247d0d8e20727f590b091e816da (patch) | |
tree | fc165edcc2c68a19e3df1edfb65f6c3599aebdfb | |
parent | b661a80aab8b8f25590f3165b08647d1df7021f3 (diff) |
Fix pass driver's dump_pass_list_ and print_pass_list_.
The lists were allocated with new char[], so they should
have been held by std::unique_ptr<const char[]> rather than
std::unique_ptr<const char>. However, it's much cleaner with
std::string.
Change-Id: Ie7c604773272194345f5e6e3c4803c3a914edf99
-rw-r--r-- | compiler/dex/pass_driver.h | 12 | ||||
-rw-r--r-- | compiler/dex/pass_driver_me.cc | 8 | ||||
-rw-r--r-- | dex2oat/dex2oat.cc | 10 |
3 files changed, 12 insertions, 18 deletions
diff --git a/compiler/dex/pass_driver.h b/compiler/dex/pass_driver.h index 788f24b461..bd8f53cd5a 100644 --- a/compiler/dex/pass_driver.h +++ b/compiler/dex/pass_driver.h @@ -153,12 +153,12 @@ class PassDriver { default_print_passes_ = true; } - static void SetDumpPassList(const char* list) { - dump_pass_list_.reset(list); + static void SetDumpPassList(const std::string& list) { + dump_pass_list_ = list; } - static void SetPrintPassList(const char* list) { - print_pass_list_.reset(list); + static void SetPrintPassList(const std::string& list) { + print_pass_list_ = list; } void SetDefaultPasses() { @@ -202,10 +202,10 @@ class PassDriver { static bool default_print_passes_; /** @brief What are the passes we want to be printing the log messages? */ - static std::unique_ptr<const char> print_pass_list_; + static std::string print_pass_list_; /** @brief What are the passes we want to be dumping the CFG? */ - static std::unique_ptr<const char> dump_pass_list_; + static std::string dump_pass_list_; }; } // namespace art diff --git a/compiler/dex/pass_driver_me.cc b/compiler/dex/pass_driver_me.cc index 099cfee5ba..e6d90e0b03 100644 --- a/compiler/dex/pass_driver_me.cc +++ b/compiler/dex/pass_driver_me.cc @@ -79,11 +79,11 @@ std::vector<const Pass*> PassDriver<PassDriverME>::g_default_pass_list(PassDrive // By default, do not have a dump pass list. template<> -std::unique_ptr<const char> PassDriver<PassDriverME>::dump_pass_list_(nullptr); +std::string PassDriver<PassDriverME>::dump_pass_list_ = std::string(); // By default, do not have a print pass list. template<> -std::unique_ptr<const char> PassDriver<PassDriverME>::print_pass_list_(nullptr); +std::string PassDriver<PassDriverME>::print_pass_list_ = std::string(); // By default, we do not print the pass' information. template<> @@ -155,7 +155,7 @@ bool PassDriverME::RunPass(const Pass* pass, bool time_split) { c_unit->print_pass = default_print_passes_; - const char* print_pass_list = print_pass_list_.get(); + const char* print_pass_list = print_pass_list_.c_str(); if (print_pass_list != nullptr && strstr(print_pass_list, pass->GetName()) != nullptr) { c_unit->print_pass = true; @@ -167,7 +167,7 @@ bool PassDriverME::RunPass(const Pass* pass, bool time_split) { // Do we want to log it? bool should_dump = ((c_unit->enable_debug & (1 << kDebugDumpCFG)) != 0); - const char* dump_pass_list = dump_pass_list_.get(); + const char* dump_pass_list = dump_pass_list_.c_str(); if (dump_pass_list != nullptr) { bool found = strstr(dump_pass_list, pass->GetName()); diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 91a1418fb0..4d3d6646cf 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -925,18 +925,12 @@ static int dex2oat(int argc, char** argv) { PassDriverME::CreateDefaultPassList(disable_passes); } else if (option.starts_with("--print-passes=")) { std::string print_passes = option.substr(strlen("--print-passes=")).data(); - size_t len = print_passes.length() + 1; - char* duplicate = new char[len]; - strncpy(duplicate, print_passes.c_str(), len); - PassDriverME::SetPrintPassList(duplicate); + PassDriverME::SetPrintPassList(print_passes); } else if (option == "--print-all-passes") { PassDriverME::SetPrintAllPasses(); } else if (option.starts_with("--dump-cfg-passes=")) { std::string dump_passes = option.substr(strlen("--dump-cfg-passes=")).data(); - size_t len = dump_passes.length() + 1; - char* duplicate = new char[len]; - strncpy(duplicate, dump_passes.c_str(), len); - PassDriverME::SetDumpPassList(duplicate); + PassDriverME::SetDumpPassList(dump_passes); } else { Usage("Unknown argument %s", option.data()); } |