llvm.org GIT mirror llvm / 1018c24
eliminate a mutable global variable, use raw_ostream::indent instead of rolling our own. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106501 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
1 changed file(s) with 9 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
9898 ValueSet DefinedValues;
9999 ForwardRefMap ForwardRefs;
100100 bool is_inline;
101 unsigned indent_level;
101102
102103 public:
103104 static char ID;
119120
120121 void error(const std::string& msg);
121122
123
124 formatted_raw_ostream& nl(formatted_raw_ostream &Out, int delta = 0);
125 inline void in() { indent_level++; }
126 inline void out() { if (indent_level >0) indent_level--; }
127
122128 private:
123129 void printLinkageType(GlobalValue::LinkageTypes LT);
124130 void printVisibilityType(GlobalValue::VisibilityTypes VisTypes);
154160 };
155161 } // end anonymous namespace.
156162
157 // FIXME: Shouldn't be using globals for this.
158 static unsigned indent_level = 0;
159 static formatted_raw_ostream& nl(formatted_raw_ostream &Out, int delta = 0) {
160 Out << "\n";
163 formatted_raw_ostream &CppWriter::nl(formatted_raw_ostream &Out, int delta) {
164 Out << '\n';
161165 if (delta >= 0 || indent_level >= unsigned(-delta))
162166 indent_level += delta;
163 for (unsigned i = 0; i < indent_level; ++i)
164 Out << " ";
167 Out.indent(indent_level);
165168 return Out;
166169 }
167
168 static inline void in() { indent_level++; }
169 static inline void out() { if (indent_level >0) indent_level--; }
170170
171171 static inline void sanitize(std::string &str) {
172172 for (size_t i = 0; i < str.length(); ++i)