add some comments to MCSymbol header, make the ctor private so that only MCContext...
[oota-llvm.git] / include / llvm / MC / MCSymbol.h
1 //===- MCSymbol.h - Machine Code Symbols ------------------------*- 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 // This file contains the declaration of the MCSymbol class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_MC_MCSYMBOL_H
15 #define LLVM_MC_MCSYMBOL_H
16
17 #include <string>
18
19 namespace llvm {
20   class MCSection;
21   class MCContext;
22
23   /// MCSymbol - Instances of this class represent a symbol name in the MC file,
24   /// and MCSymbols are created and unique'd by the MCContext class.
25   ///
26   /// If the symbol is defined/emitted into the current translation unit, the
27   /// Section member is set to indicate what section it lives in.  Otherwise, if
28   /// it is a reference to an external entity, it has a null section.  
29   /// 
30   class MCSymbol {
31     /// Name - The name of the symbol.
32     std::string Name;
33     /// Section - The section the symbol is defined in, or null if not defined
34     /// in this translation unit.
35     MCSection *Section;
36     
37     /// IsTemporary - True if this is an assembler temporary label, which
38     /// typically does not survive in the .o file's symbol table.  Usually
39     /// "Lfoo" or ".foo".
40     unsigned IsTemporary : 1;
41     
42     /// IsExternal - ?
43     unsigned IsExternal : 1;
44
45   private:  // MCContext creates and uniques these.
46     friend class MCContext;
47     MCSymbol(const char *_Name, bool _IsTemporary) 
48       : Name(_Name), Section(0), IsTemporary(_IsTemporary), IsExternal(false) {}
49   public:
50     
51     MCSection *getSection() const { return Section; }
52     void setSection(MCSection *Value) { Section = Value; }
53
54     bool isExternal() const { return IsExternal; }
55     void setExternal(bool Value) { IsExternal = Value; }
56
57     const std::string &getName() const { return Name; }
58   };
59
60 } // end namespace llvm
61
62 #endif