Coverage Report

Created: 2022-05-21 09:15

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Analysis/FlowSensitive/SourceLocationsLattice.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- SourceLocationsLattice.cpp -----------------------------------------===//
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 implements a lattice that collects source locations of interest.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "clang/Analysis/FlowSensitive/SourceLocationsLattice.h"
14
#include "clang/AST/ASTContext.h"
15
#include "clang/Analysis/FlowSensitive/DataflowLattice.h"
16
#include "llvm/ADT/STLExtras.h"
17
#include "llvm/Support/raw_ostream.h"
18
#include <algorithm>
19
#include <string>
20
#include <vector>
21
22
namespace clang {
23
namespace dataflow {
24
25
LatticeJoinEffect
26
58
SourceLocationsLattice::join(const SourceLocationsLattice &Other) {
27
58
  auto SizeBefore = Locs.size();
28
58
  Locs.insert(Other.Locs.begin(), Other.Locs.end());
29
58
  return SizeBefore == Locs.size() ? 
LatticeJoinEffect::Unchanged39
30
58
                                   : 
LatticeJoinEffect::Changed19
;
31
58
}
32
33
std::string DebugString(const SourceLocationsLattice &Lattice,
34
81
                        const ASTContext &Context) {
35
81
  if (Lattice.getSourceLocations().empty())
36
0
    return "";
37
38
81
  std::vector<std::string> Locations;
39
81
  Locations.reserve(Lattice.getSourceLocations().size());
40
81
  for (const clang::SourceLocation &Loc : Lattice.getSourceLocations()) {
41
81
    Locations.push_back(Loc.printToString(Context.getSourceManager()));
42
81
  }
43
81
  std::sort(Locations.begin(), Locations.end());
44
81
  std::string result;
45
81
  llvm::raw_string_ostream OS(result);
46
81
  llvm::interleaveComma(Locations, OS);
47
81
  return result;
48
81
}
49
50
} // namespace dataflow
51
} // namespace clang