clang API Documentation

Linkage.h
Go to the documentation of this file.
00001 //===--- Linkage.h - Linkage enumeration and utilities ----------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines the Linkage enumeration and various utility
00011 // functions.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 #ifndef LLVM_CLANG_BASIC_LINKAGE_H
00015 #define LLVM_CLANG_BASIC_LINKAGE_H
00016 
00017 namespace clang {
00018 
00019 /// \brief Describes the different kinds of linkage 
00020 /// (C++ [basic.link], C99 6.2.2) that an entity may have.
00021 enum Linkage {
00022   /// \brief No linkage, which means that the entity is unique and
00023   /// can only be referred to from within its scope.
00024   NoLinkage = 0,
00025 
00026   /// \brief Internal linkage, which indicates that the entity can
00027   /// be referred to from within the translation unit (but not other
00028   /// translation units).
00029   InternalLinkage,
00030 
00031   /// \brief External linkage within a unique namespace. From the
00032   /// language perspective, these entities have external
00033   /// linkage. However, since they reside in an anonymous namespace,
00034   /// their names are unique to this translation unit, which is
00035   /// equivalent to having internal linkage from the code-generation
00036   /// point of view.
00037   UniqueExternalLinkage,
00038 
00039   /// \brief External linkage, which indicates that the entity can
00040   /// be referred to from other translation units.
00041   ExternalLinkage
00042 };
00043 
00044 /// \brief A more specific kind of linkage. This is relevant to CodeGen and
00045 /// AST file reading.
00046 enum GVALinkage {
00047   GVA_Internal,
00048   GVA_C99Inline,
00049   GVA_CXXInline,
00050   GVA_StrongExternal,
00051   GVA_TemplateInstantiation,
00052   GVA_ExplicitTemplateInstantiation
00053 };
00054 
00055 /// \brief Determine whether the given linkage is semantically
00056 /// external.
00057 inline bool isExternalLinkage(Linkage L) {
00058   return L == UniqueExternalLinkage || L == ExternalLinkage;
00059 }
00060 
00061 /// \brief Compute the minimum linkage given two linages.
00062 static inline Linkage minLinkage(Linkage L1, Linkage L2) {
00063   return L1 < L2? L1 : L2;
00064 }
00065 
00066 } // end namespace clang
00067 
00068 #endif // LLVM_CLANG_BASIC_LINKAGE_H