1//===- BuildNamespace.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#include "clang/ScalableStaticAnalysisFramework/Core/Model/BuildNamespace.h"
10#include "../ModelStringConversions.h"
11#include "llvm/ADT/STLExtras.h"
12#include "llvm/Support/ErrorHandling.h"
13#include <tuple>
14
15namespace clang::ssaf {
16
17BuildNamespace
18BuildNamespace::makeCompilationUnit(llvm::StringRef CompilationId) {
19 return BuildNamespace{BuildNamespaceKind::CompilationUnit,
20 CompilationId.str()};
21}
22
23bool BuildNamespace::operator==(const BuildNamespace &Other) const {
24 return asTuple() == Other.asTuple();
25}
26
27bool BuildNamespace::operator!=(const BuildNamespace &Other) const {
28 return !(*this == Other);
29}
30
31bool BuildNamespace::operator<(const BuildNamespace &Other) const {
32 return asTuple() < Other.asTuple();
33}
34
35NestedBuildNamespace
36NestedBuildNamespace::makeCompilationUnit(llvm::StringRef CompilationId) {
37 NestedBuildNamespace Result;
38 Result.Namespaces.push_back(
39 x: BuildNamespace::makeCompilationUnit(CompilationId));
40 return Result;
41}
42
43bool NestedBuildNamespace::empty() const { return Namespaces.empty(); }
44
45bool NestedBuildNamespace::operator==(const NestedBuildNamespace &Other) const {
46 return Namespaces == Other.Namespaces;
47}
48
49bool NestedBuildNamespace::operator!=(const NestedBuildNamespace &Other) const {
50 return !(*this == Other);
51}
52
53bool NestedBuildNamespace::operator<(const NestedBuildNamespace &Other) const {
54 return Namespaces < Other.Namespaces;
55}
56
57llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, BuildNamespaceKind BNK) {
58 return OS << buildNamespaceKindToString(BNK);
59}
60
61llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const BuildNamespace &BN) {
62 return OS << "BuildNamespace(" << BN.Kind << ", " << BN.Name << ")";
63}
64
65llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
66 const NestedBuildNamespace &NBN) {
67 OS << "NestedBuildNamespace([";
68 llvm::interleaveComma(c: NBN.Namespaces, os&: OS);
69 OS << "])";
70 return OS;
71}
72
73} // namespace clang::ssaf
74