diff options
author | Petr Hosek <phosek@google.com> | 2021-02-24 10:26:11 -0800 |
---|---|---|
committer | Petr Hosek <phosek@google.com> | 2021-02-24 13:42:45 -0800 |
commit | 80f329bcd0281c11062879025761d0657167fe8b (patch) | |
tree | d813d16aec1d978dd4b3fecdf80b12ee0420f1e9 /llvm/unittests/ProfileData/CoverageMappingTest.cpp | |
parent | 01701646d5555409a6fad920f0e4801d79c154ea (diff) | |
download | llvm-80f329bcd0281c11062879025761d0657167fe8b.zip llvm-80f329bcd0281c11062879025761d0657167fe8b.tar.gz llvm-80f329bcd0281c11062879025761d0657167fe8b.tar.bz2 |
[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
Diffstat (limited to 'llvm/unittests/ProfileData/CoverageMappingTest.cpp')
-rw-r--r-- | llvm/unittests/ProfileData/CoverageMappingTest.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/unittests/ProfileData/CoverageMappingTest.cpp b/llvm/unittests/ProfileData/CoverageMappingTest.cpp index d1bb87a..3f9a00b 100644 --- a/llvm/unittests/ProfileData/CoverageMappingTest.cpp +++ b/llvm/unittests/ProfileData/CoverageMappingTest.cpp @@ -145,8 +145,10 @@ struct CoverageMappingTest : ::testing::TestWithParam<std::pair<bool, bool>> { 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 @@ struct CoverageMappingTest : ::testing::TestWithParam<std::pair<bool, bool>> { 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)); |