LCOV - code coverage report
Current view: top level - include/llvm/ADT - StringSet.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 9 9 100.0 %
Date: 2018-10-20 13:21:21 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- StringSet.h - The LLVM Compiler Driver -------------------*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open
       6             : // Source License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : //  StringSet - A set-like wrapper for the StringMap.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #ifndef LLVM_ADT_STRINGSET_H
      15             : #define LLVM_ADT_STRINGSET_H
      16             : 
      17             : #include "llvm/ADT/StringMap.h"
      18             : #include "llvm/ADT/StringRef.h"
      19             : #include "llvm/Support/Allocator.h"
      20             : #include <cassert>
      21             : #include <initializer_list>
      22             : #include <utility>
      23             : 
      24             : namespace llvm {
      25             : 
      26             :   /// StringSet - A wrapper for StringMap that provides set-like functionality.
      27             :   template <class AllocatorTy = MallocAllocator>
      28      537061 :   class StringSet : public StringMap<char, AllocatorTy> {
      29             :     using base = StringMap<char, AllocatorTy>;
      30             : 
      31             :   public:
      32             :     StringSet() = default;
      33        4502 :     StringSet(std::initializer_list<StringRef> S) {
      34       61529 :       for (StringRef X : S)
      35             :         insert(X);
      36        4502 :     }
      37             : 
      38             :     std::pair<typename base::iterator, bool> insert(StringRef Key) {
      39             :       assert(!Key.empty());
      40   227203589 :       return base::insert(std::make_pair(Key, '\0'));
      41             :     }
      42             : 
      43             :     template <typename InputIt>
      44        2617 :     void insert(const InputIt &Begin, const InputIt &End) {
      45        2628 :       for (auto It = Begin; It != End; ++It)
      46          22 :         base::insert(std::make_pair(*It, '\0'));
      47        2617 :     }
      48             :   };
      49             : 
      50             : } // end namespace llvm
      51             : 
      52             : #endif // LLVM_ADT_STRINGSET_H

Generated by: LCOV version 1.13