[llvm-commits] [llvm] r106501 - /llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
Chris Lattner
sabre at nondot.org
Mon Jun 21 16:14:47 PDT 2010
Author: lattner
Date: Mon Jun 21 18:14:47 2010
New Revision: 106501
URL: http://llvm.org/viewvc/llvm-project?rev=106501&view=rev
Log:
eliminate a mutable global variable, use raw_ostream::indent instead of
rolling our own.
Modified:
llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=106501&r1=106500&r2=106501&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original)
+++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Mon Jun 21 18:14:47 2010
@@ -99,6 +99,7 @@
ValueSet DefinedValues;
ForwardRefMap ForwardRefs;
bool is_inline;
+ unsigned indent_level;
public:
static char ID;
@@ -120,6 +121,11 @@
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 @@
};
} // 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] != '_')
More information about the llvm-commits
mailing list