[llvm-commits] [llvm] r103254 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp
Dan Gohman
gohman at apple.com
Fri May 7 08:30:29 PDT 2010
Author: djg
Date: Fri May 7 10:30:29 2010
New Revision: 103254
URL: http://llvm.org/viewvc/llvm-project?rev=103254&view=rev
Log:
Convert the DebugInfo classes dump() methods into print(raw_ostream &)
methods, and add dump functions implemented in terms of the print.
Modified:
llvm/trunk/include/llvm/Analysis/DebugInfo.h
llvm/trunk/lib/Analysis/DebugInfo.cpp
Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=103254&r1=103253&r2=103254&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Fri May 7 10:30:29 2010
@@ -34,6 +34,7 @@
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 @@
/// 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 @@
/// 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 @@
}
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 @@
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 @@
/// 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 @@
/// 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 @@
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 @@
/// 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 @@
/// 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 @@
/// 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;
};
Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=103254&r1=103253&r2=103254&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/DebugInfo.cpp Fri May 7 10:30:29 2010
@@ -475,34 +475,34 @@
//===----------------------------------------------------------------------===//
-/// 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 @@
<< "] ";
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 @@
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
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list