[IR] Provide an API to skip the details of a structured type when printed.

The mir infrastructure will need this for generic instructions and currently
this feature was only available through the anonymous TypePrinter class.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262869 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Quentin Colombet 2016-03-07 22:32:42 +00:00
parent 2ba0323edd
commit dbefd77861
2 changed files with 12 additions and 2 deletions

View File

@ -112,7 +112,14 @@ protected:
}
public:
void print(raw_ostream &O, bool IsForDebug = false) const;
/// Print the current type.
/// Omit the type details if \p NoDetails == true.
/// E.g., let %st = type { i32, i16 }
/// When \p NoDetails is true, we only print %st.
/// Put differently, \p NoDetails prints the type as if
/// inlined with the operands when printing an instruction.
void print(raw_ostream &O, bool IsForDebug = false,
bool NoDetails = false) const;
void dump() const;
/// getContext - Return the LLVMContext in which this type was uniqued.

View File

@ -3269,10 +3269,13 @@ void Comdat::print(raw_ostream &ROS, bool /*IsForDebug*/) const {
ROS << '\n';
}
void Type::print(raw_ostream &OS, bool /*IsForDebug*/) const {
void Type::print(raw_ostream &OS, bool /*IsForDebug*/, bool NoDetails) const {
TypePrinting TP;
TP.print(const_cast<Type*>(this), OS);
if (NoDetails)
return;
// If the type is a named struct type, print the body as well.
if (StructType *STy = dyn_cast<StructType>(const_cast<Type*>(this)))
if (!STy->isLiteral()) {