[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 13:43:21 PST 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG80f329bcd028: [Profile] Include a few asserts in coverage mapping test (authored by phosek).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97402/new/

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.326195.patch
Type: text/x-patch
Size: 1124 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210224/f95a5181/attachment.bin>


More information about the llvm-commits mailing list