summaryrefslogtreecommitdiff
path: root/lib/IR/GCOV.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-04-23 21:44:55 +0000
committerJustin Bogner <mail@justinbogner.com>2014-04-23 21:44:55 +0000
commitde2703ddfb7730fcfaf718f89b1561a539240a72 (patch)
treeb4b9e4885dc9f8fc282680137e148396b3d224ff /lib/IR/GCOV.cpp
parentedcd7c718f9312d3ca6d3501d8b844760b648cd3 (diff)
downloadllvm-de2703ddfb7730fcfaf718f89b1561a539240a72.tar.gz
llvm-de2703ddfb7730fcfaf718f89b1561a539240a72.tar.bz2
llvm-de2703ddfb7730fcfaf718f89b1561a539240a72.tar.xz
llvm-cov: Add support for gcov's --long-file-names option
GCOV provides an option to prepend output file names with the source file name, to disambiguate between covered data that's included from multiple sources. Add a flag to llvm-cov that does the same. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207035 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/GCOV.cpp')
-rw-r--r--lib/IR/GCOV.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/IR/GCOV.cpp b/lib/IR/GCOV.cpp
index 0e344ddfea..8f060d2ac9 100644
--- a/lib/IR/GCOV.cpp
+++ b/lib/IR/GCOV.cpp
@@ -424,7 +424,7 @@ static raw_ostream &operator<<(raw_ostream &OS, const formatBranchInfo &FBI) {
/// translates "/" to "#", ".." to "^", and drops ".", to match gcov.
static std::string mangleCoveragePath(StringRef Filename, bool PreservePaths) {
if (!PreservePaths)
- return (sys::path::filename(Filename) + ".gcov").str();
+ return sys::path::filename(Filename).str();
// This behaviour is defined by gcov in terms of text replacements, so it's
// not likely to do anything useful on filesystems with different textual
@@ -452,12 +452,12 @@ static std::string mangleCoveragePath(StringRef Filename, bool PreservePaths) {
if (S < I)
Result.append(S, I);
- Result.append(".gcov");
return Result.str();
}
/// print - Print source files with collected line count information.
-void FileInfo::print(StringRef GCNOFile, StringRef GCDAFile) {
+void FileInfo::print(StringRef MainFilename, StringRef GCNOFile,
+ StringRef GCDAFile) {
for (StringMap<LineData>::const_iterator I = LineInfo.begin(),
E = LineInfo.end(); I != E; ++I) {
StringRef Filename = I->first();
@@ -468,8 +468,12 @@ void FileInfo::print(StringRef GCNOFile, StringRef GCDAFile) {
}
StringRef AllLines = Buff->getBuffer();
- std::string CoveragePath = mangleCoveragePath(Filename,
- Options.PreservePaths);
+ std::string CoveragePath;
+ if (Options.LongFileNames && !Filename.equals(MainFilename))
+ CoveragePath =
+ mangleCoveragePath(MainFilename, Options.PreservePaths) + "##";
+ CoveragePath +=
+ mangleCoveragePath(Filename, Options.PreservePaths) + ".gcov";
std::string ErrorInfo;
raw_fd_ostream OS(CoveragePath.c_str(), ErrorInfo, sys::fs::F_Text);
if (!ErrorInfo.empty())