diff options
author | Vedant Kumar <vsk@apple.com> | 2016-06-28 01:14:04 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2016-06-28 01:14:04 +0000 |
commit | a48d9fe86a627c88a21398db6c18a0108b131444 (patch) | |
tree | eb42ea5f99f9d039d568e5933f529d535ce6d6c4 /llvm/tools | |
parent | b4d95031711e65da8e0f87e8b4d9b8daf69dad00 (diff) | |
download | bcm5719-llvm-a48d9fe86a627c88a21398db6c18a0108b131444.tar.gz bcm5719-llvm-a48d9fe86a627c88a21398db6c18a0108b131444.zip |
Revert "[llvm-cov] Add an -output-dir option for the show sub-command"
This reverts commit r273971. test/profile/instrprof-visibility.cpp is
failing because of an uncaught error in SafelyCloseFileDescriptor.
llvm-svn: 273978
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/llvm-cov/CodeCoverage.cpp | 39 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/CoverageViewOptions.h | 1 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageView.cpp | 45 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageView.h | 21 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageViewText.cpp | 9 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageViewText.h | 7 |
6 files changed, 6 insertions, 116 deletions
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp index e7a4f676bcd..04901a27179 100644 --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -406,12 +406,6 @@ int CodeCoverageTool::show(int argc, const char **argv, clEnumValEnd), cl::init(CoverageViewOptions::OutputFormat::Text)); - cl::opt<std::string> ShowOutputDirectory( - "output-dir", cl::init(""), - cl::desc("Directory in which coverage information is written out")); - cl::alias ShowOutputDirectoryA("o", cl::desc("Alias for --output-dir"), - cl::aliasopt(ShowOutputDirectory)); - auto Err = commandLineParser(argc, argv); if (Err) return Err; @@ -424,14 +418,6 @@ int CodeCoverageTool::show(int argc, const char **argv, ViewOpts.ShowExpandedRegions = ShowExpansions; ViewOpts.ShowFunctionInstantiations = ShowInstantiations; ViewOpts.ShowFormat = ShowFormat; - ViewOpts.ShowOutputDirectory = ShowOutputDirectory; - - if (ViewOpts.ShowOutputDirectory != "") { - if (auto E = sys::fs::create_directories(ViewOpts.ShowOutputDirectory)) { - error("Could not create output directory!", E.message()); - return 1; - } - } auto Coverage = load(); if (!Coverage) @@ -450,17 +436,8 @@ int CodeCoverageTool::show(int argc, const char **argv, << "\n"; continue; } - - auto OSOrErr = - mainView->createOutputFile("functions", /*InToplevel=*/true); - if (Error E = OSOrErr.takeError()) { - handleAllErrors(OSOrErr.takeError(), - [&](const ErrorInfoBase &EI) { error(EI.message()); }); - return 1; - } - std::unique_ptr<raw_ostream> OS = std::move(OSOrErr.get()); - mainView->print(*OS.get(), /*WholeFile=*/false, /*ShowSourceName=*/true); - mainView->closeOutputFile(std::move(OS)); + mainView->print(outs(), /*WholeFile=*/false, /*ShowSourceName=*/true); + outs() << "\n"; } return 0; } @@ -482,16 +459,10 @@ int CodeCoverageTool::show(int argc, const char **argv, continue; } - auto OSOrErr = mainView->createOutputFile(SourceFile, /*InToplevel=*/false); - if (Error E = OSOrErr.takeError()) { - handleAllErrors(OSOrErr.takeError(), - [&](const ErrorInfoBase &EI) { error(EI.message()); }); - return 1; - } - std::unique_ptr<raw_ostream> OS = std::move(OSOrErr.get()); - mainView->print(*OS.get(), /*Wholefile=*/true, + mainView->print(outs(), /*Wholefile=*/true, /*ShowSourceName=*/ShowFilenames); - mainView->closeOutputFile(std::move(OS)); + if (SourceFiles.size() > 1) + outs() << "\n"; } return 0; diff --git a/llvm/tools/llvm-cov/CoverageViewOptions.h b/llvm/tools/llvm-cov/CoverageViewOptions.h index bde8b82520b..93bc09ca9d8 100644 --- a/llvm/tools/llvm-cov/CoverageViewOptions.h +++ b/llvm/tools/llvm-cov/CoverageViewOptions.h @@ -30,7 +30,6 @@ struct CoverageViewOptions { bool ShowFunctionInstantiations; bool ShowFullFilenames; OutputFormat ShowFormat; - std::string ShowOutputDirectory; /// \brief Change the output's stream color if the colors are enabled. ColoredRawOstream colored_ostream(raw_ostream &OS, diff --git a/llvm/tools/llvm-cov/SourceCoverageView.cpp b/llvm/tools/llvm-cov/SourceCoverageView.cpp index 097d01b9643..3309189a935 100644 --- a/llvm/tools/llvm-cov/SourceCoverageView.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageView.cpp @@ -15,9 +15,7 @@ #include "SourceCoverageViewText.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/Support/FileSystem.h" #include "llvm/Support/LineIterator.h" -#include "llvm/Support/Path.h" using namespace llvm; @@ -36,49 +34,6 @@ std::string SourceCoverageView::formatCount(uint64_t N) { return Result; } -/// \brief Create a file at ``Dir/ToplevelDir/@Path.Extension``. If -/// \p ToplevelDir is empty, its path component is skipped. -static Expected<std::unique_ptr<raw_ostream>> -createFileInDirectory(StringRef Dir, StringRef ToplevelDir, StringRef Path, - StringRef Extension) { - assert(Extension.size() && "The file extension may not be empty"); - - SmallString<256> FullPath(Dir); - if (!ToplevelDir.empty()) - sys::path::append(FullPath, ToplevelDir); - - auto PathBaseDir = sys::path::relative_path(sys::path::parent_path(Path)); - sys::path::append(FullPath, PathBaseDir); - - if (auto E = sys::fs::create_directories(FullPath)) - return errorCodeToError(E); - - auto PathFilename = (sys::path::filename(Path) + "." + Extension).str(); - sys::path::append(FullPath, PathFilename); - - std::error_code E; - auto OS = llvm::make_unique<raw_fd_ostream>(FullPath, E, sys::fs::F_RW); - if (E) - return errorCodeToError(E); - return std::move(OS); -} - -Expected<std::unique_ptr<raw_ostream>> -SourceCoverageView::createOutputStream(const CoverageViewOptions &Opts, - StringRef Path, StringRef Extension, - bool InToplevel) { - if (Opts.ShowOutputDirectory == "") { - std::error_code E; - auto OS = llvm::make_unique<raw_fd_ostream>("-", E, sys::fs::F_None); - if (E) - return errorCodeToError(E); - return std::move(OS); - } - - return createFileInDirectory(Opts.ShowOutputDirectory, - InToplevel ? "" : "coverage", Path, Extension); -} - void SourceCoverageView::addExpansion( const coverage::CounterMappingRegion &Region, std::unique_ptr<SourceCoverageView> View) { diff --git a/llvm/tools/llvm-cov/SourceCoverageView.h b/llvm/tools/llvm-cov/SourceCoverageView.h index 57b5d941fb5..03c07422964 100644 --- a/llvm/tools/llvm-cov/SourceCoverageView.h +++ b/llvm/tools/llvm-cov/SourceCoverageView.h @@ -101,7 +101,7 @@ struct LineCoverageStats { /// /// A source coverage view and its nested sub-views form a file-oriented /// representation of code coverage data. This view can be printed out by a -/// renderer which implements both the File Creation and Rendering interfaces. +/// renderer which implements the Rendering Interface. class SourceCoverageView { /// A function or file name. StringRef SourceName; @@ -122,19 +122,6 @@ class SourceCoverageView { /// on display. std::vector<InstantiationView> InstantiationSubViews; -public: - /// @name File Creation Interface - /// @{ - - /// \brief Create a file to print a coverage view into. - virtual Expected<std::unique_ptr<raw_ostream>> - createOutputFile(StringRef Path, bool InToplevel) = 0; - - /// \brief Close a file which has been used to print a coverage view. - virtual void closeOutputFile(std::unique_ptr<raw_ostream> OS) = 0; - - /// @} - protected: struct LineRef { StringRef Line; @@ -196,12 +183,6 @@ protected: /// digits. static std::string formatCount(uint64_t N); - /// \brief If directory output is enabled, create a file with \p Path as the - /// suffix. Otherwise, return stdout. - static Expected<std::unique_ptr<raw_ostream>> - createOutputStream(const CoverageViewOptions &Opts, StringRef Path, - StringRef Extension, bool InToplevel); - SourceCoverageView(StringRef SourceName, const MemoryBuffer &File, const CoverageViewOptions &Options, coverage::CoverageData &&CoverageInfo) diff --git a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp index f8a313e359e..0757a4ebd95 100644 --- a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp @@ -37,15 +37,6 @@ unsigned getDividerWidth(const CoverageViewOptions &Opts) { } // anonymous namespace -Expected<std::unique_ptr<raw_ostream>> -SourceCoverageViewText::createOutputFile(StringRef Path, bool InToplevel) { - return createOutputStream(getOptions(), Path, "txt", InToplevel); -} - -void SourceCoverageViewText::closeOutputFile(std::unique_ptr<raw_ostream> OS) { - OS.get()->operator<<('\n'); -} - void SourceCoverageViewText::renderSourceName(raw_ostream &OS) { getOptions().colored_ostream(OS, raw_ostream::CYAN) << getSourceName() << ":\n"; diff --git a/llvm/tools/llvm-cov/SourceCoverageViewText.h b/llvm/tools/llvm-cov/SourceCoverageViewText.h index bcbdffd5b4b..17f2e797abd 100644 --- a/llvm/tools/llvm-cov/SourceCoverageViewText.h +++ b/llvm/tools/llvm-cov/SourceCoverageViewText.h @@ -20,13 +20,6 @@ namespace llvm { /// \brief A code coverage view which supports text-based rendering. class SourceCoverageViewText : public SourceCoverageView { -public: - Expected<std::unique_ptr<raw_ostream>> - createOutputFile(StringRef Path, bool InToplevel) override; - - void closeOutputFile(std::unique_ptr<raw_ostream> OS) override; - -private: void renderSourceName(raw_ostream &OS) override; void renderLinePrefix(raw_ostream &OS, unsigned ViewDepth) override; |