diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2015-08-21 04:45:55 +0000 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-08-21 04:45:55 +0000 |
| commit | 2257512f87c12b42c053ec760c84f73e905264d9 (patch) | |
| tree | 2e5236e40e24bb9ae18565b3533ab29a76eafc58 /llvm/lib/LTO | |
| parent | 0d6094b992d800babedb77112e647a388a86a6eb (diff) | |
| download | bcm5719-llvm-2257512f87c12b42c053ec760c84f73e905264d9.tar.gz bcm5719-llvm-2257512f87c12b42c053ec760c84f73e905264d9.zip | |
LTO: Simplify ownership of LTOCodeGenerator::CodegenOptions.
llvm-svn: 245670
Diffstat (limited to 'llvm/lib/LTO')
| -rw-r--r-- | llvm/lib/LTO/LTOCodeGenerator.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp index daaf2232922..fdf3f3a2b89 100644 --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -89,11 +89,6 @@ LTOCodeGenerator::~LTOCodeGenerator() { delete TargetMach; TargetMach = nullptr; - - for (std::vector<char *>::iterator I = CodegenOptions.begin(), - E = CodegenOptions.end(); - I != E; ++I) - free(*I); } // Initialize LTO passes. Please keep this funciton in sync with @@ -575,20 +570,19 @@ bool LTOCodeGenerator::compileOptimized(raw_pwrite_stream &out, /// LTO problems. void LTOCodeGenerator::setCodeGenDebugOptions(const char *options) { for (std::pair<StringRef, StringRef> o = getToken(options); - !o.first.empty(); o = getToken(o.second)) { - // ParseCommandLineOptions() expects argv[0] to be program name. Lazily add - // that. - if (CodegenOptions.empty()) - CodegenOptions.push_back(strdup("libLLVMLTO")); - CodegenOptions.push_back(strdup(o.first.str().c_str())); - } + !o.first.empty(); o = getToken(o.second)) + CodegenOptions.push_back(o.first); } void LTOCodeGenerator::parseCodeGenDebugOptions() { // if options were requested, set them - if (!CodegenOptions.empty()) - cl::ParseCommandLineOptions(CodegenOptions.size(), - const_cast<char **>(&CodegenOptions[0])); + if (!CodegenOptions.empty()) { + // ParseCommandLineOptions() expects argv[0] to be program name. + std::vector<const char *> CodegenArgv(1, "libLLVMLTO"); + for (std::string &Arg : CodegenOptions) + CodegenArgv.push_back(Arg.c_str()); + cl::ParseCommandLineOptions(CodegenArgv.size(), CodegenArgv.data()); + } } void LTOCodeGenerator::DiagnosticHandler(const DiagnosticInfo &DI, |

