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