Coverage Report

Created: 2023-10-30 17:15

/builds/2mk6rsew/0/parcoach/parcoach/src/include/parcoach/andersen/PtsSet.h
Line
Count
Source (jump to first uncovered line)
1
#ifndef ANDERSEN_PTSSET_H
2
#define ANDERSEN_PTSSET_H
3
4
#include "llvm/ADT/SparseBitVector.h"
5
6
// We move the points-to set representation here into a separate class
7
// The intention is to let us try out different internal implementation of this
8
// data-structure (e.g. vectors/bitvecs/sets, ref-counted/non-refcounted) easily
9
class AndersPtsSet {
10
private:
11
  llvm::SparseBitVector<> bitvec;
12
13
public:
14
  using iterator = llvm::SparseBitVector<>::iterator;
15
16
  // Return true if *this has idx as an element
17
  // This function should be marked const, but we cannot do it because
18
  // SparseBitVector::test() is not marked const. WHY???
19
0
  bool has(unsigned idx) { return bitvec.test(idx); }
20
0
  bool has(unsigned idx) const {
21
0
    // Since llvm::SparseBitVector::test() does not have a const quantifier, we
22
0
    // have to use this ugly workaround to implement has()
23
0
    llvm::SparseBitVector<> idVec;
24
0
    idVec.set(idx);
25
0
    return bitvec.contains(idVec);
26
0
  }
27
28
  // Return true if the ptsset changes
29
45.9k
  bool insert(unsigned idx) { return bitvec.test_and_set(idx); }
30
31
  // Return true if *this is a superset of other
32
0
  bool contains(AndersPtsSet const &other) const {
33
0
    return bitvec.contains(other.bitvec);
34
0
  }
35
36
  // intersectWith: return true if *this and other share points-to elements
37
0
  bool intersectWith(AndersPtsSet const &other) const {
38
0
    return bitvec.intersects(other.bitvec);
39
0
  }
40
41
  // Return true if the ptsset changes
42
88.1k
  bool unionWith(AndersPtsSet const &other) { return bitvec |= other.bitvec; }
43
44
0
  void clear() { bitvec.clear(); }
45
46
0
  unsigned getSize() const {
47
0
    return bitvec.count(); // NOT a constant time operation!
48
0
  }
49
  bool
50
  isEmpty() const // Always prefer using this function to perform empty test
51
0
  {
52
0
    return bitvec.empty();
53
0
  }
54
55
8.48k
  bool operator==(AndersPtsSet const &other) const {
56
8.48k
    return bitvec == other.bitvec;
57
8.48k
  }
58
59
295k
  iterator begin() const { return bitvec.begin(); }
60
295k
  iterator end() const { return bitvec.end(); }
61
};
62
63
#endif