Merge System into Support.
[oota-llvm.git] / include / llvm / Analysis / DIBuilder.h
1 //===--- llvm/Analysis/DIBuilder.h - Debug Information Builder --*- 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 defines a DIBuilder that is useful for creating debugging 
11 // information entries in LLVM IR form.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_ANALYSIS_DIBUILDER_H
16 #define LLVM_ANALYSIS_DIBUILDER_H
17
18 #include "llvm/Support/DataTypes.h"
19 #include "llvm/ADT/StringRef.h"
20
21 namespace llvm {
22   class Module;
23   class LLVMContext;
24   class MDNode;
25   class StringRef;
26   class DIDescriptor;
27   class DIFile;
28   class DIEnumerator;
29   class DIType;
30
31   class DIBuilder {
32     private:
33     Module &M;
34     LLVMContext & VMContext;
35     MDNode *TheCU;
36
37     DIBuilder(const DIBuilder &);       // DO NOT IMPLEMENT
38     void operator=(const DIBuilder &);  // DO NOT IMPLEMENT
39
40     public:
41     explicit DIBuilder(Module &M);
42     const MDNode *getCU() { return TheCU; }
43
44     /// CreateCompileUnit - A CompileUnit provides an anchor for all debugging
45     /// information generated during this instance of compilation.
46     /// @param Lang     Source programming language, eg. dwarf::DW_LANG_C99
47     /// @param File     File name
48     /// @param Dir      Directory
49     /// @param Producer String identify producer of debugging information. 
50     ///                 Usuall this is a compiler version string.
51     /// @param isOptimized A boolean flag which indicates whether optimization
52     ///                    is ON or not.
53     /// @param Flags    This string lists command line options. This string is 
54     ///                 directly embedded in debug info output which may be used
55     ///                 by a tool analyzing generated debugging information.
56     /// @param RV       This indicates runtime version for languages like 
57     ///                 Objective-C.
58     void CreateCompileUnit(unsigned Lang, StringRef File, StringRef Dir, 
59                            StringRef Producer,
60                            bool isOptimized, StringRef Flags, unsigned RV);
61
62     /// CreateFile - Create a file descriptor to hold debugging information
63     /// for a file.
64     DIFile CreateFile(StringRef Filename, StringRef Directory);
65                            
66     /// CreateEnumerator - Create a single enumerator value.
67     DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val);
68
69     /// CreateBasicType - Create debugging information entry for a basic 
70     /// type.
71     /// @param Name        Type name.
72     /// @param SizeInBits  Size of the type.
73     /// @param AlignInBits Type alignment.
74     /// @param Encoding    DWARF encoding code, e.g. dwarf::DW_ATE_float.
75     DIType CreateBasicType(StringRef Name, uint64_t SizeInBits, 
76                            uint64_t AlignInBits, unsigned Encoding);
77
78     /// CreateQualifiedType - Create debugging information entry for a qualified
79     /// type, e.g. 'const int'.
80     /// @param Tag         Tag identifing type, e.g. dwarf::TAG_volatile_type
81     /// @param FromTy      Base Type.
82     DIType CreateQualifiedType(unsigned Tag, DIType FromTy);
83
84     /// CreatePointerType - Create debugging information entry for a pointer.
85     DIType CreatePointerType(DIType PointeeTy, uint64_t SizeInBits,
86                              uint64_t AlignInBits = 0, StringRef Name = StringRef());
87
88     /// CreateReferenceType - Create debugging information entry for a reference.
89     DIType CreateReferenceType(DIType RTy);
90
91     /// CreateTypedef - Create debugging information entry for a typedef.
92     DIType CreateTypedef(DIType Ty, StringRef Name, DIFile F, unsigned LineNo);
93
94     /// CreateFriend - Create debugging information entry for a 'friend'.
95     DIType CreateFriend(DIType Ty, DIType FriendTy);
96
97     /// CreateInheritance - Create debugging information entry to establish
98     /// inheritance relationship between two types.
99     DIType CreateInheritance(DIType Ty, DIType BaseTy, uint64_t BaseOffset,
100                              unsigned Flags);
101
102     /// CreateMemberType - Create debugging information entry for a member.
103     DIType CreateMemberType(DIDescriptor Context, StringRef Name, DIFile F,
104                             unsigned LineNumber, uint64_t SizeInBits, 
105                             uint64_t AlignInBits, uint64_t OffsetInBits, 
106                             unsigned Flags, DIType Ty);
107
108     /// CreateArtificialType - Create a new DIType with "artificial" flag set.
109     DIType CreateArtificialType(DIType Ty);
110   };
111 } // end namespace llvm
112
113 #endif