llvm_wrap/
link.rs

1//! A renamed `LLVMLinkage`
2use super::*;
3
4/// A renamed `LLVMLinkage`
5///
6/// *Some deprecated values have been removed, see `LLVMLinkage`*
7#[derive(Copy, Clone, Debug, Eq, PartialEq)]
8pub enum Linkage {
9    /// The default, externally visible linkage type
10    External = 0,
11    /// Globals will not be emitted to the object file and definitions will be used for
12    /// optimization purposes, allowing inlining and discarding
13    AvailableExternally = 1,
14    /// Globals are merged with other globals of the same name during linkage and unused globals
15    /// are discarded
16    LinkOnceAny = 2,
17    /// Similar to `LinkOnceAny`, but it allows further optimizations by ensuring that only globals
18    /// with equivalent definitions are merged
19    LinkOnceODR = 3,
20    /// Similar to `LinkOnceAny`, but unused globals are not discarded
21    WeakAny = 5,
22    /// Similar to `LinkOnceODR`, but unused globals are not discarded
23    WeakODR = 6,
24    /// Global arrays are appended together when linkage occurs
25    Appending = 7,
26    /// Similar to `Private`, but values are represented as local symbols
27    Internal = 8,
28    /// Globals are only directly accessible by objects in the current module
29    Private = 9,
30    /// The symbol is `Weak` until linked, otherwise it becomes null instead of undefined
31    ExternalWeak = 12,
32    /// Used for tentative definitions at global scope, similar to `Weak`
33    Common = 14,
34}
35
36impl Linkage {
37    /// The `LLVMLinkage` this value represents
38    pub fn inner(&self) -> LLVMLinkage {
39        use llvm_sys::LLVMLinkage::*;
40        use self::Linkage::*;
41        match self {
42            &External => LLVMExternalLinkage,
43            &AvailableExternally => LLVMAvailableExternallyLinkage,
44            &LinkOnceAny => LLVMLinkOnceAnyLinkage,
45            &LinkOnceODR => LLVMLinkOnceODRLinkage,
46            &WeakAny => LLVMWeakAnyLinkage,
47            &WeakODR => LLVMWeakODRLinkage,
48            &Appending => LLVMAppendingLinkage,
49            &Internal => LLVMInternalLinkage,
50            &Private => LLVMPrivateLinkage,
51            &ExternalWeak => LLVMExternalWeakLinkage,
52            &Common => LLVMCommonLinkage,
53        }
54    }
55}