[Coverage] Assert that filenames in a TU are unique, NFC

llvm-svn: 372024
This commit is contained in:
Vedant Kumar 2019-09-16 19:08:41 +00:00
parent dd63b9f570
commit 95de24978e
2 changed files with 11 additions and 2 deletions

View File

@ -30,8 +30,7 @@ class CoverageFilenamesSectionWriter {
ArrayRef<StringRef> Filenames;
public:
CoverageFilenamesSectionWriter(ArrayRef<StringRef> Filenames)
: Filenames(Filenames) {}
CoverageFilenamesSectionWriter(ArrayRef<StringRef> Filenames);
/// Write encoded filenames to the given output stream.
void write(raw_ostream &OS);

View File

@ -24,6 +24,16 @@
using namespace llvm;
using namespace coverage;
CoverageFilenamesSectionWriter::CoverageFilenamesSectionWriter(
ArrayRef<StringRef> Filenames)
: Filenames(Filenames) {
#ifndef NDEBUG
StringSet<> NameSet;
for (StringRef Name : Filenames)
assert(NameSet.insert(Name).second && "Duplicate filename");
#endif
}
void CoverageFilenamesSectionWriter::write(raw_ostream &OS) {
encodeULEB128(Filenames.size(), OS);
for (const auto &Filename : Filenames) {