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