summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2013-11-12 18:06:09 +0000
committerAndrew Trick <atrick@apple.com>2013-11-12 18:06:09 +0000
commit2f08e75a45b9fa698a49277f6cc11e041bf5fa51 (patch)
treed931fdab24bf6a86de5b204ae4d1b98f869b6706 /include
parent4be0c592c42739b1927aaf2a20b3fabbf6adf335 (diff)
downloadllvm-2f08e75a45b9fa698a49277f6cc11e041bf5fa51.tar.gz
llvm-2f08e75a45b9fa698a49277f6cc11e041bf5fa51.tar.bz2
llvm-2f08e75a45b9fa698a49277f6cc11e041bf5fa51.tar.xz
GraphViz CFGPrinter: wrap long lines.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194496 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Analysis/CFGPrinter.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/include/llvm/Analysis/CFGPrinter.h b/include/llvm/Analysis/CFGPrinter.h
index 6977374088..39e90eb96a 100644
--- a/include/llvm/Analysis/CFGPrinter.h
+++ b/include/llvm/Analysis/CFGPrinter.h
@@ -46,6 +46,7 @@ struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits {
static std::string getCompleteNodeLabel(const BasicBlock *Node,
const Function *) {
+ enum { MaxColumns = 80 };
std::string Str;
raw_string_ostream OS(Str);
@@ -59,16 +60,32 @@ struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits {
if (OutStr[0] == '\n') OutStr.erase(OutStr.begin());
// Process string output to make it nicer...
- for (unsigned i = 0; i != OutStr.length(); ++i)
+ unsigned ColNum = 0;
+ unsigned LastSpace = 0;
+ for (unsigned i = 0; i != OutStr.length(); ++i) {
if (OutStr[i] == '\n') { // Left justify
OutStr[i] = '\\';
OutStr.insert(OutStr.begin()+i+1, 'l');
+ ColNum = 0;
+ LastSpace = 0;
} else if (OutStr[i] == ';') { // Delete comments!
unsigned Idx = OutStr.find('\n', i+1); // Find end of line
OutStr.erase(OutStr.begin()+i, OutStr.begin()+Idx);
--i;
+ } else if (ColNum == MaxColumns) { // Wrap lines.
+ if (LastSpace) {
+ OutStr.insert(LastSpace, "\\l...");
+ ColNum = i - LastSpace;
+ LastSpace = 0;
+ i += 3; // The loop will advance 'i' again.
+ }
+ // Else keep trying to find a space.
}
-
+ else
+ ++ColNum;
+ if (OutStr[i] == ' ')
+ LastSpace = i;
+ }
return OutStr;
}