diff options
| author | Justin Bogner <mail@justinbogner.com> | 2014-04-23 21:44:55 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2014-04-23 21:44:55 +0000 |
| commit | c67f0250ef817ae4d3c749c82cf8de2e2eac5c99 (patch) | |
| tree | 1a903bef4a7d5e79d89bdd34852987a468f0272c /llvm/lib | |
| parent | bac905c684f734c4a110acd0b94deacb29b5a475 (diff) | |
| download | bcm5719-llvm-c67f0250ef817ae4d3c749c82cf8de2e2eac5c99.tar.gz bcm5719-llvm-c67f0250ef817ae4d3c749c82cf8de2e2eac5c99.zip | |
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.
llvm-svn: 207035
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/IR/GCOV.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/IR/GCOV.cpp b/llvm/lib/IR/GCOV.cpp index 0e344ddfead..8f060d2ac90 100644 --- a/llvm/lib/IR/GCOV.cpp +++ b/llvm/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()) |

