aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CoverageMappingGen.cpp
diff options
context:
space:
mode:
authorKeith Smiley <keithbsmiley@gmail.com>2021-01-25 10:03:07 -0800
committerKeith Smiley <keithbsmiley@gmail.com>2021-01-25 10:14:04 -0800
commitc3324450b204392169d4ec7172cb32f74c03e376 (patch)
tree48046e8312929ecd40d20dfa2b72de7a15c679dd /clang/lib/CodeGen/CoverageMappingGen.cpp
parentf851db3dae5cc24ce1897918bd69fa989aa31b59 (diff)
downloadllvm-c3324450b204392169d4ec7172cb32f74c03e376.zip
llvm-c3324450b204392169d4ec7172cb32f74c03e376.tar.gz
llvm-c3324450b204392169d4ec7172cb32f74c03e376.tar.bz2
[clang] Add -fprofile-prefix-map
This flag allows you to re-write absolute paths in coverage data analogous to -fdebug-prefix-map. This flag is also implied by -ffile-prefix-map.
Diffstat (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp')
-rw-r--r--clang/lib/CodeGen/CoverageMappingGen.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index c474546..5c25c20 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1544,13 +1544,6 @@ struct CounterCoverageMappingBuilder
}
};
-std::string normalizeFilename(StringRef Filename) {
- llvm::SmallString<256> Path(Filename);
- llvm::sys::fs::make_absolute(Path);
- llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
- return std::string(Path);
-}
-
} // end anonymous namespace
static void dump(llvm::raw_ostream &OS, StringRef FunctionName,
@@ -1592,6 +1585,23 @@ static void dump(llvm::raw_ostream &OS, StringRef FunctionName,
}
}
+CoverageMappingModuleGen::CoverageMappingModuleGen(
+ CodeGenModule &CGM, CoverageSourceInfo &SourceInfo)
+ : CGM(CGM), SourceInfo(SourceInfo) {
+ ProfilePrefixMap = CGM.getCodeGenOpts().ProfilePrefixMap;
+}
+
+std::string CoverageMappingModuleGen::normalizeFilename(StringRef Filename) {
+ llvm::SmallString<256> Path(Filename);
+ llvm::sys::fs::make_absolute(Path);
+ llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
+ for (const auto &Entry : ProfilePrefixMap) {
+ if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))
+ break;
+ }
+ return Path.str().str();
+}
+
static std::string getInstrProfSection(const CodeGenModule &CGM,
llvm::InstrProfSectKind SK) {
return llvm::getInstrProfSectionName(