clang 23.0.0git
SSAFBuiltinForceLinker.h
Go to the documentation of this file.
1//===- SSAFBuiltinForceLinker.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/// \file
10/// This file pulls in all built-in SSAF extractor and format registrations
11/// by referencing their anchor symbols, preventing the static linker from
12/// discarding the containing object files.
13///
14/// Include this header (with IWYU pragma: keep) in any translation unit that
15/// must guarantee these registrations are active — typically the entry point
16/// of a binary that uses clangScalableStaticAnalysisFrameworkCore.
17///
18//===----------------------------------------------------------------------===//
19
20#ifndef LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_SSAFBUILTINFORCELINKER_H
21#define LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_SSAFBUILTINFORCELINKER_H
22
23namespace clang::ssaf {
24
25#define ANCHOR(NAME) extern volatile int NAME;
26#include "BuiltinAnchorSources.def"
27
28// Force the linker to link in the built-in SSAF registrations.
29[[maybe_unused]] static const int BuiltinAnchorDestination = [] {
30 int AnchorSources[]{
31#define ANCHOR(NAME) NAME,
32#include "BuiltinAnchorSources.def"
33 };
34
35 int SomeUse = 0;
36 for (int V : AnchorSources)
37 SomeUse |= V;
38 return SomeUse;
39}();
40
41} // namespace clang::ssaf
42
43#endif // LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_SSAFBUILTINFORCELINKER_H
#define V(N, I)
static const int BuiltinAnchorDestination