clang 22.0.0git
BuildNamespace.cpp
Go to the documentation of this file.
1//===- BuildNamespace.cpp ---------------------------------------*- 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
10#include "llvm/Support/ErrorHandling.h"
11#include <tuple>
12
13namespace clang::ssaf {
14
15llvm::StringRef toString(BuildNamespaceKind BNK) {
16 switch (BNK) {
18 return "compilation_unit";
20 return "link_unit";
21 }
22 llvm_unreachable("Unknown BuildNamespaceKind");
23}
24
25std::optional<BuildNamespaceKind> parseBuildNamespaceKind(llvm::StringRef Str) {
26 if (Str == "compilation_unit")
28 if (Str == "link_unit")
30 return std::nullopt;
31}
32
33BuildNamespace
34BuildNamespace::makeCompilationUnit(llvm::StringRef CompilationId) {
36 CompilationId.str()};
37}
38
40 return asTuple() == Other.asTuple();
41}
42
44 return !(*this == Other);
45}
46
48 return asTuple() < Other.asTuple();
49}
50
52NestedBuildNamespace::makeCompilationUnit(llvm::StringRef CompilationId) {
54 Result.Namespaces.push_back(
56 return Result;
57}
58
59bool NestedBuildNamespace::empty() const { return Namespaces.empty(); }
60
62 return Namespaces == Other.Namespaces;
63}
64
66 return !(*this == Other);
67}
68
70 return Namespaces < Other.Namespaces;
71}
72
73} // namespace clang::ssaf
BuildNamespace(BuildNamespaceKind Kind, llvm::StringRef Name)
bool operator<(const BuildNamespace &Other) const
bool operator!=(const BuildNamespace &Other) const
static BuildNamespace makeCompilationUnit(llvm::StringRef CompilationId)
Creates a BuildNamespace representing a compilation unit.
bool operator==(const BuildNamespace &Other) const
Represents a hierarchical sequence of build namespaces.
static NestedBuildNamespace makeCompilationUnit(llvm::StringRef CompilationId)
Creates a NestedBuildNamespace representing a compilation unit.
bool operator<(const NestedBuildNamespace &Other) const
bool operator!=(const NestedBuildNamespace &Other) const
bool operator==(const NestedBuildNamespace &Other) const
std::optional< BuildNamespaceKind > parseBuildNamespaceKind(llvm::StringRef Str)
llvm::StringRef toString(BuildNamespaceKind BNK)
@ Result
The result type of a method or function.
Definition TypeBase.h:905
@ Other
Other implicit parameter.
Definition Decl.h:1746