24 using namespace llvm::dwarf;
27 assert((Tag & LLVMDebugVersionMask) == 0 &&
28 "Tag too large for debug encoding!");
33 : M(m), VMContext(M.getContext()), TempEnumTypes(0), TempRetainTypes(0),
34 TempSubprograms(0), TempGVs(0), DeclareFn(0), ValueFn(0) {}
47 for (
unsigned I = 0, E = AllRetainTypes.size();
I < E;
I++)
48 if (RetainSet.
insert(AllRetainTypes[
I]))
49 RetainValues.
push_back(AllRetainTypes[I]);
59 for (
unsigned ii = 0, ee = NMD->getNumOperands(); ii != ee; ++ii)
61 NMD->eraseFromParent();
63 if (
MDNode *Temp = SP.getVariablesNodes()) {
86 assert(!Filename.
empty() &&
"Unable to create file without name");
103 "Invalid Language tag");
104 assert(!Filename.
empty() &&
105 "Unable to create compile unit without filename");
166 assert(M.
Verify() &&
"Imported module should be valid");
196 assert(M.
Verify() &&
"Imported module should be valid");
197 AllImportedModules.push_back(M);
213 assert(!Name.
empty() &&
"Unable to create enumerator without name");
224 assert(!Name.
empty() &&
"Unable to create type without name");
251 uint64_t AlignInBits,
unsigned Encoding) {
252 assert(!Name.
empty() &&
"Unable to create type without name");
331 assert(RTy.
isType() &&
"Unable to create reference type");
352 assert(Ty.
isType() &&
"Invalid typedef type!");
371 assert(Ty.
isType() &&
"Invalid type!");
372 assert(FriendTy.
isType() &&
"Invalid friend type!");
393 assert(Ty.
isType() &&
"Unable to create inheritance");
414 uint64_t AlignInBits,
415 uint64_t OffsetInBits,
unsigned Flags,
462 uint64_t SizeInBits, uint64_t AlignInBits,
465 StringRef SetterName,
unsigned PropertyAttributes) {
491 uint64_t AlignInBits,
492 uint64_t OffsetInBits,
unsigned Flags,
516 unsigned PropertyAttributes,
DIType Ty) {
549 DIBuilder::createTemplateValueParameter(
unsigned Tag,
DIDescriptor Context,
572 MDNode *File,
unsigned LineNo,
574 return createTemplateValueParameter(dwarf::DW_TAG_template_value_parameter,
575 Context, Name, Ty, Val, File, LineNo,
582 MDNode *File,
unsigned LineNo,
584 return createTemplateValueParameter(
585 dwarf::DW_TAG_GNU_template_template_param, Context, Name, Ty,
592 MDNode *File,
unsigned LineNo,
594 return createTemplateValueParameter(dwarf::DW_TAG_GNU_template_parameter_pack,
595 Context, Name, Ty, Val, File, LineNo,
601 DIFile File,
unsigned LineNumber,
603 uint64_t AlignInBits,
604 uint64_t OffsetInBits,
610 assert((!Context || Context.
isScope() || Context.
isType()) &&
611 "createClassType should be called with a valid Context");
632 "createClassType should return a DICompositeType");
633 if (!UniqueIdentifier.
empty())
643 uint64_t AlignInBits,
646 unsigned RunTimeLang,
669 "createStructType should return a DICompositeType");
670 if (!UniqueIdentifier.
empty())
677 DIFile File,
unsigned LineNumber,
679 uint64_t AlignInBits,
unsigned Flags,
681 unsigned RunTimeLang,
702 if (!UniqueIdentifier.
empty())
735 uint64_t SizeInBits, uint64_t AlignInBits,
DIArray Elements,
756 AllEnumTypes.push_back(CTy);
757 if (!UniqueIdentifier.
empty())
817 assert (N &&
"Unexpected input DIType!");
839 assert (N &&
"Unexpected input DIType!");
872 DIFile F,
unsigned Line,
unsigned RuntimeLang,
873 uint64_t SizeInBits, uint64_t AlignInBits,
896 "createForwardDecl result should be a DIType");
897 if (!UniqueIdentifier.
empty())
904 if (Elements.
empty()) {
927 DIType Ty,
bool isLocalToUnit,
945 AllGVs.push_back(Node);
951 unsigned LineNumber,
DIType Ty,
964 DIType Ty,
bool isLocalToUnit,
982 AllGVs.push_back(Node);
989 unsigned LineNo,
DIType Ty,
990 bool AlwaysPreserve,
unsigned Flags,
993 assert((!Context || Context.
isScope()) &&
994 "createLocalVariable should be called with a valid Context");
996 "createLocalVariable should be called with a valid type");
1008 if (AlwaysPreserve) {
1018 "createLocalVariable should return a valid DIVariable");
1035 (LineNo | (ArgNo << 24))));
1050 bool isLocalToUnit,
bool isDefinition,
1051 unsigned ScopeLine,
unsigned Flags,
1058 LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine,
1059 Flags, isOptimized, Fn, TParams, Decl);
1066 bool isLocalToUnit,
bool isDefinition,
1067 unsigned ScopeLine,
unsigned Flags,
1070 assert(Ty.
getTag() == dwarf::DW_TAG_subroutine_type &&
1071 "function types should be subroutines");
1099 AllSubprograms.push_back(Node);
1101 assert(S.
isSubprogram() &&
"createFunction should return a valid DISubprogram");
1109 bool isLocalToUnit,
bool isDefinition,
1110 unsigned VK,
unsigned VIndex,
1114 assert(Ty.
getTag() == dwarf::DW_TAG_subroutine_type &&
1115 "function types should be subroutines");
1117 "Methods should have both a Context and a context that isn't "
1118 "the compile unit.");
1145 AllSubprograms.push_back(Node);
1147 assert(S.
isSubprogram() &&
"createMethod should return a valid DISubprogram");
1154 DIFile File,
unsigned LineNo) {
1164 "createNameSpace should return a verifiable DINameSpace");
1180 "createLexicalBlockFile should return a verifiable DILexicalBlockFile");
1185 unsigned Line,
unsigned Col) {
1187 static unsigned int unique_id = 0;
1198 "createLexicalBlock should return a verifiable DILexicalBlock");
1205 assert(Storage &&
"no storage passed to dbg.declare");
1207 "empty or invalid DIVariable passed to dbg.declare");
1218 assert(Storage &&
"no storage passed to dbg.declare");
1220 "empty or invalid DIVariable passed to dbg.declare");
1238 assert(V &&
"no value passed to dbg.value");
1240 "empty or invalid DIVariable passed to dbg.value");
1254 assert(V &&
"no value passed to dbg.value");
1256 "empty or invalid DIVariable passed to dbg.value");
void finalize()
finalize - Construct any deferred debug info descriptors.
DICompileUnit createCompileUnit(unsigned Lang, StringRef File, StringRef Dir, StringRef Producer, bool isOptimized, StringRef Flags, unsigned RV, StringRef SplitName=StringRef())
DITemplateTypeParameter - This is a wrapper for template type parameter.
void push_back(const T &Elt)
static MDNode * getTemporary(LLVMContext &Context, ArrayRef< Value * > Vals)
static IntegerType * getInt1Ty(LLVMContext &C)
DILexicalBlock createLexicalBlock(DIDescriptor Scope, DIFile File, unsigned Line, unsigned Col)
DICompositeType createForwardDecl(unsigned Tag, StringRef Name, DIDescriptor Scope, DIFile F, unsigned Line, unsigned RuntimeLang=0, uint64_t SizeInBits=0, uint64_t AlignInBits=0, StringRef UniqueIdentifier=StringRef())
createForwardDecl - Create a temporary forward-declared type.
DIObjCProperty createObjCProperty(StringRef Name, DIFile File, unsigned LineNumber, StringRef GetterName, StringRef SetterName, unsigned PropertyAttributes, DIType Ty)
DITemplateValueParameter createTemplateParameterPack(DIDescriptor Scope, StringRef Name, DIType Ty, DIArray Val, MDNode *File=0, unsigned LineNo=0, unsigned ColumnNo=0)
Create debugging information for a template parameter pack.
bool isArtificial() const
bool isVariable() const
isVariable - Return true if the specified tag is legal for DIVariable.
void replaceAllUsesWith(DIDescriptor &D)
bool isSubprogram() const
DIGlobalVariable createGlobalVariable(StringRef Name, DIFile File, unsigned LineNo, DIType Ty, bool isLocalToUnit, llvm::Value *Val)
Create a new descriptor for the specified global.
The main container class for the LLVM Intermediate Representation.
static MDString * get(LLVMContext &Context, StringRef Str)
DICompositeType createClassType(DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType DerivedFrom, DIArray Elements, DIType VTableHolder=DIType(), MDNode *TemplateParms=0, StringRef UniqueIdentifier=StringRef())
createClassType - Create debugging information entry for a class.
bool Verify() const
Verify that the imported module descriptor is well formed.
unsigned getNumOperands() const
getNumOperands - Return number of MDNode operands.
DIVariable createComplexVariable(unsigned Tag, DIDescriptor Scope, StringRef Name, DIFile F, unsigned LineNo, DIType Ty, ArrayRef< Value * > Addr, unsigned ArgNo=0)
void addOperand(MDNode *M)
addOperand - Add metadata operand.
DINameSpace createNameSpace(DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNo)
void retainType(DIType T)
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
DIFile createFile(StringRef Filename, StringRef Directory)
static MDNode * createFilePathPair(LLVMContext &VMContext, StringRef Filename, StringRef Directory)
MDNode - a tuple of other values.
static MDNode * getNonCompileUnitScope(MDNode *N)
static IntegerType * getInt64Ty(LLVMContext &C)
DIBasicType createNullPtrType()
Create C++11 nullptr type.
DICompositeType createVectorType(uint64_t Size, uint64_t AlignInBits, DIType Ty, DIArray Subscripts)
createVectorType - Create debugging information entry for a vector.
static MDNode * get(LLVMContext &Context, ArrayRef< Value * > Vals)
static Constant * getNullValue(Type *Ty)
Value * getOperand(unsigned i) const LLVM_READONLY
getOperand - Return specified operand.
DIArray - This descriptor holds an array of descriptors.
DIVariable createLocalVariable(unsigned Tag, DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNo, DIType Ty, bool AlwaysPreserve=false, unsigned Flags=0, unsigned ArgNo=0)
createVariable - Create a new descriptor for the specified variable.
DILexicalBlockFile createLexicalBlockFile(DIDescriptor Scope, DIFile File)
bool Verify() const
Verify that the lexical block descriptor is well formed.
DISubprogram createMethod(DIDescriptor Scope, StringRef Name, StringRef LinkageName, DIFile File, unsigned LineNo, DICompositeType Ty, bool isLocalToUnit, bool isDefinition, unsigned Virtuality=0, unsigned VTableIndex=0, DIType VTableHolder=DIType(), unsigned Flags=0, bool isOptimized=false, Function *Fn=0, MDNode *TParam=0)
createMethod - Create a new descriptor for the specified C++ method.
DISubrange - This is used to represent ranges, for array bounds.
DIScopeRef getRef() const
DISubprogram - This is a wrapper for a subprogram (e.g. a function).
DICompositeType createEnumerationType(DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, DIArray Elements, DIType UnderlyingType, StringRef UniqueIdentifier=StringRef())
DIDescriptor createUnspecifiedParameter()
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
DIImportedEntity createImportedDeclaration(DIScope Context, DIDescriptor Decl, unsigned Line)
Create a descriptor for an imported function.
static Constant * GetTagConstant(LLVMContext &VMContext, unsigned Tag)
DIFile - This is a wrapper for a file.
DIDerivedType createFriend(DIType Ty, DIType FriendTy)
createFriend - Create debugging information entry for a 'friend'.
DICompositeType createArrayType(uint64_t Size, uint64_t AlignInBits, DIType Ty, DIArray Subscripts)
createArrayType - Create debugging information entry for an array.
bool isType() const
isType - Return true if the specified tag is legal for DIType.
DILexicalBlock - This is a wrapper for a lexical block.
DISubprogram getDISubprogram(const MDNode *Scope)
getDISubprogram - Find subprogram that is enclosing this scope.
DITemplateValueParameter - This is a wrapper for template value parameter.
LLVM Basic Block Representation.
DIDerivedType createPointerType(DIType PointeeTy, uint64_t SizeInBits, uint64_t AlignInBits=0, StringRef Name=StringRef())
createPointerType - Create debugging information entry for a pointer.
DIDescriptor getElement(unsigned Idx) const
LLVM Constant Representation.
DIArray getOrCreateArray(ArrayRef< Value * > Elements)
getOrCreateArray - Get a DIArray, create one if required.
Instruction * insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset, DIVariable VarInfo, BasicBlock *InsertAtEnd)
insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
DIType createObjectPointerType(DIType Ty)
DIGlobalVariable - This is a wrapper for a global variable.
DIDerivedType createReferenceType(unsigned Tag, DIType RTy)
bool Verify() const
Verify that the file-scoped lexical block descriptor is well formed.
bool empty() const
empty - Check if the array is empty.
unsigned getNumElements() const
void append(in_iter in_start, in_iter in_end)
bool isObjectPointer() const
DIDerivedType createStaticMemberType(DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNo, DIType Ty, unsigned Flags, llvm::Value *Val)
LLVMContext & getContext() const
All values hold a context through their type.
Instruction * insertDeclare(llvm::Value *Storage, DIVariable VarInfo, BasicBlock *InsertAtEnd)
insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
DISubrange getOrCreateSubrange(int64_t Lo, int64_t Count)
An imported module (C++ using directive or similar).
DIScope - A base class for various scopes.
static CallInst * Create(Value *Func, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=0)
DIDerivedType createMemberType(DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType Ty)
createMemberType - Create debugging information entry for a member.
T resolve(const DITypeIdentifierMap &Map) const
DIBasicType createUnspecifiedType(StringRef Name)
Create a DWARF unspecified type.
DINameSpace - A wrapper for a C++ style name space.
NamedMDNode * getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP)
DICompositeType createUnionType(DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, DIArray Elements, unsigned RunTimeLang=0, StringRef UniqueIdentifier=StringRef())
createUnionType - Create debugging information entry for an union.
DIImportedEntity createImportedModule(DIScope Context, DINameSpace NS, unsigned Line, StringRef Name=StringRef())
Create a descriptor for an imported module.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
DITemplateValueParameter createTemplateTemplateParameter(DIDescriptor Scope, StringRef Name, DIType Ty, StringRef Val, MDNode *File=0, unsigned LineNo=0, unsigned ColumnNo=0)
Create debugging information for a template template parameter.
DIDerivedType createMemberPointerType(DIType PointeeTy, DIType Class)
Create debugging information entry for a pointer to member.
DIDerivedType createQualifiedType(unsigned Tag, DIType FromTy)
DIDerivedType createTypedef(DIType Ty, StringRef Name, DIFile File, unsigned LineNo, DIDescriptor Context)
createTypedef - Create debugging information entry for a typedef.
static DIImportedEntity createImportedModule(LLVMContext &C, DIScope Context, DIDescriptor NS, unsigned Line, StringRef Name, SmallVectorImpl< Value * > &AllImportedModules)
static IntegerType * getInt32Ty(LLVMContext &C)
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
bool isCompositeType() const
unsigned getFlags() const
DITemplateTypeParameter createTemplateTypeParameter(DIDescriptor Scope, StringRef Name, DIType Ty, MDNode *File=0, unsigned LineNo=0, unsigned ColumnNo=0)
LLVM Value Representation.
DIGlobalVariable createStaticVariable(DIDescriptor Context, StringRef Name, StringRef LinkageName, DIFile File, unsigned LineNo, DIType Ty, bool isLocalToUnit, llvm::Value *Val, MDNode *Decl=NULL)
DISubprogram createFunction(DIDescriptor Scope, StringRef Name, StringRef LinkageName, DIFile File, unsigned LineNo, DICompositeType Ty, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, unsigned Flags=0, bool isOptimized=false, Function *Fn=0, MDNode *TParam=0, MDNode *Decl=0)
createFunction - Create a new descriptor for the specified function.
DIDerivedType createObjCIVar(StringRef Name, DIFile File, unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType Ty, StringRef PropertyName=StringRef(), StringRef PropertyGetterName=StringRef(), StringRef PropertySetterName=StringRef(), unsigned PropertyAttributes=0)
DIBasicType createBasicType(StringRef Name, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Encoding)
DIDerivedType createInheritance(DIType Ty, DIType BaseTy, uint64_t BaseOffset, unsigned Flags)
DIEnumerator createEnumerator(StringRef Name, int64_t Val)
createEnumerator - Create a single enumerator value.
bool Verify() const
Verify - Verify that a namespace descriptor is well formed.
NamedMDNode * getFnSpecificMDNode(const Module &M, DISubprogram SP)
DICompositeType createSubroutineType(DIFile File, DIArray ParameterTypes)
createSubroutineType - Create subroutine type.
DICompileUnit - A wrapper for a compile unit.
DICompositeType createStructType(DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, DIType DerivedFrom, DIArray Elements, unsigned RunTimeLang=0, DIType VTableHolder=DIType(), StringRef UniqueIdentifier=StringRef())
createStructType - Create debugging information entry for a struct.
DIType createArtificialType(DIType Ty)
createArtificialType - Create a new DIType with "artificial" flag set.
MDNode * getFileNode() const
Retrieve the MDNode for the directory/file pair.
bool empty() const
empty - Check if the string is empty.
DIBasicType - A basic type, like 'int' or 'float'.