// HTML: <span>Code Coverage Report</span>
// HTML: <div class='created-time'>
// HTML: <span>Created:
-// HTML-FILE: <pre>Source:
-// HTML-FILE: showProjectSummary.cpp</pre>
-// HTML-FILE: <pre>Binary:
-// HTML-FILE: showProjectSummary.covmapping</pre>
-// HTML-FUNCTION: <pre>Function: main</pre>
+// HTML-FILE: <pre>Source: {{.*}}showProjectSummary.cpp (Binary: showProjectSummary.covmapping)</pre>
+// HTML-FUNCTION: <pre>main</pre>
// HTML-UNCOVEREDLINE: <a href='#L8'>Go to first unexecuted line</a>
// HTML-HEADER: <tr><td><span><pre>Line No.</pre></span></td>
// HTML-HEADER: <td><span><pre>Count</pre></span></td>
int j = 1; // ALL-NEXT: [[@LINE]]| 0| int j = 1;
} // ALL-NEXT: [[@LINE]]| 2|}
- // SHARED: {{^ *(\| )?}}Function: _Z4funcIbEiT_:
+ // SHARED: {{^ *(\| )?}}_Z4funcIbEiT_:
// SHARED: [[@LINE-9]]| 1|int func(T x) {
// SHARED-NEXT: [[@LINE-9]]| 1| if(x)
// SHARED-NEXT: [[@LINE-9]]| 1| return 0;
// SHARED-NEXT: [[@LINE-9]]| 0| int j = 1;
// SHARED-NEXT: [[@LINE-9]]| 1|}
- // ALL: {{^ *}}| Function: _Z4funcIiEiT_:
- // FILTER-NOT: {{^ *(\| )?}}Function: _Z4funcIiEiT_:
+ // ALL: {{^ *}}| _Z4funcIiEiT_:
+ // FILTER-NOT: {{^ *(\| )?}} _Z4funcIiEiT_:
// ALL: [[@LINE-19]]| 1|int func(T x) {
// ALL-NEXT: [[@LINE-19]]| 1| if(x)
// ALL-NEXT: [[@LINE-19]]| 0| return 0;
// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='uncovered-line'><pre>0</pre></td><td class='code'><pre>
// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>2</pre></td><td class='code'><pre>}
-// HTML-SHARED: <div class='source-name-title'><pre>Function: _Z4funcIbEiT_</pre></div>
+// HTML-SHARED: <div class='source-name-title'><pre>_Z4funcIbEiT_</pre></div>
// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>int func(T x) {
// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> if(x)
// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> ret
// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='uncovered-line'><pre>0</pre></td><td class='code'><pre>
// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>}
-// HTML-ALL: <div class='source-name-title'><pre>Function: _Z4funcIiEiT_</pre></div>
+// HTML-ALL: <div class='source-name-title'><pre>_Z4funcIiEiT_</pre></div>
// HTML-FILTER-NOT: <div class='source-name-title'><pre>_Z4funcIiEiT_</pre></div><table>
// HTML-ALL: <td class='line-number'><a name='L[[@LINE-63]]'><pre>[[@LINE-63]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>int func(T x) {
// HTML-ALL: <td class='line-number'><a name='L[[@LINE-63]]'><pre>[[@LINE-63]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> if(x)
return nullptr;
auto Expansions = FunctionCoverage.getExpansions();
- auto View = SourceCoverageView::create(
- getSymbolForHumans(Function.Name), SourceBuffer.get(), ViewOpts,
- std::move(FunctionCoverage), /*FunctionView=*/true);
+ auto View = SourceCoverageView::create(getSymbolForHumans(Function.Name),
+ SourceBuffer.get(), ViewOpts,
+ std::move(FunctionCoverage));
attachExpansionSubViews(*View, Expansions, Coverage);
return View;
auto SubViewExpansions = SubViewCoverage.getExpansions();
auto SubView = SourceCoverageView::create(
getSymbolForHumans(Function->Name), SourceBuffer.get(), ViewOpts,
- std::move(SubViewCoverage), /*FunctionView=*/true);
+ std::move(SubViewCoverage));
attachExpansionSubViews(*SubView, SubViewExpansions, Coverage);
if (SubView) {
std::unique_ptr<SourceCoverageView>
SourceCoverageView::create(StringRef SourceName, const MemoryBuffer &File,
const CoverageViewOptions &Options,
- coverage::CoverageData &&CoverageInfo,
- bool FunctionView) {
+ coverage::CoverageData &&CoverageInfo) {
switch (Options.Format) {
case CoverageViewOptions::OutputFormat::Text:
return llvm::make_unique<SourceCoverageViewText>(
- SourceName, File, Options, std::move(CoverageInfo), FunctionView);
+ SourceName, File, Options, std::move(CoverageInfo));
case CoverageViewOptions::OutputFormat::HTML:
return llvm::make_unique<SourceCoverageViewHTML>(
- SourceName, File, Options, std::move(CoverageInfo), FunctionView);
+ SourceName, File, Options, std::move(CoverageInfo));
}
llvm_unreachable("Unknown coverage output format!");
}
-std::string SourceCoverageView::getNativeSourceName() const {
- std::string SourceFile = isFunctionView() ? "Function: " : "Source: ";
- SourceFile += getSourceName().str();
- SmallString<128> SourceText(SourceFile);
+std::string SourceCoverageView::getSourceName() const {
+ SmallString<128> SourceText(SourceName);
sys::path::remove_dots(SourceText, /*remove_dot_dots=*/true);
sys::path::native(SourceText);
- return SourceText.c_str();
+ return SourceText.str();
+}
+
+std::string SourceCoverageView::getVerboseSourceName() const {
+ return "Source: " + getSourceName() + " (Binary: " +
+ sys::path::filename(getOptions().ObjectFilename).str() + ")";
}
void SourceCoverageView::addExpansion(
/// on display.
std::vector<InstantiationView> InstantiationSubViews;
- /// Specifies whether or not the view is a function view.
- bool FunctionView;
-
/// Get the first uncovered line number for the source file.
unsigned getFirstUncoveredLineNo();
SourceCoverageView(StringRef SourceName, const MemoryBuffer &File,
const CoverageViewOptions &Options,
- coverage::CoverageData &&CoverageInfo, bool FunctionView)
+ coverage::CoverageData &&CoverageInfo)
: SourceName(SourceName), File(File), Options(Options),
- CoverageInfo(std::move(CoverageInfo)), FunctionView(FunctionView) {}
+ CoverageInfo(std::move(CoverageInfo)) {}
public:
static std::unique_ptr<SourceCoverageView>
create(StringRef SourceName, const MemoryBuffer &File,
const CoverageViewOptions &Options,
- coverage::CoverageData &&CoverageInfo, bool FucntionView = false);
+ coverage::CoverageData &&CoverageInfo);
virtual ~SourceCoverageView() {}
- StringRef getSourceName() const { return SourceName; }
-
/// \brief Return the source name formatted for the host OS.
- std::string getNativeSourceName() const;
+ std::string getSourceName() const;
- bool isFunctionView() const { return FunctionView; }
+ /// \brief Return a verbose description of the source name and the binary it
+ /// corresponds to.
+ std::string getVerboseSourceName() const;
const CoverageViewOptions &getOptions() const { return Options; }
void SourceCoverageViewHTML::renderSourceName(raw_ostream &OS, bool WholeFile,
unsigned FirstUncoveredLineNo) {
OS << BeginSourceNameDiv;
- // Render the source name for the view.
- OS << tag("pre", escape(getNativeSourceName(), getOptions()));
+ std::string ViewInfo = escape(
+ WholeFile ? getVerboseSourceName() : getSourceName(), getOptions());
+ OS << tag("pre", ViewInfo);
if (WholeFile) {
- // Render the object file name for the view.
- OS << tag("pre",
- escape("Binary: " + getOptions().ObjectFilename, getOptions()));
// Render the "Go to first unexecuted line" link for the view.
if (FirstUncoveredLineNo != 0) { // The file is not fully covered
std::string LinkText =
public:
SourceCoverageViewHTML(StringRef SourceName, const MemoryBuffer &File,
const CoverageViewOptions &Options,
- coverage::CoverageData &&CoverageInfo,
- bool FunctionView)
- : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo),
- FunctionView) {}
+ coverage::CoverageData &&CoverageInfo)
+ : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
+ }
};
} // namespace llvm
void SourceCoverageViewText::renderSourceName(raw_ostream &OS, bool WholeFile,
unsigned FirstUncoveredLineNo) {
- getOptions().colored_ostream(OS, raw_ostream::CYAN) << getNativeSourceName()
- << ":\n";
- if (WholeFile) {
- getOptions().colored_ostream(OS, raw_ostream::CYAN)
- << "Binary: " << getOptions().ObjectFilename << ":\n";
- }
+ std::string ViewInfo = WholeFile ? getVerboseSourceName() : getSourceName();
+ getOptions().colored_ostream(OS, raw_ostream::CYAN) << ViewInfo << ":\n";
}
void SourceCoverageViewText::renderLinePrefix(raw_ostream &OS,
public:
SourceCoverageViewText(StringRef SourceName, const MemoryBuffer &File,
const CoverageViewOptions &Options,
- coverage::CoverageData &&CoverageInfo,
- bool FunctionView)
- : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo),
- FunctionView) {}
+ coverage::CoverageData &&CoverageInfo)
+ : SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
+ }
};
} // namespace llvm