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

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 16 12:08:42 PDT 2019


Author: vedantk
Date: Mon Sep 16 12:08:41 2019
New Revision: 372024

URL: http://llvm.org/viewvc/llvm-project?rev=372024&view=rev
Log:
[Coverage] Assert that filenames in a TU are unique, NFC

Modified:
    llvm/trunk/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h
    llvm/trunk/lib/ProfileData/Coverage/CoverageMappingWriter.cpp

Modified: llvm/trunk/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h?rev=372024&r1=372023&r2=372024&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h (original)
+++ llvm/trunk/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h Mon Sep 16 12:08:41 2019
@@ -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);

Modified: llvm/trunk/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/Coverage/CoverageMappingWriter.cpp?rev=372024&r1=372023&r2=372024&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/Coverage/CoverageMappingWriter.cpp (original)
+++ llvm/trunk/lib/ProfileData/Coverage/CoverageMappingWriter.cpp Mon Sep 16 12:08:41 2019
@@ -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) {




More information about the llvm-commits mailing list