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