Index: lib/Support/GraphWriter.cpp =================================================================== --- lib/Support/GraphWriter.cpp +++ lib/Support/GraphWriter.cpp @@ -189,7 +189,13 @@ return ExecGraphViewer(ViewerPath, args, Filename, wait, ErrMsg); } - enum PSViewerKind { PSV_None, PSV_OSXOpen, PSV_XDGOpen, PSV_Ghostview }; + enum PSViewerKind { + PSV_None, + PSV_OSXOpen, + PSV_XDGOpen, + PSV_Ghostview, + PDFV_Start + }; PSViewerKind PSViewer = PSV_None; #ifdef __APPLE__ if (!PSViewer && S.TryFindProgram("open", ViewerPath)) @@ -199,17 +205,26 @@ PSViewer = PSV_Ghostview; if (!PSViewer && S.TryFindProgram("xdg-open", ViewerPath)) PSViewer = PSV_XDGOpen; +#ifdef LLVM_ON_WIN32 + if (!PSViewer && S.TryFindProgram("cmd", ViewerPath)) { + PSViewer = PDFV_Start; + } +#endif // PostScript graph generator + PostScript viewer std::string GeneratorPath; if (PSViewer && (S.TryFindProgram(getProgramName(program), GeneratorPath) || S.TryFindProgram("dot|fdp|neato|twopi|circo", GeneratorPath))) { - std::string PSFilename = Filename + ".ps"; + std::string PSFilename = + Filename + (PSViewer == PDFV_Start ? ".pdf" : ".ps"); std::vector args; args.push_back(GeneratorPath.c_str()); - args.push_back("-Tps"); + if (PSViewer == PDFV_Start) + args.push_back("-Tpdf"); + else + args.push_back("-Tps"); args.push_back("-Nfontname=Courier"); args.push_back("-Gsize=7.5,10"); args.push_back(Filename.c_str()); @@ -222,6 +237,10 @@ if (ExecGraphViewer(GeneratorPath, args, Filename, true, ErrMsg)) return true; + std::string StartArg; + if (PSViewer == PDFV_Start) + StartArg = (StringRef("start ") + PSFilename).str(); + args.clear(); args.push_back(ViewerPath.c_str()); switch (PSViewer) { @@ -237,6 +256,11 @@ args.push_back("--spartan"); args.push_back(PSFilename.c_str()); break; + case PDFV_Start: + args.push_back("/S"); + args.push_back("/C"); + args.push_back(StartArg.c_str()); + break; case PSV_None: llvm_unreachable("Invalid viewer"); }