Daniel Dunbar | 3845f86 | 2008-10-31 03:54:29 +0000 | [diff] [blame] | 1 | //===--- CGDebugInfo.h - DebugInfo for LLVM CodeGen -------------*- C++ -*-===// |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 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 | // |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 10 | // This is the source level debug info generator for llvm translation. |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef CLANG_CODEGEN_CGDEBUGINFO_H |
| 15 | #define CLANG_CODEGEN_CGDEBUGINFO_H |
| 16 | |
Sanjiv Gupta | 1c6a38b | 2008-05-25 05:15:42 +0000 | [diff] [blame] | 17 | #include "clang/AST/Type.h" |
Mike Stump | b1a6e68 | 2009-09-30 02:43:10 +0000 | [diff] [blame] | 18 | #include "clang/AST/Expr.h" |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 19 | #include "clang/Basic/SourceLocation.h" |
Chris Lattner | 9c85ba3 | 2008-11-10 06:08:34 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/DenseMap.h" |
| 21 | #include "llvm/Analysis/DebugInfo.h" |
Devang Patel | 823d8e9 | 2010-12-08 22:42:58 +0000 | [diff] [blame] | 22 | #include "llvm/Analysis/DIBuilder.h" |
Daniel Dunbar | 23e81ba | 2009-09-19 19:27:24 +0000 | [diff] [blame] | 23 | #include "llvm/Support/ValueHandle.h" |
Devang Patel | 9c6c3a0 | 2010-01-14 00:36:21 +0000 | [diff] [blame] | 24 | #include "llvm/Support/Allocator.h" |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 25 | |
Daniel Dunbar | 45d196b | 2008-11-01 01:53:16 +0000 | [diff] [blame] | 26 | #include "CGBuilder.h" |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 27 | |
Daniel Dunbar | 23e81ba | 2009-09-19 19:27:24 +0000 | [diff] [blame] | 28 | namespace llvm { |
| 29 | class MDNode; |
| 30 | } |
| 31 | |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 32 | namespace clang { |
Sanjiv Gupta | cc9b163 | 2008-05-30 10:30:31 +0000 | [diff] [blame] | 33 | class VarDecl; |
Devang Patel | 9ca36b6 | 2009-02-26 21:10:26 +0000 | [diff] [blame] | 34 | class ObjCInterfaceDecl; |
Devang Patel | 9c1714b | 2011-04-05 17:30:54 +0000 | [diff] [blame] | 35 | class ClassTemplateSpecializationDecl; |
Peter Collingbourne | fd05ca0 | 2011-06-14 04:02:39 +0000 | [diff] [blame] | 36 | class GlobalDecl; |
Daniel Dunbar | 45d196b | 2008-11-01 01:53:16 +0000 | [diff] [blame] | 37 | |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 38 | namespace CodeGen { |
| 39 | class CodeGenModule; |
Mike Stump | b1a6e68 | 2009-09-30 02:43:10 +0000 | [diff] [blame] | 40 | class CodeGenFunction; |
John McCall | 6b5a61b | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 41 | class CGBlockInfo; |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 42 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 43 | /// CGDebugInfo - This class gathers all debug information during compilation |
| 44 | /// and is responsible for emitting to llvm globals or pass directly to |
Sanjiv Gupta | 1c6a38b | 2008-05-25 05:15:42 +0000 | [diff] [blame] | 45 | /// the backend. |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 46 | class CGDebugInfo { |
Anders Carlsson | 20f12a2 | 2009-12-06 18:00:51 +0000 | [diff] [blame] | 47 | CodeGenModule &CGM; |
Devang Patel | 823d8e9 | 2010-12-08 22:42:58 +0000 | [diff] [blame] | 48 | llvm::DIBuilder DBuilder; |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 49 | llvm::DICompileUnit TheCU; |
Chris Lattner | 9c85ba3 | 2008-11-10 06:08:34 +0000 | [diff] [blame] | 50 | SourceLocation CurLoc, PrevLoc; |
Devang Patel | 4ce3f20 | 2010-01-28 18:11:52 +0000 | [diff] [blame] | 51 | llvm::DIType VTablePtrType; |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 52 | |
Sanjiv Gupta | 1c6a38b | 2008-05-25 05:15:42 +0000 | [diff] [blame] | 53 | /// TypeCache - Cache of previously constructed Types. |
Ted Kremenek | 590838b | 2010-03-29 18:29:57 +0000 | [diff] [blame] | 54 | llvm::DenseMap<void *, llvm::WeakVH> TypeCache; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 55 | |
Mike Stump | 9bc093c | 2009-05-14 02:03:51 +0000 | [diff] [blame] | 56 | bool BlockLiteralGenericSet; |
| 57 | llvm::DIType BlockLiteralGeneric; |
| 58 | |
Eric Christopher | aa2164c | 2011-09-29 00:00:45 +0000 | [diff] [blame] | 59 | // LexicalBlockStack - Keep track of our current nested lexical block. |
| 60 | std::vector<llvm::TrackingVH<llvm::MDNode> > LexicalBlockStack; |
Devang Patel | 3dd96a1 | 2010-01-29 18:11:03 +0000 | [diff] [blame] | 61 | llvm::DenseMap<const Decl *, llvm::WeakVH> RegionMap; |
Eric Christopher | aa2164c | 2011-09-29 00:00:45 +0000 | [diff] [blame] | 62 | // FnBeginRegionCount - Keep track of LexicalBlockStack counter at the |
| 63 | // beginning of a function. This is used to pop unbalanced regions at |
| 64 | // the end of a function. |
Devang Patel | 5a6fbcf | 2010-07-22 22:29:16 +0000 | [diff] [blame] | 65 | std::vector<unsigned> FnBeginRegionCount; |
| 66 | |
| 67 | /// LineDirectiveFiles - This stack is used to keep track of |
| 68 | /// scopes introduced by #line directives. |
| 69 | std::vector<const char *> LineDirectiveFiles; |
Eli Friedman | 3f2af10 | 2008-05-22 01:40:10 +0000 | [diff] [blame] | 70 | |
Devang Patel | 89f05f8 | 2010-01-28 18:21:00 +0000 | [diff] [blame] | 71 | /// DebugInfoNames - This is a storage for names that are |
Devang Patel | 9c6c3a0 | 2010-01-14 00:36:21 +0000 | [diff] [blame] | 72 | /// constructed on demand. For example, C++ destructors, C++ operators etc.. |
Devang Patel | 89f05f8 | 2010-01-28 18:21:00 +0000 | [diff] [blame] | 73 | llvm::BumpPtrAllocator DebugInfoNames; |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 74 | StringRef CWDName; |
Devang Patel | 9c6c3a0 | 2010-01-14 00:36:21 +0000 | [diff] [blame] | 75 | |
Ted Kremenek | 9c25039 | 2010-03-30 00:27:51 +0000 | [diff] [blame] | 76 | llvm::DenseMap<const char *, llvm::WeakVH> DIFileCache; |
Devang Patel | 4125fd2 | 2010-01-19 01:54:44 +0000 | [diff] [blame] | 77 | llvm::DenseMap<const FunctionDecl *, llvm::WeakVH> SPCache; |
Devang Patel | abb485f | 2010-02-01 19:16:32 +0000 | [diff] [blame] | 78 | llvm::DenseMap<const NamespaceDecl *, llvm::WeakVH> NameSpaceCache; |
Devang Patel | 4125fd2 | 2010-01-19 01:54:44 +0000 | [diff] [blame] | 79 | |
Sanjiv Gupta | 1c6a38b | 2008-05-25 05:15:42 +0000 | [diff] [blame] | 80 | /// Helper functions for getOrCreateType. |
Devang Patel | f1d1d9a | 2010-11-01 16:52:40 +0000 | [diff] [blame] | 81 | llvm::DIType CreateType(const BuiltinType *Ty); |
Devang Patel | 344ff5d | 2010-12-09 00:25:29 +0000 | [diff] [blame] | 82 | llvm::DIType CreateType(const ComplexType *Ty); |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 83 | llvm::DIType CreateQualifiedType(QualType Ty, llvm::DIFile F); |
| 84 | llvm::DIType CreateType(const TypedefType *Ty, llvm::DIFile F); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 85 | llvm::DIType CreateType(const ObjCObjectPointerType *Ty, |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 86 | llvm::DIFile F); |
| 87 | llvm::DIType CreateType(const PointerType *Ty, llvm::DIFile F); |
| 88 | llvm::DIType CreateType(const BlockPointerType *Ty, llvm::DIFile F); |
| 89 | llvm::DIType CreateType(const FunctionType *Ty, llvm::DIFile F); |
Devang Patel | 31f7d02 | 2011-01-17 22:23:07 +0000 | [diff] [blame] | 90 | llvm::DIType CreateType(const TagType *Ty); |
| 91 | llvm::DIType CreateType(const RecordType *Ty); |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 92 | llvm::DIType CreateType(const ObjCInterfaceType *Ty, llvm::DIFile F); |
John McCall | c12c5bb | 2010-05-15 11:32:37 +0000 | [diff] [blame] | 93 | llvm::DIType CreateType(const ObjCObjectType *Ty, llvm::DIFile F); |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 94 | llvm::DIType CreateType(const VectorType *Ty, llvm::DIFile F); |
| 95 | llvm::DIType CreateType(const ArrayType *Ty, llvm::DIFile F); |
| 96 | llvm::DIType CreateType(const LValueReferenceType *Ty, llvm::DIFile F); |
Douglas Gregor | 36b8ee6 | 2011-01-22 01:58:15 +0000 | [diff] [blame] | 97 | llvm::DIType CreateType(const RValueReferenceType *Ty, llvm::DIFile Unit); |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 98 | llvm::DIType CreateType(const MemberPointerType *Ty, llvm::DIFile F); |
Eli Friedman | b001de7 | 2011-10-06 23:00:33 +0000 | [diff] [blame] | 99 | llvm::DIType CreateType(const AtomicType *Ty, llvm::DIFile F); |
Devang Patel | 31f7d02 | 2011-01-17 22:23:07 +0000 | [diff] [blame] | 100 | llvm::DIType CreateEnumType(const EnumDecl *ED); |
Devang Patel | a6da192 | 2010-01-28 00:28:01 +0000 | [diff] [blame] | 101 | llvm::DIType getOrCreateMethodType(const CXXMethodDecl *Method, |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 102 | llvm::DIFile F); |
Devang Patel | 1c29652 | 2011-05-31 20:46:46 +0000 | [diff] [blame] | 103 | llvm::DIType getOrCreateFunctionType(const Decl *D, QualType FnType, |
| 104 | llvm::DIFile F); |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 105 | llvm::DIType getOrCreateVTablePtrType(llvm::DIFile F); |
Devang Patel | 170cef3 | 2010-12-09 00:33:05 +0000 | [diff] [blame] | 106 | llvm::DINameSpace getOrCreateNameSpace(const NamespaceDecl *N); |
Devang Patel | c69e1cf | 2010-09-30 19:05:55 +0000 | [diff] [blame] | 107 | llvm::DIType CreatePointeeType(QualType PointeeTy, llvm::DIFile F); |
Anders Carlsson | a031b35 | 2009-11-06 19:19:55 +0000 | [diff] [blame] | 108 | llvm::DIType CreatePointerLikeType(unsigned Tag, |
| 109 | const Type *Ty, QualType PointeeTy, |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 110 | llvm::DIFile F); |
Anders Carlsson | d6f9a0d | 2010-01-26 04:49:33 +0000 | [diff] [blame] | 111 | |
Anders Carlsson | 4433f1c | 2010-01-26 05:19:50 +0000 | [diff] [blame] | 112 | llvm::DISubprogram CreateCXXMemberFunction(const CXXMethodDecl *Method, |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 113 | llvm::DIFile F, |
Dan Gohman | 4cac5b4 | 2010-08-20 22:02:57 +0000 | [diff] [blame] | 114 | llvm::DIType RecordTy); |
Anders Carlsson | d6f9a0d | 2010-01-26 04:49:33 +0000 | [diff] [blame] | 115 | |
Devang Patel | 4125fd2 | 2010-01-19 01:54:44 +0000 | [diff] [blame] | 116 | void CollectCXXMemberFunctions(const CXXRecordDecl *Decl, |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 117 | llvm::DIFile F, |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 118 | SmallVectorImpl<llvm::Value *> &E, |
Dan Gohman | 4cac5b4 | 2010-08-20 22:02:57 +0000 | [diff] [blame] | 119 | llvm::DIType T); |
Devang Patel | 2ed8f00 | 2010-08-27 17:47:47 +0000 | [diff] [blame] | 120 | |
| 121 | void CollectCXXFriends(const CXXRecordDecl *Decl, |
| 122 | llvm::DIFile F, |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 123 | SmallVectorImpl<llvm::Value *> &EltTys, |
Devang Patel | 2ed8f00 | 2010-08-27 17:47:47 +0000 | [diff] [blame] | 124 | llvm::DIType RecordTy); |
| 125 | |
Devang Patel | a245c5b | 2010-01-25 23:32:18 +0000 | [diff] [blame] | 126 | void CollectCXXBases(const CXXRecordDecl *Decl, |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 127 | llvm::DIFile F, |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 128 | SmallVectorImpl<llvm::Value *> &EltTys, |
Dan Gohman | 4cac5b4 | 2010-08-20 22:02:57 +0000 | [diff] [blame] | 129 | llvm::DIType RecordTy); |
Devang Patel | 5ecb1df | 2011-04-05 22:54:11 +0000 | [diff] [blame] | 130 | |
| 131 | llvm::DIArray |
| 132 | CollectTemplateParams(const TemplateParameterList *TPList, |
| 133 | const TemplateArgumentList &TAList, |
| 134 | llvm::DIFile Unit); |
| 135 | llvm::DIArray |
| 136 | CollectFunctionTemplateParams(const FunctionDecl *FD, llvm::DIFile Unit); |
Devang Patel | 9c1714b | 2011-04-05 17:30:54 +0000 | [diff] [blame] | 137 | llvm::DIArray |
| 138 | CollectCXXTemplateParams(const ClassTemplateSpecializationDecl *TS, |
| 139 | llvm::DIFile F); |
| 140 | |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 141 | llvm::DIType createFieldType(StringRef name, QualType type, |
John McCall | 8178df3 | 2011-02-22 22:38:33 +0000 | [diff] [blame] | 142 | Expr *bitWidth, SourceLocation loc, |
| 143 | AccessSpecifier AS, uint64_t offsetInBits, |
Devang Patel | 1d323e0 | 2011-06-24 22:00:59 +0000 | [diff] [blame] | 144 | llvm::DIFile tunit, |
| 145 | llvm::DIDescriptor scope); |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 146 | void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile F, |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 147 | SmallVectorImpl<llvm::Value *> &E, |
Devang Patel | 1d323e0 | 2011-06-24 22:00:59 +0000 | [diff] [blame] | 148 | llvm::DIType RecordTy); |
Devang Patel | 4ce3f20 | 2010-01-28 18:11:52 +0000 | [diff] [blame] | 149 | |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 150 | void CollectVTableInfo(const CXXRecordDecl *Decl, |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 151 | llvm::DIFile F, |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 152 | SmallVectorImpl<llvm::Value *> &EltTys); |
Devang Patel | 4ce3f20 | 2010-01-28 18:11:52 +0000 | [diff] [blame] | 153 | |
Eric Christopher | 414ee4b | 2011-09-29 00:00:35 +0000 | [diff] [blame] | 154 | // UpdateLineDirectiveRegion - Update region stack only if #line directive |
| 155 | // has introduced scope change. |
| 156 | void UpdateLineDirectiveRegion(CGBuilderTy &Builder); |
| 157 | |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 158 | public: |
Anders Carlsson | 20f12a2 | 2009-12-06 18:00:51 +0000 | [diff] [blame] | 159 | CGDebugInfo(CodeGenModule &CGM); |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 160 | ~CGDebugInfo(); |
Devang Patel | 4111fef | 2011-08-15 23:01:55 +0000 | [diff] [blame] | 161 | void finalize() { DBuilder.finalize(); } |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 162 | |
Daniel Dunbar | 66031a5 | 2008-10-17 16:15:48 +0000 | [diff] [blame] | 163 | /// setLocation - Update the current source location. If \arg loc is |
| 164 | /// invalid it is ignored. |
Chris Lattner | 9c85ba3 | 2008-11-10 06:08:34 +0000 | [diff] [blame] | 165 | void setLocation(SourceLocation Loc); |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 166 | |
Eric Christopher | 5321bc4 | 2011-09-29 00:00:41 +0000 | [diff] [blame] | 167 | /// EmitLocation - Emit metadata to indicate a change in line/column |
| 168 | /// information in the source file. |
| 169 | void EmitLocation(CGBuilderTy &Builder); |
Sanjiv Gupta | 1c6a38b | 2008-05-25 05:15:42 +0000 | [diff] [blame] | 170 | |
| 171 | /// EmitFunctionStart - Emit a call to llvm.dbg.function.start to indicate |
Daniel Dunbar | 2284ac9 | 2008-10-18 18:22:23 +0000 | [diff] [blame] | 172 | /// start of a new function. |
Devang Patel | 9c6c3a0 | 2010-01-14 00:36:21 +0000 | [diff] [blame] | 173 | void EmitFunctionStart(GlobalDecl GD, QualType FnType, |
Daniel Dunbar | 45d196b | 2008-11-01 01:53:16 +0000 | [diff] [blame] | 174 | llvm::Function *Fn, CGBuilderTy &Builder); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 175 | |
Devang Patel | 5a6fbcf | 2010-07-22 22:29:16 +0000 | [diff] [blame] | 176 | /// EmitFunctionEnd - Constructs the debug code for exiting a function. |
| 177 | void EmitFunctionEnd(CGBuilderTy &Builder); |
| 178 | |
Devang Patel | e80d567 | 2011-03-23 16:29:39 +0000 | [diff] [blame] | 179 | /// UpdateCompletedType - Update type cache because the type is now |
| 180 | /// translated. |
| 181 | void UpdateCompletedType(const TagDecl *TD); |
| 182 | |
Eric Christopher | aa2164c | 2011-09-29 00:00:45 +0000 | [diff] [blame] | 183 | /// EmitLexicalBlockStart - Emit metadata to indicate the beginning of a |
| 184 | /// new lexical block and push the block onto the stack. |
| 185 | void EmitLexicalBlockStart(CGBuilderTy &Builder); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 186 | |
Eric Christopher | aa2164c | 2011-09-29 00:00:45 +0000 | [diff] [blame] | 187 | /// EmitLexicalBlockEnd - Emit metadata to indicate the end of a new lexical |
| 188 | /// block and pop the current block. |
| 189 | void EmitLexicalBlockEnd(CGBuilderTy &Builder); |
Sanjiv Gupta | cc9b163 | 2008-05-30 10:30:31 +0000 | [diff] [blame] | 190 | |
Chris Lattner | 9c85ba3 | 2008-11-10 06:08:34 +0000 | [diff] [blame] | 191 | /// EmitDeclareOfAutoVariable - Emit call to llvm.dbg.declare for an automatic |
| 192 | /// variable declaration. |
| 193 | void EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI, |
| 194 | CGBuilderTy &Builder); |
Sanjiv Gupta | 686226b | 2008-06-05 08:59:10 +0000 | [diff] [blame] | 195 | |
Mike Stump | b1a6e68 | 2009-09-30 02:43:10 +0000 | [diff] [blame] | 196 | /// EmitDeclareOfBlockDeclRefVariable - Emit call to llvm.dbg.declare for an |
| 197 | /// imported variable declaration in a block. |
John McCall | 6b5a61b | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 198 | void EmitDeclareOfBlockDeclRefVariable(const VarDecl *variable, |
| 199 | llvm::Value *storage, |
Mike Stump | b1a6e68 | 2009-09-30 02:43:10 +0000 | [diff] [blame] | 200 | CGBuilderTy &Builder, |
John McCall | 6b5a61b | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 201 | const CGBlockInfo &blockInfo); |
Mike Stump | b1a6e68 | 2009-09-30 02:43:10 +0000 | [diff] [blame] | 202 | |
Chris Lattner | 9c85ba3 | 2008-11-10 06:08:34 +0000 | [diff] [blame] | 203 | /// EmitDeclareOfArgVariable - Emit call to llvm.dbg.declare for an argument |
| 204 | /// variable declaration. |
| 205 | void EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI, |
Devang Patel | 093ac46 | 2011-03-03 20:13:15 +0000 | [diff] [blame] | 206 | unsigned ArgNo, CGBuilderTy &Builder); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 207 | |
John McCall | 8178df3 | 2011-02-22 22:38:33 +0000 | [diff] [blame] | 208 | /// EmitDeclareOfBlockLiteralArgVariable - Emit call to |
| 209 | /// llvm.dbg.declare for the block-literal argument to a block |
| 210 | /// invocation function. |
| 211 | void EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, |
| 212 | llvm::Value *addr, |
| 213 | CGBuilderTy &Builder); |
| 214 | |
Sanjiv Gupta | 686226b | 2008-06-05 08:59:10 +0000 | [diff] [blame] | 215 | /// EmitGlobalVariable - Emit information about a global variable. |
Chris Lattner | 9c85ba3 | 2008-11-10 06:08:34 +0000 | [diff] [blame] | 216 | void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl); |
Devang Patel | 9ca36b6 | 2009-02-26 21:10:26 +0000 | [diff] [blame] | 217 | |
| 218 | /// EmitGlobalVariable - Emit information about an objective-c interface. |
| 219 | void EmitGlobalVariable(llvm::GlobalVariable *GV, ObjCInterfaceDecl *Decl); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 220 | |
Devang Patel | 25c2c8f | 2010-08-10 17:53:33 +0000 | [diff] [blame] | 221 | /// EmitGlobalVariable - Emit global variable's debug info. |
John McCall | 189d6ef | 2010-10-09 01:34:31 +0000 | [diff] [blame] | 222 | void EmitGlobalVariable(const ValueDecl *VD, llvm::Constant *Init); |
Devang Patel | 8d30838 | 2010-08-10 07:24:25 +0000 | [diff] [blame] | 223 | |
Devang Patel | c69e1cf | 2010-09-30 19:05:55 +0000 | [diff] [blame] | 224 | /// getOrCreateRecordType - Emit record type's standalone debug info. |
| 225 | llvm::DIType getOrCreateRecordType(QualType Ty, SourceLocation L); |
Chris Lattner | 86cd8af | 2008-11-03 09:11:11 +0000 | [diff] [blame] | 226 | private: |
Chris Lattner | 9c85ba3 | 2008-11-10 06:08:34 +0000 | [diff] [blame] | 227 | /// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration. |
| 228 | void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI, |
Devang Patel | 093ac46 | 2011-03-03 20:13:15 +0000 | [diff] [blame] | 229 | unsigned ArgNo, CGBuilderTy &Builder); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 230 | |
Devang Patel | 809b9bb | 2010-02-10 18:49:08 +0000 | [diff] [blame] | 231 | // EmitTypeForVarWithBlocksAttr - Build up structure info for the byref. |
| 232 | // See BuildByRefType. |
| 233 | llvm::DIType EmitTypeForVarWithBlocksAttr(const ValueDecl *VD, |
| 234 | uint64_t *OffSet); |
| 235 | |
Devang Patel | 3358305 | 2010-01-28 23:15:27 +0000 | [diff] [blame] | 236 | /// getContextDescriptor - Get context info for the decl. |
Devang Patel | 170cef3 | 2010-12-09 00:33:05 +0000 | [diff] [blame] | 237 | llvm::DIDescriptor getContextDescriptor(const Decl *Decl); |
Devang Patel | 979ec2e | 2009-10-06 00:35:31 +0000 | [diff] [blame] | 238 | |
Devang Patel | ac4d13c | 2010-07-27 15:17:16 +0000 | [diff] [blame] | 239 | /// getCurrentDirname - Return current directory name. |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 240 | StringRef getCurrentDirname(); |
Devang Patel | ac4d13c | 2010-07-27 15:17:16 +0000 | [diff] [blame] | 241 | |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 242 | /// CreateCompileUnit - Create new compile unit. |
| 243 | void CreateCompileUnit(); |
| 244 | |
| 245 | /// getOrCreateFile - Get the file debug info descriptor for the input |
| 246 | /// location. |
| 247 | llvm::DIFile getOrCreateFile(SourceLocation Loc); |
Sanjiv Gupta | 1c6a38b | 2008-05-25 05:15:42 +0000 | [diff] [blame] | 248 | |
Devang Patel | 532105f | 2010-10-28 22:03:20 +0000 | [diff] [blame] | 249 | /// getOrCreateMainFile - Get the file info for main compile unit. |
| 250 | llvm::DIFile getOrCreateMainFile(); |
| 251 | |
Sanjiv Gupta | 1c6a38b | 2008-05-25 05:15:42 +0000 | [diff] [blame] | 252 | /// getOrCreateType - Get the type from the cache or create a new type if |
| 253 | /// necessary. |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 254 | llvm::DIType getOrCreateType(QualType Ty, llvm::DIFile F); |
Daniel Dunbar | 03faac3 | 2009-09-19 19:27:14 +0000 | [diff] [blame] | 255 | |
| 256 | /// CreateTypeNode - Create type metadata for a source language type. |
Devang Patel | 1780055 | 2010-03-09 00:44:50 +0000 | [diff] [blame] | 257 | llvm::DIType CreateTypeNode(QualType Ty, llvm::DIFile F); |
Devang Patel | 9c6c3a0 | 2010-01-14 00:36:21 +0000 | [diff] [blame] | 258 | |
Benjamin Kramer | d3651cc | 2010-04-24 20:26:20 +0000 | [diff] [blame] | 259 | /// CreateMemberType - Create new member and increase Offset by FType's size. |
Benjamin Kramer | 48c70f6 | 2010-04-24 20:19:58 +0000 | [diff] [blame] | 260 | llvm::DIType CreateMemberType(llvm::DIFile Unit, QualType FType, |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 261 | StringRef Name, uint64_t *Offset); |
Benjamin Kramer | 48c70f6 | 2010-04-24 20:19:58 +0000 | [diff] [blame] | 262 | |
Devang Patel | 120bf32 | 2011-04-23 00:08:01 +0000 | [diff] [blame] | 263 | /// getFunctionDeclaration - Return debug info descriptor to describe method |
| 264 | /// declaration for the given method definition. |
| 265 | llvm::DISubprogram getFunctionDeclaration(const Decl *D); |
| 266 | |
Devang Patel | 9c6c3a0 | 2010-01-14 00:36:21 +0000 | [diff] [blame] | 267 | /// getFunctionName - Get function name for the given FunctionDecl. If the |
| 268 | /// name is constructred on demand (e.g. C++ destructor) then the name |
| 269 | /// is stored on the side. |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 270 | StringRef getFunctionName(const FunctionDecl *FD); |
Devang Patel | cebbedd | 2010-10-12 23:24:54 +0000 | [diff] [blame] | 271 | |
David Chisnall | 52044a2 | 2010-09-02 18:01:51 +0000 | [diff] [blame] | 272 | /// getObjCMethodName - Returns the unmangled name of an Objective-C method. |
| 273 | /// This is the display name for the debugging info. |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 274 | StringRef getObjCMethodName(const ObjCMethodDecl *FD); |
Devang Patel | 4ce3f20 | 2010-01-28 18:11:52 +0000 | [diff] [blame] | 275 | |
Devang Patel | 1f15c19 | 2011-04-18 17:30:25 +0000 | [diff] [blame] | 276 | /// getSelectorName - Return selector name. This is used for debugging |
Devang Patel | 90c1eed | 2011-04-16 00:37:51 +0000 | [diff] [blame] | 277 | /// info. |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 278 | StringRef getSelectorName(Selector S); |
Devang Patel | 90c1eed | 2011-04-16 00:37:51 +0000 | [diff] [blame] | 279 | |
Devang Patel | 700a1cb | 2010-07-20 20:24:18 +0000 | [diff] [blame] | 280 | /// getClassName - Get class name including template argument list. |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 281 | StringRef getClassName(RecordDecl *RD); |
Devang Patel | 700a1cb | 2010-07-20 20:24:18 +0000 | [diff] [blame] | 282 | |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 283 | /// getVTableName - Get vtable name for the given Class. |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 284 | StringRef getVTableName(const CXXRecordDecl *Decl); |
Devang Patel | 4ce3f20 | 2010-01-28 18:11:52 +0000 | [diff] [blame] | 285 | |
Devang Patel | 8ab870d | 2010-05-12 23:46:38 +0000 | [diff] [blame] | 286 | /// getLineNumber - Get line number for the location. If location is invalid |
| 287 | /// then use current location. |
| 288 | unsigned getLineNumber(SourceLocation Loc); |
| 289 | |
| 290 | /// getColumnNumber - Get column number for the location. If location is |
| 291 | /// invalid then use current location. |
| 292 | unsigned getColumnNumber(SourceLocation Loc); |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 293 | }; |
| 294 | } // namespace CodeGen |
| 295 | } // namespace clang |
| 296 | |
Devang Patel | bbd9fa4 | 2009-10-06 18:36:08 +0000 | [diff] [blame] | 297 | |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 298 | #endif |