1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[Profile] Include a few asserts in coverage mapping test

These should catch any accidental use of the compilation directory.

Differential Revision: https://reviews.llvm.org/D97402
This commit is contained in:
Petr Hosek 2021-02-24 10:26:11 -08:00
parent 5c2785ddb8
commit eceb39715e

View File

@ -145,8 +145,10 @@ struct CoverageMappingTest : ::testing::TestWithParam<std::pair<bool, bool>> {
unsigned getGlobalFileIndex(StringRef Name) { unsigned getGlobalFileIndex(StringRef Name) {
auto R = Files.find(Name); auto R = Files.find(Name);
if (R != Files.end()) if (R != Files.end()) {
assert(R->second > 0 && "got index of compilation dir");
return R->second; return R->second;
}
unsigned Index = Files.size() + 1; unsigned Index = Files.size() + 1;
Files.try_emplace(Name, Index); Files.try_emplace(Name, Index);
return Index; return Index;
@ -161,8 +163,10 @@ struct CoverageMappingTest : ::testing::TestWithParam<std::pair<bool, bool>> {
auto &CurrentFunctionFileMapping = auto &CurrentFunctionFileMapping =
InputFunctions.back().ReverseVirtualFileMapping; InputFunctions.back().ReverseVirtualFileMapping;
auto R = CurrentFunctionFileMapping.find(GlobalIndex); auto R = CurrentFunctionFileMapping.find(GlobalIndex);
if (R != CurrentFunctionFileMapping.end()) if (R != CurrentFunctionFileMapping.end()) {
assert(R->second > 0 && "got index of compilation dir");
return R->second; return R->second;
}
unsigned IndexInFunction = CurrentFunctionFileMapping.size(); unsigned IndexInFunction = CurrentFunctionFileMapping.size();
CurrentFunctionFileMapping.insert( CurrentFunctionFileMapping.insert(
std::make_pair(GlobalIndex, IndexInFunction)); std::make_pair(GlobalIndex, IndexInFunction));