本文整理汇总了C++中DIType::getNode方法的典型用法代码示例。如果您正苦于以下问题:C++ DIType::getNode方法的具体用法?C++ DIType::getNode怎么用?C++ DIType::getNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIType
的用法示例。
在下文中一共展示了DIType::getNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createVariantType
/// createVarinatType - Create variant type or return MainTy.
DIType DebugInfo::createVariantType(tree type, DIType MainTy) {
DIType Ty;
if (tree TyDef = TYPE_NAME(type)) {
std::map<tree_node *, WeakVH >::iterator I = TypeCache.find(TyDef);
if (I != TypeCache.end())
if (Value *M = I->second)
return DIType(cast<MDNode>(M));
if (TREE_CODE(TyDef) == TYPE_DECL && DECL_ORIGINAL_TYPE(TyDef)) {
expanded_location TypeDefLoc = GetNodeLocation(TyDef);
Ty = DebugFactory.CreateDerivedType(DW_TAG_typedef,
findRegion(DECL_CONTEXT(TyDef)),
GetNodeName(TyDef),
getOrCreateFile(TypeDefLoc.file),
TypeDefLoc.line,
0 /*size*/,
0 /*align*/,
0 /*offset */,
0 /*flags*/,
MainTy);
TypeCache[TyDef] = WeakVH(Ty.getNode());
return Ty;
}
}
if (TYPE_VOLATILE(type)) {
Ty = DebugFactory.CreateDerivedType(DW_TAG_volatile_type,
findRegion(TYPE_CONTEXT(type)),
StringRef(),
getOrCreateFile(main_input_filename),
0 /*line no*/,
NodeSizeInBits(type),
NodeAlignInBits(type),
0 /*offset */,
0 /* flags */,
MainTy);
MainTy = Ty;
}
if (TYPE_READONLY(type))
Ty = DebugFactory.CreateDerivedType(DW_TAG_const_type,
findRegion(TYPE_CONTEXT(type)),
StringRef(),
getOrCreateFile(main_input_filename),
0 /*line no*/,
NodeSizeInBits(type),
NodeAlignInBits(type),
0 /*offset */,
0 /* flags */,
MainTy);
if (TYPE_VOLATILE(type) || TYPE_READONLY(type)) {
TypeCache[type] = WeakVH(Ty.getNode());
return Ty;
}
// If, for some reason, main type varaint type is seen then use it.
return MainTy;
}
示例2: addType
/// addType - Add type into Tys.
bool DebugInfoFinder::addType(DIType DT) {
if (DT.isNull())
return false;
if (!NodesSeen.insert(DT.getNode()))
return false;
TYs.push_back(DT.getNode());
return true;
}
示例3: DIGlobalVariable
/// CreateGlobalVariable - Create a new descriptor for the specified global.
DIGlobalVariable
DIFactory::CreateGlobalVariable(DIDescriptor Context, const char * Name,
const char * DisplayName,
const char * LinkageName,
DICompileUnit CompileUnit,
unsigned LineNo, DIType Type,bool isLocalToUnit,
bool isDefinition, llvm::GlobalVariable *Val) {
Value *Elts[] = {
GetTagConstant(dwarf::DW_TAG_variable),
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
Context.getNode(),
MDString::get(VMContext, Name),
MDString::get(VMContext, DisplayName),
MDString::get(VMContext, LinkageName),
CompileUnit.getNode(),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
Type.getNode(),
ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit),
ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition),
Val
};
Value *const *Vs = &Elts[0];
MDNode *Node = MDNode::get(VMContext,Vs, 12);
// Create a named metadata so that we do not lose this mdnode.
NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv");
NMD->addElement(Node);
return DIGlobalVariable(Node);
}
示例4: CreateCompositeTypeEx
/// CreateCompositeType - Create a composite type like array, struct, etc.
DICompositeType DIFactory::CreateCompositeTypeEx(unsigned Tag,
DIDescriptor Context,
const char * Name,
DICompileUnit CompileUnit,
unsigned LineNumber,
Constant *SizeInBits,
Constant *AlignInBits,
Constant *OffsetInBits,
unsigned Flags,
DIType DerivedFrom,
DIArray Elements,
unsigned RuntimeLang) {
Value *Elts[] = {
GetTagConstant(Tag),
Context.getNode(),
MDString::get(VMContext, Name),
CompileUnit.getNode(),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
SizeInBits,
AlignInBits,
OffsetInBits,
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
DerivedFrom.getNode(),
Elements.getNode(),
ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang)
};
return DICompositeType(MDNode::get(VMContext, &Elts[0], 12));
}
示例5: EmitDeclare
/// EmitDeclare - Constructs the debug code for allocation of a new variable.
/// region - "llvm.dbg.declare."
void DebugInfo::EmitDeclare(tree decl, unsigned Tag, const char *Name,
tree type, Value *AI, LLVMBuilder &Builder) {
// Ignore compiler generated temporaries.
if (DECL_IGNORED_P(decl))
return;
assert(!RegionStack.empty() && "Region stack mismatch, stack empty!");
expanded_location Loc = GetNodeLocation(decl, false);
// Construct variable.
DIScope VarScope = DIScope(cast<MDNode>(RegionStack.back()));
DIType Ty = getOrCreateType(type);
if (DECL_ARTIFICIAL (decl))
Ty = DebugFactory.CreateArtificialType(Ty);
// If type info is not available then do not emit debug info for this var.
if (!Ty.getNode())
return;
llvm::DIVariable D =
DebugFactory.CreateVariable(Tag, VarScope,
Name, getOrCreateFile(Loc.file),
Loc.line, Ty, optimize);
// Insert an llvm.dbg.declare into the current block.
Instruction *Call = DebugFactory.InsertDeclare(AI, D,
Builder.GetInsertBlock());
Call->setDebugLoc(DebugLoc::get(Loc.line, 0, VarScope.getNode()));
}
示例6: CreateVariable
/// CreateVariable - Create a new descriptor for the specified variable.
DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context,
const char * Name,
DICompileUnit CompileUnit, unsigned LineNo,
DIType Type) {
Value *Elts[] = {
GetTagConstant(Tag),
Context.getNode(),
MDString::get(VMContext, Name),
CompileUnit.getNode(),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
Type.getNode(),
};
return DIVariable(MDNode::get(VMContext, &Elts[0], 6));
}
示例7: processType
/// processType - Process DIType.
void DebugInfoFinder::processType(DIType DT) {
if (!addType(DT))
return;
addCompileUnit(DT.getCompileUnit());
if (DT.isCompositeType()) {
DICompositeType DCT(DT.getNode());
processType(DCT.getTypeDerivedFrom());
DIArray DA = DCT.getTypeArray();
if (!DA.isNull())
for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) {
DIDescriptor D = DA.getElement(i);
DIType TypeE = DIType(D.getNode());
if (!TypeE.isNull())
processType(TypeE);
else
processSubprogram(DISubprogram(D.getNode()));
}
} else if (DT.isDerivedType()) {
DIDerivedType DDT(DT.getNode());
if (!DDT.isNull())
processType(DDT.getTypeDerivedFrom());
}
}
示例8: CreateComplexVariable
/// CreateComplexVariable - Create a new descriptor for the specified variable
/// which has a complex address expression for its address.
DIVariable DIFactory::CreateComplexVariable(unsigned Tag, DIDescriptor Context,
const std::string &Name,
DICompileUnit CompileUnit,
unsigned LineNo,
DIType Type, SmallVector<Value *, 9> &addr) {
SmallVector<Value *, 9> Elts;
Elts.push_back(GetTagConstant(Tag));
Elts.push_back(Context.getNode());
Elts.push_back(MDString::get(VMContext, Name));
Elts.push_back(CompileUnit.getNode());
Elts.push_back(ConstantInt::get(Type::getInt32Ty(VMContext), LineNo));
Elts.push_back(Type.getNode());
Elts.insert(Elts.end(), addr.begin(), addr.end());
return DIVariable(MDNode::get(VMContext, &Elts[0], 6+addr.size()));
}
示例9: createPointerType
/// createPointerType - Create PointerType.
DIType DebugInfo::createPointerType(tree type) {
DIType FromTy = getOrCreateType(TREE_TYPE(type));
// type* and type&
// FIXME: Should BLOCK_POINTER_TYP have its own DW_TAG?
unsigned Tag = (TREE_CODE(type) == POINTER_TYPE ||
TREE_CODE(type) == BLOCK_POINTER_TYPE) ?
DW_TAG_pointer_type :
DW_TAG_reference_type;
unsigned Flags = 0;
if (type_is_block_byref_struct(type))
Flags |= llvm::DIType::FlagBlockByrefStruct;
// Check if this pointer type has a name.
if (tree TyName = TYPE_NAME(type))
if (TREE_CODE(TyName) == TYPE_DECL && !DECL_ORIGINAL_TYPE(TyName)) {
expanded_location TypeNameLoc = GetNodeLocation(TyName);
DIType Ty =
DebugFactory.CreateDerivedType(Tag, findRegion(DECL_CONTEXT(TyName)),
GetNodeName(TyName),
getOrCreateFile(TypeNameLoc.file),
TypeNameLoc.line,
0 /*size*/,
0 /*align*/,
0 /*offset */,
0 /*flags*/,
FromTy);
TypeCache[TyName] = WeakVH(Ty.getNode());
return Ty;
}
StringRef PName = FromTy.getName();
DIType PTy =
DebugFactory.CreateDerivedType(Tag, findRegion(TYPE_CONTEXT(type)),
Tag == DW_TAG_pointer_type ?
StringRef() : PName,
getOrCreateFile(main_input_filename),
0 /*line no*/,
NodeSizeInBits(type),
NodeAlignInBits(type),
0 /*offset */,
Flags,
FromTy);
return PTy;
}
示例10: getOriginalTypeSize
/// getOriginalTypeSize - If this type is derived from a base type then
/// return base type size.
uint64_t DIDerivedType::getOriginalTypeSize() const {
unsigned Tag = getTag();
if (Tag == dwarf::DW_TAG_member || Tag == dwarf::DW_TAG_typedef ||
Tag == dwarf::DW_TAG_const_type || Tag == dwarf::DW_TAG_volatile_type ||
Tag == dwarf::DW_TAG_restrict_type) {
DIType BaseType = getTypeDerivedFrom();
// If this type is not derived from any type then take conservative
// approach.
if (BaseType.isNull())
return getSizeInBits();
if (BaseType.isDerivedType())
return DIDerivedType(BaseType.getNode()).getOriginalTypeSize();
else
return BaseType.getSizeInBits();
}
return getSizeInBits();
}
示例11: switch
/// PopulateDerivedTypeInfo - Populate TypeNo, Aux[], TagName for derived type
/// from Ty. Derived types are mostly pointers.
///
void PIC16DbgInfo::PopulateDerivedTypeInfo (DIType Ty, unsigned short &TypeNo,
bool &HasAux, int Aux[],
std::string &TagName) {
switch(Ty.getTag())
{
case dwarf::DW_TAG_pointer_type:
TypeNo = TypeNo << PIC16Dbg::S_DERIVED;
TypeNo = TypeNo | PIC16Dbg::DT_PTR;
break;
default:
TypeNo = TypeNo << PIC16Dbg::S_DERIVED;
}
// We also need to encode the information about the base type of
// pointer in TypeNo.
DIType BaseType = DIDerivedType(Ty.getNode()).getTypeDerivedFrom();
PopulateDebugInfo(BaseType, TypeNo, HasAux, Aux, TagName);
}
示例12: DICompositeType
/// PopulateArrayTypeInfo - Populate TypeNo, Aux[] for array from Ty.
void PIC16DbgInfo::PopulateArrayTypeInfo (DIType Ty, unsigned short &TypeNo,
bool &HasAux, int Aux[],
std::string &TagName) {
DICompositeType CTy = DICompositeType(Ty.getNode());
DIArray Elements = CTy.getTypeArray();
unsigned short size = 1;
unsigned short Dimension[4]={0,0,0,0};
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
DIDescriptor Element = Elements.getElement(i);
if (Element.getTag() == dwarf::DW_TAG_subrange_type) {
TypeNo = TypeNo << PIC16Dbg::S_DERIVED;
TypeNo = TypeNo | PIC16Dbg::DT_ARY;
DISubrange SubRange = DISubrange(Element.getNode());
Dimension[i] = SubRange.getHi() - SubRange.getLo() + 1;
// Each dimension is represented by 2 bytes starting at byte 9.
Aux[8+i*2+0] = Dimension[i];
Aux[8+i*2+1] = Dimension[i] >> 8;
size = size * Dimension[i];
}
}
示例13: CreateSubprogram
/// CreateSubprogram - Create a new descriptor for the specified subprogram.
/// See comments in DISubprogram for descriptions of these fields. This
/// method does not unique the generated descriptors.
DISubprogram DIFactory::CreateSubprogram(DIDescriptor Context,
const char * Name,
const char * DisplayName,
const char * LinkageName,
DICompileUnit CompileUnit,
unsigned LineNo, DIType Type,
bool isLocalToUnit,
bool isDefinition) {
Value *Elts[] = {
GetTagConstant(dwarf::DW_TAG_subprogram),
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
Context.getNode(),
MDString::get(VMContext, Name),
MDString::get(VMContext, DisplayName),
MDString::get(VMContext, LinkageName),
CompileUnit.getNode(),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
Type.getNode(),
ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit),
ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition)
};
return DISubprogram(MDNode::get(VMContext, &Elts[0], 11));
}
示例14: CreateDerivedType
/// CreateDerivedType - Create a derived type like const qualified type,
/// pointer, typedef, etc.
DIDerivedType DIFactory::CreateDerivedType(unsigned Tag,
DIDescriptor Context,
const char * Name,
DICompileUnit CompileUnit,
unsigned LineNumber,
uint64_t SizeInBits,
uint64_t AlignInBits,
uint64_t OffsetInBits,
unsigned Flags,
DIType DerivedFrom) {
Value *Elts[] = {
GetTagConstant(Tag),
Context.getNode(),
MDString::get(VMContext, Name),
CompileUnit.getNode(),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
DerivedFrom.getNode(),
};
return DIDerivedType(MDNode::get(VMContext, &Elts[0], 10));
}
示例15: findRegion
/// findRegion - Find the region (context) of a GCC tree.
DIDescriptor DebugInfo::findRegion(tree exp) {
if (exp == NULL_TREE)
return getOrCreateFile(main_input_filename);
tree Node = exp;
location_t *p_locus = 0;
tree_code code = TREE_CODE(exp);
enum tree_code_class tree_cc = TREE_CODE_CLASS(code);
switch (tree_cc) {
case tcc_declaration: /* A decl node */
p_locus = &DECL_SOURCE_LOCATION(exp);
break;
case tcc_expression: /* an expression */
case tcc_comparison: /* a comparison expression */
case tcc_unary: /* a unary arithmetic expression */
case tcc_binary: /* a binary arithmetic expression */
Node = TREE_BLOCK(exp);
p_locus = EXPR_LOCUS(exp);
break;
case tcc_exceptional:
switch (code) {
case BLOCK:
p_locus = &BLOCK_SOURCE_LOCATION(Node);
break;
default:
gcc_unreachable ();
}
break;
default:
break;
}
std::map<tree_node *, WeakVH>::iterator I = RegionMap.find(Node);
if (I != RegionMap.end())
if (MDNode *R = dyn_cast_or_null<MDNode>(I->second))
return DIDescriptor(R);
if (TYPE_P (Node)) {
DIType Ty = getOrCreateType(Node);
return DIDescriptor(Ty.getNode());
} else if (DECL_P (Node)) {
switch (TREE_CODE(Node)) {
default:
/// What kind of DECL is this?
return findRegion (DECL_CONTEXT (Node));
case NAMESPACE_DECL: {
DIDescriptor NSContext = findRegion(DECL_CONTEXT(Node));
DINameSpace NS = getOrCreateNameSpace(Node, NSContext);
return DIDescriptor(NS.getNode());
}
case FUNCTION_DECL: {
DISubprogram SP = CreateSubprogramFromFnDecl(Node);
return SP;
}
}
} else if (TREE_CODE(Node) == BLOCK) {
// Recursively establish ancestor scopes.
DIDescriptor context = findRegion(BLOCK_SUPERCONTEXT(Node));
// If we don't have a location, use the last-seen info.
unsigned int line;
const char *fullpath;
if (LOCATION_FILE(*p_locus) == (char*)0) {
fullpath = CurFullPath;
line = CurLineNo;
} else {
fullpath = LOCATION_FILE(*p_locus);
line = LOCATION_LINE(*p_locus);
}
DIFile F(getOrCreateFile(fullpath));
DILexicalBlock lexical_block =
DebugFactory.CreateLexicalBlock(context, F, line, 0U);
RegionMap[Node] = WeakVH(lexical_block.getNode());
return DIDescriptor(lexical_block);
}
// Otherwise main compile unit covers everything.
return getOrCreateFile(main_input_filename);
}