[PATCH] D97402: [Profile] Include a few asserts in coverage mapping test
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 24 10:28:18 PST 2021
phosek created this revision.
phosek added a reviewer: vsk.
phosek requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
These should catch any accidental use of the compilation directory.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97402
Files:
llvm/unittests/ProfileData/CoverageMappingTest.cpp
Index: llvm/unittests/ProfileData/CoverageMappingTest.cpp
===================================================================
--- llvm/unittests/ProfileData/CoverageMappingTest.cpp
+++ llvm/unittests/ProfileData/CoverageMappingTest.cpp
@@ -145,8 +145,10 @@
unsigned getGlobalFileIndex(StringRef 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;
+ }
unsigned Index = Files.size() + 1;
Files.try_emplace(Name, Index);
return Index;
@@ -161,8 +163,10 @@
auto &CurrentFunctionFileMapping =
InputFunctions.back().ReverseVirtualFileMapping;
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;
+ }
unsigned IndexInFunction = CurrentFunctionFileMapping.size();
CurrentFunctionFileMapping.insert(
std::make_pair(GlobalIndex, IndexInFunction));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97402.326142.patch
Type: text/x-patch
Size: 1124 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210224/62f0e52e/attachment.bin>
More information about the llvm-commits
mailing list