1 //===- Core/UndefinedAtom.h - An Undefined Atom ---------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLD_CORE_UNDEFINED_ATOM_H
10 #define LLD_CORE_UNDEFINED_ATOM_H
12 #include "lld/Core/Atom.h"
16 /// An UndefinedAtom has no content.
17 /// It exists as a placeholder for a future atom.
18 class UndefinedAtom : public Atom {
20 /// Whether this undefined symbol needs to be resolved,
21 /// or whether it can just evaluate to nullptr.
22 /// This concept is often called "weak", but that term
23 /// is overloaded to mean other things too.
25 /// Normal symbols must be resolved at build time
28 /// This symbol can be missing at runtime and will evalute to nullptr.
29 /// That is, the static linker still must find a definition (usually
30 /// is some shared library), but at runtime, the dynamic loader
31 /// will allow the symbol to be missing and resolved to nullptr.
33 /// On Darwin this is generated using a function prototype with
34 /// __attribute__((weak_import)).
35 /// On linux this is generated using a function prototype with
36 /// __attribute__((weak)).
37 /// On Windows this feature is not supported.
40 /// This symbol can be missing at build time.
41 /// That is, the static linker will not error if a definition for
42 /// this symbol is not found at build time. Instead, the linker
43 /// will build an executable that lets the dynamic loader find the
44 /// symbol at runtime.
45 /// This feature is not supported on Darwin nor Windows.
46 /// On linux this is generated using a function prototype with
47 /// __attribute__((weak)).
51 virtual CanBeNull canBeNull() const = 0;
53 static bool classof(const Atom *a) {
54 return a->definition() == definitionUndefined;
57 static bool classof(const UndefinedAtom *) { return true; }
60 UndefinedAtom() : Atom(definitionUndefined) {}
62 ~UndefinedAtom() override = default;
67 #endif // LLD_CORE_UNDEFINED_ATOM_H