diff options
author | Bob Haarman <llvm@inglorion.net> | 2017-05-17 20:46:48 +0000 |
---|---|---|
committer | Bob Haarman <llvm@inglorion.net> | 2017-05-17 20:46:48 +0000 |
commit | de33a637847a226da9d7439263b601a20f1de96e (patch) | |
tree | 448f74b70c3d492a82505f7ef13a106622c8c51c | |
parent | 00549e47bdb77b7ba7dc8a685e1c2e974c6434e7 (diff) | |
download | bcm5719-llvm-de33a637847a226da9d7439263b601a20f1de96e.tar.gz bcm5719-llvm-de33a637847a226da9d7439263b601a20f1de96e.zip |
[llvm-pdbdump] in yaml2pdb, generate default output filename if none given
Summary:
llvm-pdbdump yaml2pdb used to fail with a misleading error
message ("An I/O error occurred on the file system") if no output file
was specified. This change adds an assert to PDBFileBuilder to check
that an output file name is specified, and makes llvm-pdbdump generate
an output file name based on the input file name if no output file
name is explicitly specified.
Reviewers: amccarth, zturner
Reviewed By: zturner
Subscribers: fhahn, llvm-commits
Differential Revision: https://reviews.llvm.org/D33296
llvm-svn: 303299
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp | 1 | ||||
-rw-r--r-- | llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp | 14 |
2 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp index 4dd965c6907..c6568029ec5 100644 --- a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp @@ -117,6 +117,7 @@ Expected<uint32_t> PDBFileBuilder::getNamedStreamIndex(StringRef Name) const { } Error PDBFileBuilder::commit(StringRef Filename) { + assert(!Filename.empty()); auto ExpectedLayout = finalizeMsfLayout(); if (!ExpectedLayout) return ExpectedLayout.takeError(); diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp index 0e5913fa3c9..dc3e15a89af 100644 --- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp +++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp @@ -67,6 +67,7 @@ #include "llvm/Support/Format.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/Path.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Process.h" #include "llvm/Support/Regex.h" @@ -365,9 +366,9 @@ cl::opt<std::string> YamlPdbOutputFile("pdb", cl::desc("the name of the PDB file to write"), cl::sub(YamlToPdbSubcommand)); -cl::list<std::string> InputFilename(cl::Positional, - cl::desc("<input YAML file>"), cl::Required, - cl::sub(YamlToPdbSubcommand)); +cl::opt<std::string> InputFilename(cl::Positional, + cl::desc("<input YAML file>"), cl::Required, + cl::sub(YamlToPdbSubcommand)); } namespace pdb2yaml { @@ -894,7 +895,12 @@ int main(int argc_, const char *argv_[]) { if (opts::PdbToYamlSubcommand) { pdb2Yaml(opts::pdb2yaml::InputFilename.front()); } else if (opts::YamlToPdbSubcommand) { - yamlToPdb(opts::yaml2pdb::InputFilename.front()); + if (opts::yaml2pdb::YamlPdbOutputFile.empty()) { + SmallString<16> OutputFilename(opts::yaml2pdb::InputFilename.getValue()); + sys::path::replace_extension(OutputFilename, ".pdb"); + opts::yaml2pdb::YamlPdbOutputFile = OutputFilename.str(); + } + yamlToPdb(opts::yaml2pdb::InputFilename); } else if (opts::AnalyzeSubcommand) { dumpAnalysis(opts::analyze::InputFilename.front()); } else if (opts::PrettySubcommand) { |