[PATCH] D33296: [llvm-pdbdump] in yaml2pdb, generate default output filename if none given

Bob Haarman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 17 13:18:03 PDT 2017


inglorion created this revision.
Herald added a subscriber: fhahn.

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.


https://reviews.llvm.org/D33296

Files:
  lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
  tools/llvm-pdbdump/llvm-pdbdump.cpp


Index: tools/llvm-pdbdump/llvm-pdbdump.cpp
===================================================================
--- tools/llvm-pdbdump/llvm-pdbdump.cpp
+++ 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 @@
     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 @@
   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) {
Index: lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
===================================================================
--- lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
+++ lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
@@ -117,6 +117,7 @@
 }
 
 Error PDBFileBuilder::commit(StringRef Filename) {
+  assert(!Filename.empty());
   auto ExpectedLayout = finalizeMsfLayout();
   if (!ExpectedLayout)
     return ExpectedLayout.takeError();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33296.99340.patch
Type: text/x-patch
Size: 2145 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170517/67fa5e7f/attachment.bin>


More information about the llvm-commits mailing list