clang 24.0.0git
StaticLibrary.h
Go to the documentation of this file.
1//===- StaticLibrary.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 StaticLibrary class, which represents a static
10// library of translation unit summary encodings (the SSAF analogue of an
11// ar / libtool -static / lib.exe output).
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_SCALABLESTATICANALYSIS_CORE_ENTITYLINKER_STATICLIBRARY_H
16#define LLVM_CLANG_SCALABLESTATICANALYSIS_CORE_ENTITYLINKER_STATICLIBRARY_H
17
20#include "llvm/TargetParser/Triple.h"
21#include <memory>
22#include <set>
23
24namespace clang::ssaf {
25
26class StaticLibraryCreateCLI;
27
28/// Represents a static library of translation unit summary encodings.
29///
30/// A StaticLibrary bundles member translation units without performing
31/// entity resolution, mirroring the role of ar / libtool -static / lib.exe
32/// in native build pipelines. It is consumed by the EntityLinker for
33/// selective inclusion when passed as a command line argument.
34///
35/// Static libraries are single-architecture: every member's target triple
36/// must equal the library's. Multi-architecture static libraries are
37/// expressed as a fat wrapper around per-architecture StaticLibrary
38/// instances rather than as a single mixed-architecture library.
39///
40/// Members are stored as encoded TUSummaryEncoding objects: the
41/// static-library tool never decodes per-entity payloads, and the linker
42/// consumes them as-is during its selective inclusion pass.
45 friend class SerializationFormat;
47 friend class TestFixture;
48
49 /// Orders members by their TUNamespace. As a nested struct of
50 /// StaticLibrary, it inherits StaticLibrary's friend access to
51 /// TUSummaryEncoding's private fields.
52 struct MemberByNamespace {
53 bool operator()(const std::unique_ptr<TUSummaryEncoding> &A,
54 const std::unique_ptr<TUSummaryEncoding> &B) const {
55 return A->TUNamespace < B->TUNamespace;
56 }
57 };
58
59 // Target triple of the static library. All member TUs must share this
60 // triple.
61 llvm::Triple TargetTriple;
62
63 // The namespace identifying this static library (kind=StaticLibrary).
64 BuildNamespace Namespace;
65
66 // Member translation units, ordered by their TUNamespace. Membership is
67 // by namespace identity: inserting a TU whose TUNamespace already exists
68 // in the set is rejected during deserialization.
69 std::set<std::unique_ptr<TUSummaryEncoding>, MemberByNamespace> Members;
70
71public:
72 StaticLibrary(llvm::Triple TargetTriple, BuildNamespace Namespace)
73 : TargetTriple(std::move(TargetTriple)), Namespace(std::move(Namespace)) {
74 }
75};
76
77} // namespace clang::ssaf
78
79#endif // LLVM_CLANG_SCALABLESTATICANALYSIS_CORE_ENTITYLINKER_STATICLIBRARY_H
Represents a single namespace in the build process.
StaticLibrary(llvm::Triple TargetTriple, BuildNamespace Namespace)
friend class MultiArchStaticLibrary
friend class StaticLibraryCreateCLI