void dump() const;
};
- /// DIGlobal - This is a common class for global variables and subprograms.
- class DIGlobal : public DIDescriptor {
- protected:
- explicit DIGlobal(const MDNode *N) : DIDescriptor(N) {}
-
- public:
- virtual ~DIGlobal() {}
-
- DIScope getContext() const { return getFieldAs<DIScope>(2); }
- StringRef getName() const { return getStringField(3); }
- StringRef getDisplayName() const { return getStringField(4); }
- StringRef getLinkageName() const { return getStringField(5); }
- DICompileUnit getCompileUnit() const{
- if (getVersion() == llvm::LLVMDebugVersion7)
- return getFieldAs<DICompileUnit>(6);
-
- DIFile F = getFieldAs<DIFile>(6);
- return F.getCompileUnit();
- }
-
- unsigned getLineNumber() const { return getUnsignedField(7); }
- DIType getType() const { return getFieldAs<DIType>(8); }
-
- /// 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); }
-
- /// print - print global.
- void print(raw_ostream &OS) const;
-
- /// dump - print global to dbgs() with a newline.
- void dump() const;
- };
-
/// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
class DISubprogram : public DIScope {
public:
};
/// DIGlobalVariable - This is a wrapper for a global variable.
- class DIGlobalVariable : public DIGlobal {
+ class DIGlobalVariable : public DIDescriptor {
public:
- explicit DIGlobalVariable(const MDNode *N = 0) : DIGlobal(N) {}
+ explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
+
+ DIScope getContext() const { return getFieldAs<DIScope>(2); }
+ StringRef getName() const { return getStringField(3); }
+ StringRef getDisplayName() const { return getStringField(4); }
+ StringRef getLinkageName() const { return getStringField(5); }
+ DICompileUnit getCompileUnit() const{
+ if (getVersion() == llvm::LLVMDebugVersion7)
+ return getFieldAs<DICompileUnit>(6);
+
+ DIFile F = getFieldAs<DIFile>(6);
+ return F.getCompileUnit();
+ }
+
+ unsigned getLineNumber() const { return getUnsignedField(7); }
+ DIType getType() const { return getFieldAs<DIType>(8); }
+ unsigned isLocalToUnit() const { return getUnsignedField(9); }
+ unsigned isDefinition() const { return getUnsignedField(10); }
GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
OS << " [" << A.getNumElements() << " elements]";
}
-/// print - Print global.
-void DIGlobal::print(raw_ostream &OS) const {
+/// print - Print subprogram.
+void DISubprogram::print(raw_ostream &OS) const {
StringRef Res = getName();
if (!Res.empty())
OS << " [" << Res << "] ";
if (isDefinition())
OS << " [def] ";
- if (isGlobalVariable())
- DIGlobalVariable(DbgNode).print(OS);
-
OS << "\n";
}
-/// print - Print subprogram.
-void DISubprogram::print(raw_ostream &OS) const {
+/// print - Print global variable.
+void DIGlobalVariable::print(raw_ostream &OS) const {
+ OS << " [";
StringRef Res = getName();
if (!Res.empty())
OS << " [" << Res << "] ";
if (isDefinition())
OS << " [def] ";
- OS << "\n";
-}
-
-/// print - Print global variable.
-void DIGlobalVariable::print(raw_ostream &OS) const {
- OS << " [";
- getGlobal()->print(OS);
- OS << "] ";
+ if (isGlobalVariable())
+ DIGlobalVariable(DbgNode).print(OS);
+ OS << "]\n";
}
/// print - Print variable.
print(dbgs()); dbgs() << '\n';
}
-/// dump - Print global to dbgs() with a newline.
-void DIGlobal::dump() const {
- print(dbgs()); dbgs() << '\n';
-}
-
/// dump - Print subprogram to dbgs() with a newline.
void DISubprogram::dump() const {
print(dbgs()); dbgs() << '\n';
/// addSourceLine - Add location information to specified debug information
/// entry.
void addSourceLine(DIE *Die, const DIVariable *V);
- void addSourceLine(DIE *Die, const DIGlobal *G);
+ void addSourceLine(DIE *Die, const DIGlobalVariable *G);
void addSourceLine(DIE *Die, const DISubprogram *SP);
void addSourceLine(DIE *Die, const DIType *Ty);
void addSourceLine(DIE *Die, const DINameSpace *NS);