clang 23.0.0git
MultiArchSharedLibrary.h
Go to the documentation of this file.
1//===- MultiArchSharedLibrary.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 the MultiArchSharedLibrary class, which represents a
10// multi-architecture wrapper around per-architecture LUSummaryEncoding
11// instances (the SSAF analogue of a Mach-O fat shared library/dylib, e.g.
12// one produced by `lipo -create` over per-arch `.dylib` files).
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_CLANG_SCALABLESTATICANALYSIS_CORE_ENTITYLINKER_MULTIARCHSHAREDLIBRARY_H
17#define LLVM_CLANG_SCALABLESTATICANALYSIS_CORE_ENTITYLINKER_MULTIARCHSHAREDLIBRARY_H
18
21#include <memory>
22#include <set>
23#include <tuple>
24
25namespace clang::ssaf {
26
27/// Represents a multi-architecture shared library.
28///
29/// A MultiArchSharedLibrary bundles per-architecture LUSummaryEncoding
30/// members, mirroring the role of a Mach-O fat shared library (the result
31/// of `lipo -create` over per-architecture `.dylib` files). All members
32/// represent the same logical shared library built for different
33/// architectures; the wrapper's \c Namespace is the nested build
34/// namespace identifying that shared library, and every member's
35/// \c LUNamespace must equal it exactly.
37 friend class SerializationFormat;
38 friend class TestFixture;
39
40 /// Orders members by their TargetTriple's canonical enum components.
41 /// llvm::Triple's parser maps alias spellings to the same enum values
42 /// (e.g. "aarch64" and "arm64" both become Triple::aarch64), so a
43 /// tuple-of-enums compare is equivalent to comparing normalized triples
44 /// for identity, but without the per-call string allocation.
45 struct MemberByTargetTriple {
46 static auto key(const llvm::Triple &T) {
47 return std::make_tuple(T.getArch(), T.getSubArch(), T.getVendor(),
48 T.getOS(), T.getEnvironment(),
49 T.getObjectFormat());
50 }
51 bool operator()(const std::unique_ptr<LUSummaryEncoding> &A,
52 const std::unique_ptr<LUSummaryEncoding> &B) const {
53 return key(A->TargetTriple) < key(B->TargetTriple);
54 }
55 };
56
57 // The nested namespace identifying this multi-architecture shared
58 // library. It matches the LUNamespace of every member exactly (same
59 // path, same kinds, same names): the shared library's identity is the
60 // same across all its architecture slices.
61 NestedBuildNamespace Namespace;
62
63 // LUSummaryEncoding objects ordered by TargetTriple enum components.
64 // Two members with the same TargetTriple are not permitted.
65 std::set<std::unique_ptr<LUSummaryEncoding>, MemberByTargetTriple> Members;
66
67public:
69 : Namespace(std::move(Namespace)) {}
70};
71
72} // namespace clang::ssaf
73
74#endif // LLVM_CLANG_SCALABLESTATICANALYSIS_CORE_ENTITYLINKER_MULTIARCHSHAREDLIBRARY_H
MultiArchSharedLibrary(NestedBuildNamespace Namespace)
Represents a hierarchical sequence of build namespaces.