Home | History | Annotate | Download | only in Basic
      1 //===--- Linkage.h - Linkage enumeration and utilities ----------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 ///
     10 /// \file
     11 /// \brief Defines the Linkage enumeration and various utility functions.
     12 ///
     13 //===----------------------------------------------------------------------===//
     14 #ifndef LLVM_CLANG_BASIC_LINKAGE_H
     15 #define LLVM_CLANG_BASIC_LINKAGE_H
     16 
     17 namespace clang {
     18 
     19 /// \brief Describes the different kinds of linkage
     20 /// (C++ [basic.link], C99 6.2.2) that an entity may have.
     21 enum Linkage {
     22   /// \brief No linkage, which means that the entity is unique and
     23   /// can only be referred to from within its scope.
     24   NoLinkage = 0,
     25 
     26   /// \brief Internal linkage, which indicates that the entity can
     27   /// be referred to from within the translation unit (but not other
     28   /// translation units).
     29   InternalLinkage,
     30 
     31   /// \brief External linkage within a unique namespace.
     32   ///
     33   /// From the language perspective, these entities have external
     34   /// linkage. However, since they reside in an anonymous namespace,
     35   /// their names are unique to this translation unit, which is
     36   /// equivalent to having internal linkage from the code-generation
     37   /// point of view.
     38   UniqueExternalLinkage,
     39 
     40   /// \brief External linkage, which indicates that the entity can
     41   /// be referred to from other translation units.
     42   ExternalLinkage
     43 };
     44 
     45 /// \brief Describes the different kinds of language linkage
     46 /// (C++ [dcl.link]) that an entity may have.
     47 enum LanguageLinkage {
     48   CLanguageLinkage,
     49   CXXLanguageLinkage,
     50   NoLanguageLinkage
     51 };
     52 
     53 /// \brief A more specific kind of linkage than enum Linkage.
     54 ///
     55 /// This is relevant to CodeGen and AST file reading.
     56 enum GVALinkage {
     57   GVA_Internal,
     58   GVA_C99Inline,
     59   GVA_CXXInline,
     60   GVA_StrongExternal,
     61   GVA_TemplateInstantiation,
     62   GVA_ExplicitTemplateInstantiation
     63 };
     64 
     65 /// \brief Determine whether the given linkage is semantically external.
     66 inline bool isExternalLinkage(Linkage L) {
     67   return L == UniqueExternalLinkage || L == ExternalLinkage;
     68 }
     69 
     70 /// \brief Compute the minimum linkage given two linages.
     71 inline Linkage minLinkage(Linkage L1, Linkage L2) {
     72   return L1 < L2? L1 : L2;
     73 }
     74 
     75 } // end namespace clang
     76 
     77 #endif // LLVM_CLANG_BASIC_LINKAGE_H
     78