diff options
author | Chris Lattner <sabre@nondot.org> | 2010-06-21 23:14:47 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-06-21 23:14:47 +0000 |
commit | 1018c24c1357f76d350dc42957108362bd3b830c (patch) | |
tree | 86157c4c2d73e4b32b3ae6216fbe07febd867580 /lib/Target/CppBackend/CPPBackend.cpp | |
parent | 7e6d7451ae35ff148e8e264c6593780101c22d3b (diff) |
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
Diffstat (limited to 'lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r-- | lib/Target/CppBackend/CPPBackend.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index df1947e2e2..00f3cafb70 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -99,6 +99,7 @@ namespace { ValueSet DefinedValues; ForwardRefMap ForwardRefs; bool is_inline; + unsigned indent_level; public: static char ID; @@ -120,6 +121,11 @@ namespace { void error(const std::string& msg); + + formatted_raw_ostream& nl(formatted_raw_ostream &Out, int delta = 0); + inline void in() { indent_level++; } + inline void out() { if (indent_level >0) indent_level--; } + private: void printLinkageType(GlobalValue::LinkageTypes LT); void printVisibilityType(GlobalValue::VisibilityTypes VisTypes); @@ -155,20 +161,14 @@ namespace { }; } // end anonymous namespace. -// FIXME: Shouldn't be using globals for this. -static unsigned indent_level = 0; -static formatted_raw_ostream& nl(formatted_raw_ostream &Out, int delta = 0) { - Out << "\n"; +formatted_raw_ostream &CppWriter::nl(formatted_raw_ostream &Out, int delta) { + Out << '\n'; if (delta >= 0 || indent_level >= unsigned(-delta)) indent_level += delta; - for (unsigned i = 0; i < indent_level; ++i) - Out << " "; + Out.indent(indent_level); return Out; } -static inline void in() { indent_level++; } -static inline void out() { if (indent_level >0) indent_level--; } - static inline void sanitize(std::string &str) { for (size_t i = 0; i < str.length(); ++i) if (!isalnum(str[i]) && str[i] != '_') |