aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-05-07 15:30:29 +0000
committerDan Gohman <gohman@apple.com>2010-05-07 15:30:29 +0000
commit504043662ced71235b7c7d4ae3ce3cee898cb391 (patch)
treed4d85b20a38ca45a7cad8934764d9138cd79be95
parent733783b27c9f07d090747213e2a2db646eaeb18a (diff)
Convert the DebugInfo classes dump() methods into print(raw_ostream &)
methods, and add dump functions implemented in terms of the print. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103254 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/DebugInfo.h53
-rw-r--r--lib/Analysis/DebugInfo.cpp154
2 files changed, 145 insertions, 62 deletions
diff --git a/include/llvm/Analysis/DebugInfo.h b/include/llvm/Analysis/DebugInfo.h
index 9b1379d90a..9a465b0eec 100644
--- a/include/llvm/Analysis/DebugInfo.h
+++ b/include/llvm/Analysis/DebugInfo.h
@@ -34,6 +34,7 @@ namespace llvm {
class Instruction;
class MDNode;
class LLVMContext;
+ class raw_ostream;
/// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
/// This should not be stored in a container, because underly MDNode may
@@ -75,7 +76,10 @@ namespace llvm {
/// ValidDebugInfo - Return true if N represents valid debug info value.
static bool ValidDebugInfo(MDNode *N, unsigned OptLevel);
- /// dump - print descriptor.
+ /// print - print descriptor.
+ void print(raw_ostream &OS) const;
+
+ /// dump - print descriptor to dbgs() with a newline.
void dump() const;
bool isDerivedType() const;
@@ -153,7 +157,10 @@ namespace llvm {
/// Verify - Verify that a compile unit is well formed.
bool Verify() const;
- /// dump - print compile unit.
+ /// print - print compile unit.
+ void print(raw_ostream &OS) const;
+
+ /// dump - print compile unit to dbgs() with a newline.
void dump() const;
};
@@ -253,7 +260,11 @@ namespace llvm {
}
StringRef getFilename() const { return getCompileUnit().getFilename();}
StringRef getDirectory() const { return getCompileUnit().getDirectory();}
- /// dump - print type.
+
+ /// print - print type.
+ void print(raw_ostream &OS) const;
+
+ /// dump - print type to dbgs() with a newline.
void dump() const;
};
@@ -264,7 +275,10 @@ namespace llvm {
unsigned getEncoding() const { return getUnsignedField(9); }
- /// dump - print basic type.
+ /// print - print basic type.
+ void print(raw_ostream &OS) const;
+
+ /// dump - print basic type to dbgs() with a newline.
void dump() const;
};
@@ -283,7 +297,11 @@ namespace llvm {
/// getOriginalTypeSize - If this type is derived from a base type then
/// return base type size.
uint64_t getOriginalTypeSize() const;
- /// dump - print derived type.
+
+ /// print - print derived type.
+ void print(raw_ostream &OS) const;
+
+ /// dump - print derived type to dbgs() with a newline.
void dump() const;
/// replaceAllUsesWith - Replace all uses of debug info referenced by
@@ -312,7 +330,10 @@ namespace llvm {
/// Verify - Verify that a composite type descriptor is well formed.
bool Verify() const;
- /// dump - print composite type.
+ /// print - print composite type.
+ void print(raw_ostream &OS) const;
+
+ /// dump - print composite type to dbgs() with a newline.
void dump() const;
};
@@ -344,7 +365,10 @@ namespace llvm {
unsigned isLocalToUnit() const { return getUnsignedField(9); }
unsigned isDefinition() const { return getUnsignedField(10); }
- /// dump - print global.
+ /// print - print global.
+ void print(raw_ostream &OS) const;
+
+ /// dump - print global to dbgs() with a newline.
void dump() const;
};
@@ -413,7 +437,10 @@ namespace llvm {
/// Verify - Verify that a subprogram descriptor is well formed.
bool Verify() const;
- /// dump - print subprogram.
+ /// print - print subprogram.
+ void print(raw_ostream &OS) const;
+
+ /// dump - print subprogram to dbgs() with a newline.
void dump() const;
/// describes - Return true if this subprogram provides debugging
@@ -431,7 +458,10 @@ namespace llvm {
/// Verify - Verify that a global variable descriptor is well formed.
bool Verify() const;
- /// dump - print global variable.
+ /// print - print global variable.
+ void print(raw_ostream &OS) const;
+
+ /// dump - print global variable to dbgs() with a newline.
void dump() const;
};
@@ -479,7 +509,10 @@ namespace llvm {
/// information for an inlined function arguments.
bool isInlinedFnArgument(const Function *CurFn);
- /// dump - print variable.
+ /// print - print variable.
+ void print(raw_ostream &OS) const;
+
+ /// dump - print variable to dbgs() with a newline.
void dump() const;
};
diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp
index 141b181ab7..e4233540a5 100644
--- a/lib/Analysis/DebugInfo.cpp
+++ b/lib/Analysis/DebugInfo.cpp
@@ -475,34 +475,34 @@ StringRef DIScope::getDirectory() const {
//===----------------------------------------------------------------------===//
-/// dump - Print descriptor.
-void DIDescriptor::dump() const {
- dbgs() << "[" << dwarf::TagString(getTag()) << "] ";
- dbgs().write_hex((intptr_t) &*DbgNode) << ']';
+/// print - Print descriptor.
+void DIDescriptor::print(raw_ostream &OS) const {
+ OS << "[" << dwarf::TagString(getTag()) << "] ";
+ OS.write_hex((intptr_t) &*DbgNode) << ']';
}
-/// dump - Print compile unit.
-void DICompileUnit::dump() const {
+/// print - Print compile unit.
+void DICompileUnit::print(raw_ostream &OS) const {
if (getLanguage())
- dbgs() << " [" << dwarf::LanguageString(getLanguage()) << "] ";
+ OS << " [" << dwarf::LanguageString(getLanguage()) << "] ";
- dbgs() << " [" << getDirectory() << "/" << getFilename() << " ]";
+ OS << " [" << getDirectory() << "/" << getFilename() << " ]";
}
-/// dump - Print type.
-void DIType::dump() const {
+/// print - Print type.
+void DIType::print(raw_ostream &OS) const {
if (!DbgNode) return;
StringRef Res = getName();
if (!Res.empty())
- dbgs() << " [" << Res << "] ";
+ OS << " [" << Res << "] ";
unsigned Tag = getTag();
- dbgs() << " [" << dwarf::TagString(Tag) << "] ";
+ OS << " [" << dwarf::TagString(Tag) << "] ";
// TODO : Print context
getCompileUnit().dump();
- dbgs() << " ["
+ OS << " ["
<< getLineNumber() << ", "
<< getSizeInBits() << ", "
<< getAlignInBits() << ", "
@@ -510,12 +510,12 @@ void DIType::dump() const {
<< "] ";
if (isPrivate())
- dbgs() << " [private] ";
+ OS << " [private] ";
else if (isProtected())
- dbgs() << " [protected] ";
+ OS << " [protected] ";
if (isForwardDecl())
- dbgs() << " [fwd] ";
+ OS << " [fwd] ";
if (isBasicType())
DIBasicType(DbgNode).dump();
@@ -524,97 +524,147 @@ void DIType::dump() const {
else if (isCompositeType())
DICompositeType(DbgNode).dump();
else {
- dbgs() << "Invalid DIType\n";
+ OS << "Invalid DIType\n";
return;
}
- dbgs() << "\n";
+ OS << "\n";
}
-/// dump - Print basic type.
-void DIBasicType::dump() const {
- dbgs() << " [" << dwarf::AttributeEncodingString(getEncoding()) << "] ";
+/// print - Print basic type.
+void DIBasicType::print(raw_ostream &OS) const {
+ OS << " [" << dwarf::AttributeEncodingString(getEncoding()) << "] ";
}
-/// dump - Print derived type.
-void DIDerivedType::dump() const {
- dbgs() << "\n\t Derived From: "; getTypeDerivedFrom().dump();
+/// print - Print derived type.
+void DIDerivedType::print(raw_ostream &OS) const {
+ OS << "\n\t Derived From: "; getTypeDerivedFrom().dump();
}
-/// dump - Print composite type.
-void DICompositeType::dump() const {
+/// print - Print composite type.
+void DICompositeType::print(raw_ostream &OS) const {
DIArray A = getTypeArray();
- dbgs() << " [" << A.getNumElements() << " elements]";
+ OS << " [" << A.getNumElements() << " elements]";
}
-/// dump - Print global.
-void DIGlobal::dump() const {
+/// print - Print global.
+void DIGlobal::print(raw_ostream &OS) const {
StringRef Res = getName();
if (!Res.empty())
- dbgs() << " [" << Res << "] ";
+ OS << " [" << Res << "] ";
unsigned Tag = getTag();
- dbgs() << " [" << dwarf::TagString(Tag) << "] ";
+ OS << " [" << dwarf::TagString(Tag) << "] ";
// TODO : Print context
getCompileUnit().dump();
- dbgs() << " [" << getLineNumber() << "] ";
+ OS << " [" << getLineNumber() << "] ";
if (isLocalToUnit())
- dbgs() << " [local] ";
+ OS << " [local] ";
if (isDefinition())
- dbgs() << " [def] ";
+ OS << " [def] ";
if (isGlobalVariable())
DIGlobalVariable(DbgNode).dump();
- dbgs() << "\n";
+ OS << "\n";
}
-/// dump - Print subprogram.
-void DISubprogram::dump() const {
+/// print - Print subprogram.
+void DISubprogram::print(raw_ostream &OS) const {
StringRef Res = getName();
if (!Res.empty())
- dbgs() << " [" << Res << "] ";
+ OS << " [" << Res << "] ";
unsigned Tag = getTag();
- dbgs() << " [" << dwarf::TagString(Tag) << "] ";
+ OS << " [" << dwarf::TagString(Tag) << "] ";
// TODO : Print context
getCompileUnit().dump();
- dbgs() << " [" << getLineNumber() << "] ";
+ OS << " [" << getLineNumber() << "] ";
if (isLocalToUnit())
- dbgs() << " [local] ";
+ OS << " [local] ";
if (isDefinition())
- dbgs() << " [def] ";
+ OS << " [def] ";
- dbgs() << "\n";
+ OS << "\n";
}
-/// dump - Print global variable.
-void DIGlobalVariable::dump() const {
- dbgs() << " [";
+/// print - Print global variable.
+void DIGlobalVariable::print(raw_ostream &OS) const {
+ OS << " [";
getGlobal()->dump();
- dbgs() << "] ";
+ OS << "] ";
}
-/// dump - Print variable.
-void DIVariable::dump() const {
+/// print - Print variable.
+void DIVariable::print(raw_ostream &OS) const {
StringRef Res = getName();
if (!Res.empty())
- dbgs() << " [" << Res << "] ";
+ OS << " [" << Res << "] ";
getCompileUnit().dump();
- dbgs() << " [" << getLineNumber() << "] ";
+ OS << " [" << getLineNumber() << "] ";
getType().dump();
- dbgs() << "\n";
+ OS << "\n";
// FIXME: Dump complex addresses
}
+/// dump - Print descriptor to dbgs() with a newline.
+void DIDescriptor::dump() const {
+ print(dbgs()); dbgs() << '\n';
+}
+
+/// dump - Print compile unit to dbgs() with a newline.
+void DICompileUnit::dump() const {
+ print(dbgs()); dbgs() << '\n';
+}
+
+/// dump - Print type to dbgs() with a newline.
+void DIType::dump() const {
+ print(dbgs()); dbgs() << '\n';
+}
+
+/// dump - Print basic type to dbgs() with a newline.
+void DIBasicType::dump() const {
+ print(dbgs()); dbgs() << '\n';
+}
+
+/// dump - Print derived type to dbgs() with a newline.
+void DIDerivedType::dump() const {
+ print(dbgs()); dbgs() << '\n';
+}
+
+/// dump - Print composite type to dbgs() with a newline.
+void DICompositeType::dump() const {
+ 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';
+}
+
+/// dump - Print global variable.
+void DIGlobalVariable::dump() const {
+ print(dbgs()); dbgs() << '\n';
+}
+
+/// dump - Print variable.
+void DIVariable::dump() const {
+ print(dbgs()); dbgs() << '\n';
+}
+
//===----------------------------------------------------------------------===//
// DIFactory: Basic Helpers
//===----------------------------------------------------------------------===//