Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/ADT/SetOperations.h
Line
Count
Source
1
//===-- llvm/ADT/SetOperations.h - Generic Set Operations -------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file defines generic set operations that may be used on set's of
10
// different types, and different element types.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_ADT_SETOPERATIONS_H
15
#define LLVM_ADT_SETOPERATIONS_H
16
17
namespace llvm {
18
19
/// set_union(A, B) - Compute A := A u B, return whether A changed.
20
///
21
template <class S1Ty, class S2Ty>
22
66.6M
bool set_union(S1Ty &S1, const S2Ty &S2) {
23
66.6M
  bool Changed = false;
24
66.6M
25
66.6M
  for (typename S2Ty::const_iterator SI = S2.begin(), SE = S2.end();
26
127M
       SI != SE; 
++SI60.6M
)
27
60.6M
    if (S1.insert(*SI).second)
28
48.5M
      Changed = true;
29
66.6M
30
66.6M
  return Changed;
31
66.6M
}
bool llvm::set_union<llvm::DenseSet<unsigned int, llvm::DenseMapInfo<unsigned int> >, llvm::SmallVector<unsigned int, 16u> >(llvm::DenseSet<unsigned int, llvm::DenseMapInfo<unsigned int> >&, llvm::SmallVector<unsigned int, 16u> const&)
Line
Count
Source
22
66.6M
bool set_union(S1Ty &S1, const S2Ty &S2) {
23
66.6M
  bool Changed = false;
24
66.6M
25
66.6M
  for (typename S2Ty::const_iterator SI = S2.begin(), SE = S2.end();
26
127M
       SI != SE; 
++SI60.6M
)
27
60.6M
    if (S1.insert(*SI).second)
28
48.5M
      Changed = true;
29
66.6M
30
66.6M
  return Changed;
31
66.6M
}
bool llvm::set_union<llvm::DenseSet<llvm::Value const*, llvm::DenseMapInfo<llvm::Value const*> >, llvm::DenseSet<llvm::Value const*, llvm::DenseMapInfo<llvm::Value const*> > >(llvm::DenseSet<llvm::Value const*, llvm::DenseMapInfo<llvm::Value const*> >&, llvm::DenseSet<llvm::Value const*, llvm::DenseMapInfo<llvm::Value const*> > const&)
Line
Count
Source
22
53
bool set_union(S1Ty &S1, const S2Ty &S2) {
23
53
  bool Changed = false;
24
53
25
53
  for (typename S2Ty::const_iterator SI = S2.begin(), SE = S2.end();
26
120
       SI != SE; 
++SI67
)
27
67
    if (S1.insert(*SI).second)
28
67
      Changed = true;
29
53
30
53
  return Changed;
31
53
}
32
33
/// set_intersect(A, B) - Compute A := A ^ B
34
/// Identical to set_intersection, except that it works on set<>'s and
35
/// is nicer to use.  Functionally, this iterates through S1, removing
36
/// elements that are not contained in S2.
37
///
38
template <class S1Ty, class S2Ty>
39
581k
void set_intersect(S1Ty &S1, const S2Ty &S2) {
40
1.11M
   for (typename S1Ty::iterator I = S1.begin(); I != S1.end();) {
41
528k
     const auto &E = *I;
42
528k
     ++I;
43
528k
     if (!S2.count(E)) 
S1.erase(E)494k
; // Erase element if not in S2
44
528k
   }
45
581k
}
void llvm::set_intersect<llvm::DenseSet<llvm::Value const*, llvm::DenseMapInfo<llvm::Value const*> >, llvm::DenseSet<llvm::Value const*, llvm::DenseMapInfo<llvm::Value const*> > >(llvm::DenseSet<llvm::Value const*, llvm::DenseMapInfo<llvm::Value const*> >&, llvm::DenseSet<llvm::Value const*, llvm::DenseMapInfo<llvm::Value const*> > const&)
Line
Count
Source
39
59
void set_intersect(S1Ty &S1, const S2Ty &S2) {
40
189
   for (typename S1Ty::iterator I = S1.begin(); I != S1.end();) {
41
130
     const auto &E = *I;
42
130
     ++I;
43
130
     if (!S2.count(E)) 
S1.erase(E)33
; // Erase element if not in S2
44
130
   }
45
59
}
void llvm::set_intersect<llvm::SmallPtrSet<llvm::BasicBlock*, 4u>, llvm::SmallPtrSet<llvm::BasicBlock*, 4u> >(llvm::SmallPtrSet<llvm::BasicBlock*, 4u>&, llvm::SmallPtrSet<llvm::BasicBlock*, 4u> const&)
Line
Count
Source
39
90
void set_intersect(S1Ty &S1, const S2Ty &S2) {
40
210
   for (typename S1Ty::iterator I = S1.begin(); I != S1.end();) {
41
120
     const auto &E = *I;
42
120
     ++I;
43
120
     if (!S2.count(E)) 
S1.erase(E)51
; // Erase element if not in S2
44
120
   }
45
90
}
void llvm::set_intersect<llvm::SmallPtrSet<llvm::Value*, 4u>, llvm::SmallPtrSet<llvm::Value*, 4u> >(llvm::SmallPtrSet<llvm::Value*, 4u>&, llvm::SmallPtrSet<llvm::Value*, 4u> const&)
Line
Count
Source
39
581k
void set_intersect(S1Ty &S1, const S2Ty &S2) {
40
1.11M
   for (typename S1Ty::iterator I = S1.begin(); I != S1.end();) {
41
528k
     const auto &E = *I;
42
528k
     ++I;
43
528k
     if (!S2.count(E)) 
S1.erase(E)494k
; // Erase element if not in S2
44
528k
   }
45
581k
}
46
47
/// set_difference(A, B) - Return A - B
48
///
49
template <class S1Ty, class S2Ty>
50
51
S1Ty set_difference(const S1Ty &S1, const S2Ty &S2) {
51
51
  S1Ty Result;
52
51
  for (typename S1Ty::const_iterator SI = S1.begin(), SE = S1.end();
53
62
       SI != SE; 
++SI11
)
54
11
    if (!S2.count(*SI))       // if the element is not in set2
55
9
      Result.insert(*SI);
56
51
  return Result;
57
51
}
58
59
/// set_subtract(A, B) - Compute A := A - B
60
///
61
template <class S1Ty, class S2Ty>
62
66.6M
void set_subtract(S1Ty &S1, const S2Ty &S2) {
63
66.6M
  for (typename S2Ty::const_iterator SI = S2.begin(), SE = S2.end();
64
92.4M
       SI != SE; 
++SI25.7M
)
65
25.7M
    S1.erase(*SI);
66
66.6M
}
67
68
} // End llvm namespace
69
70
#endif