/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 | 328 | SourceLocationsLattice::join(const SourceLocationsLattice &Other) { |
27 | 328 | auto SizeBefore = Locs.size(); |
28 | 328 | Locs.insert(Other.Locs.begin(), Other.Locs.end()); |
29 | 328 | return SizeBefore == Locs.size() ? LatticeJoinEffect::Unchanged265 |
30 | 328 | : LatticeJoinEffect::Changed63 ; |
31 | 328 | } |
32 | | |
33 | | std::string DebugString(const SourceLocationsLattice &Lattice, |
34 | 123 | const ASTContext &Context) { |
35 | 123 | if (Lattice.getSourceLocations().empty()) |
36 | 0 | return ""; |
37 | | |
38 | 123 | std::vector<std::string> Locations; |
39 | 123 | Locations.reserve(Lattice.getSourceLocations().size()); |
40 | 123 | for (const clang::SourceLocation &Loc : Lattice.getSourceLocations()) { |
41 | 123 | Locations.push_back(Loc.printToString(Context.getSourceManager())); |
42 | 123 | } |
43 | 123 | std::sort(Locations.begin(), Locations.end()); |
44 | 123 | std::string result; |
45 | 123 | llvm::raw_string_ostream OS(result); |
46 | 123 | llvm::interleaveComma(Locations, OS); |
47 | 123 | return result; |
48 | 123 | } |
49 | | |
50 | | } // namespace dataflow |
51 | | } // namespace clang |