Introduce DIBuilder. It is intended to be a front-end friendly interface to emit...
[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/System/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     void CreateCompileUnit(unsigned Lang, StringRef F, StringRef D, StringRef P,
47                            bool isOptimized, StringRef Flags, unsigned RV);
48
49     /// CreateFile - Create a file descriptor to hold debugging information
50     /// for a file.
51     DIFile CreateFile(StringRef Filename, StringRef Directory);
52                            
53     /// CreateEnumerator - Create a single enumerator value.
54     DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val);
55
56     /// CreateBasicType - Create debugging information entry for a basic 
57     /// type, e.g 'char'.
58     DIType CreateBasicType(StringRef Name, uint64_t SizeInBits, 
59                            uint64_t AlignInBits, unsigned Encoding);
60
61     /// CreateQaulifiedType - Create debugging information entry for a qualified
62     /// type, e.g. 'const int'.
63     DIType CreateQualifiedType(unsigned Tag, DIType FromTy);
64
65     /// CreatePointerType - Create debugging information entry for a pointer.
66     DIType CreatePointerType(DIType PointeeTy, uint64_t SizeInBits,
67                              uint64_t AlignInBits = 0, StringRef Name = StringRef());
68
69     /// CreateReferenceType - Create debugging information entry for a reference.
70     DIType CreateReferenceType(DIType RTy);
71
72     /// CreateTypedef - Create debugging information entry for a typedef.
73     DIType CreateTypedef(DIType Ty, StringRef Name, DIFile F, unsigned LineNo);
74
75     /// CreateFriend - Create debugging information entry for a 'friend'.
76     DIType CreateFriend(DIType Ty, DIType FriendTy);
77
78     /// CreateInheritance - Create debugging information entry to establish
79     /// inheritnace relationship between two types.
80     DIType CreateInheritance(DIType Ty, DIType BaseTy, uint64_t BaseOffset,
81                              unsigned Flags);
82
83     /// CreateMemberType - Create debugging information entry for a member.
84     DIType CreateMemberType(DIDescriptor Context, StringRef Name, DIFile F,
85                             unsigned LineNumber, uint64_t SizeInBits, 
86                             uint64_t AlignInBits, uint64_t OffsetInBits, 
87                             unsigned Flags, DIType Ty);
88
89     /// CreateArtificialType - Create a new DIType with "artificial" flag set.
90     DIType CreateArtificialType(DIType Ty);
91   };
92 } // end namespace llvm
93
94 #endif