Correct indentation for dumping LexicalScope.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174237 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Manman Ren 2013-02-02 00:02:03 +00:00
parent 945e828003
commit 7650d9b893
2 changed files with 7 additions and 15 deletions

View File

@ -159,9 +159,6 @@ public:
LexicalScope(LexicalScope *P, const MDNode *D, const MDNode *I, bool A) LexicalScope(LexicalScope *P, const MDNode *D, const MDNode *I, bool A)
: Parent(P), Desc(D), InlinedAtLocation(I), AbstractScope(A), : Parent(P), Desc(D), InlinedAtLocation(I), AbstractScope(A),
LastInsn(0), FirstInsn(0), DFSIn(0), DFSOut(0) { LastInsn(0), FirstInsn(0), DFSIn(0), DFSOut(0) {
#ifndef NDEBUG
IndentLevel = 0;
#endif
if (Parent) if (Parent)
Parent->addChild(this); Parent->addChild(this);
} }
@ -228,7 +225,7 @@ public:
void setDFSIn(unsigned I) { DFSIn = I; } void setDFSIn(unsigned I) { DFSIn = I; }
/// dump - print lexical scope. /// dump - print lexical scope.
void dump() const; void dump(unsigned Indent = 0) const;
private: private:
LexicalScope *Parent; // Parent to this scope. LexicalScope *Parent; // Parent to this scope.
@ -244,9 +241,6 @@ private:
const MachineInstr *FirstInsn; // First instruction of this scope. const MachineInstr *FirstInsn; // First instruction of this scope.
unsigned DFSIn, DFSOut; // In & Out Depth use to determine unsigned DFSIn, DFSOut; // In & Out Depth use to determine
// scope nesting. // scope nesting.
#ifndef NDEBUG
mutable unsigned IndentLevel; // Private state for dump()
#endif
}; };
} // end llvm namespace } // end llvm namespace

View File

@ -314,24 +314,22 @@ bool LexicalScopes::dominates(DebugLoc DL, MachineBasicBlock *MBB) {
void LexicalScope::anchor() { } void LexicalScope::anchor() { }
/// dump - Print data structures. /// dump - Print data structures.
void LexicalScope::dump() const { void LexicalScope::dump(unsigned Indent) const {
#ifndef NDEBUG #ifndef NDEBUG
raw_ostream &err = dbgs(); raw_ostream &err = dbgs();
err.indent(IndentLevel); err.indent(Indent);
err << "DFSIn: " << DFSIn << " DFSOut: " << DFSOut << "\n"; err << "DFSIn: " << DFSIn << " DFSOut: " << DFSOut << "\n";
const MDNode *N = Desc; const MDNode *N = Desc;
err.indent(Indent);
N->dump(); N->dump();
if (AbstractScope) if (AbstractScope)
err << "Abstract Scope\n"; err << std::string(Indent, ' ') << "Abstract Scope\n";
IndentLevel += 2;
if (!Children.empty()) if (!Children.empty())
err << "Children ...\n"; err << std::string(Indent + 2, ' ') << "Children ...\n";
for (unsigned i = 0, e = Children.size(); i != e; ++i) for (unsigned i = 0, e = Children.size(); i != e; ++i)
if (Children[i] != this) if (Children[i] != this)
Children[i]->dump(); Children[i]->dump(Indent + 2);
IndentLevel -= 2;
#endif #endif
} }