bool isSubprogram() const;
bool isGlobalVariable() const;
bool isScope() const;
+ bool isCompileUnit() const;
+ bool isLexicalBlock() const;
};
/// DISubrange - This is used to represent ranges, for array bounds.
if (DbgNode && !isScope())
DbgNode = 0;
}
+
+ virtual const std::string &getFilename(std::string &F) const {
+ return F;
+ }
+
+ virtual const std::string &getDirectory(std::string &D) const {
+ return D;
+ }
};
/// DICompileUnit - A wrapper for a compile unit.
- class DICompileUnit : public DIDescriptor {
+ class DICompileUnit : public DIScope {
public:
- explicit DICompileUnit(MDNode *N = 0)
- : DIDescriptor(N, dwarf::DW_TAG_compile_unit) {}
+ explicit DICompileUnit(MDNode *N = 0) {
+ DbgNode = N;
+ if (DbgNode && !isCompileUnit())
+ DbgNode = 0;
+ }
unsigned getLanguage() const { return getUnsignedField(2); }
const std::string &getFilename(std::string &F) const {
};
/// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
- class DISubprogram : public DIGlobal {
+ class DISubprogram : public DIScope {
public:
- explicit DISubprogram(MDNode *N = 0)
- : DIGlobal(N, dwarf::DW_TAG_subprogram) {}
+ explicit DISubprogram(MDNode *N = 0) {
+ DbgNode = N;
+ if (DbgNode && !isSubprogram())
+ DbgNode = 0;
+ }
+ DIDescriptor getContext() const { return getDescriptorField(2); }
+ const std::string &getName(std::string &F) const {
+ return getStringField(3, F);
+ }
+ const std::string &getDisplayName(std::string &F) const {
+ return getStringField(4, F);
+ }
+ const std::string &getLinkageName(std::string &F) const {
+ return getStringField(5, F);
+ }
+ DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(6); }
+ unsigned getLineNumber() const { return getUnsignedField(7); }
DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
/// getReturnTypeName - Subprogram return types are encoded either as
return T.getName(F);
}
+ /// isLocalToUnit - Return true if this subprogram is local to the current
+ /// compile unit, like 'static' in C.
+ unsigned isLocalToUnit() const { return getUnsignedField(9); }
+ unsigned isDefinition() const { return getUnsignedField(10); }
+
+ const std::string &getFilename(std::string &F) const {
+ return getCompileUnit().getFilename(F);
+ }
+ const std::string &getDirectory(std::string &F) const {
+ return getCompileUnit().getDirectory(F);
+ }
+
/// Verify - Verify that a subprogram descriptor is well formed.
bool Verify() const;
void dump() const;
};
- /// DIBlock - This is a wrapper for a block (e.g. a function, scope, etc).
- class DIBlock : public DIDescriptor {
+ /// DILexicalBlock - This is a wrapper for a lexical block.
+ class DILexicalBlock : public DIScope {
public:
- explicit DIBlock(MDNode *N = 0)
- : DIDescriptor(N, dwarf::DW_TAG_lexical_block) {}
+ explicit DILexicalBlock(MDNode *N = 0) {
+ DbgNode = N;
+ if (DbgNode && !isLexicalBlock())
+ DbgNode = 0;
+ }
+ DIScope getContext() const { return getFieldAs<DIScope>(1); }
- DIDescriptor getContext() const { return getDescriptorField(1); }
+ const std::string &getFilename(std::string &F) const {
+ return getContext().getFilename(F);
+ }
+ const std::string &getDirectory(std::string &D) const {
+ return getContext().getDirectory(D);
+ }
+ };
+
+ /// DILocation - This object holds location information. This object
+ /// is not associated with any DWARF tag.
+ class DILocation : public DIDescriptor {
+ public:
+ explicit DILocation(MDNode *L) { DbgNode = L; }
+
+ unsigned getLineNumber() const { return getUnsignedField(0); }
+ unsigned getColumnNumber() const { return getUnsignedField(1); }
+ DIScope getScope() const { return getFieldAs<DIScope>(3); }
+ DILocation getOrigLocation() const { return getFieldAs<DILocation>(4); }
+ std::string getFilename(std::string &F) const {
+ return getScope().getFilename(F);
+ }
+ std::string getDirectory(std::string &D) const {
+ return getScope().getDirectory(D);
+ }
};
/// DIFactory - This object assists with the construction of the various
DICompileUnit CompileUnit, unsigned LineNo,
DIType Type);
- /// CreateBlock - This creates a descriptor for a lexical block with the
- /// specified parent context.
- DIBlock CreateBlock(DIDescriptor Context);
+ /// CreateLexicalBlock - This creates a descriptor for a lexical block
+ /// with the specified parent context.
+ DILexicalBlock CreateLexicalBlock(DIDescriptor Context);
+
+ /// CreateLocation - Creates a debug info location.
+ DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
+ DIScope S, DILocation OrigLoc);
/// InsertStopPoint - Create a new llvm.dbg.stoppoint intrinsic invocation,
/// inserting it at the end of the specified basic block.