Coverage Report

Created: 2022-05-14 11:35

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Analysis/FlowSensitive/SourceLocationsLattice.h
Line
Count
Source
1
//===-- SourceLocationsLattice.h --------------------------------*- 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 a lattice that collects source locations of interest.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_SOURCELOCATIONS_LATTICE_H
14
#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_SOURCELOCATIONS_LATTICE_H
15
16
#include "clang/AST/ASTContext.h"
17
#include "clang/Analysis/FlowSensitive/DataflowLattice.h"
18
#include "clang/Basic/SourceLocation.h"
19
#include "llvm/ADT/DenseSet.h"
20
#include <string>
21
#include <utility>
22
23
namespace clang {
24
namespace dataflow {
25
26
/// Lattice for dataflow analysis that keeps track of a set of source locations.
27
///
28
/// Bottom is the empty set, join is set union, and equality is set equality.
29
///
30
/// FIXME: Generalize into a (templated) PowerSetLattice.
31
class SourceLocationsLattice {
32
public:
33
332
  SourceLocationsLattice() = default;
34
35
  explicit SourceLocationsLattice(llvm::DenseSet<SourceLocation> Locs)
36
      : Locs(std::move(Locs)) {}
37
38
12
  bool operator==(const SourceLocationsLattice &Other) const {
39
12
    return Locs == Other.Locs;
40
12
  }
41
42
  bool operator!=(const SourceLocationsLattice &Other) const {
43
    return !(*this == Other);
44
  }
45
46
  LatticeJoinEffect join(const SourceLocationsLattice &Other);
47
48
162
  llvm::DenseSet<SourceLocation> &getSourceLocations() { return Locs; }
49
50
438
  const llvm::DenseSet<SourceLocation> &getSourceLocations() const {
51
438
    return Locs;
52
438
  }
53
54
private:
55
  llvm::DenseSet<SourceLocation> Locs;
56
};
57
58
/// Returns a string that represents the source locations of the lattice.
59
std::string DebugString(const SourceLocationsLattice &Lattice,
60
                        const ASTContext &Context);
61
62
} // namespace dataflow
63
} // namespace clang
64
65
#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_SOURCELOCATIONS_LATTICE_H