mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-08 19:46:39 +00:00
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
This commit is contained in:
parent
7e6d7451ae
commit
1018c24c13
@ -99,6 +99,7 @@ namespace {
|
|||||||
ValueSet DefinedValues;
|
ValueSet DefinedValues;
|
||||||
ForwardRefMap ForwardRefs;
|
ForwardRefMap ForwardRefs;
|
||||||
bool is_inline;
|
bool is_inline;
|
||||||
|
unsigned indent_level;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
@ -120,6 +121,11 @@ namespace {
|
|||||||
|
|
||||||
void error(const std::string& msg);
|
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:
|
private:
|
||||||
void printLinkageType(GlobalValue::LinkageTypes LT);
|
void printLinkageType(GlobalValue::LinkageTypes LT);
|
||||||
void printVisibilityType(GlobalValue::VisibilityTypes VisTypes);
|
void printVisibilityType(GlobalValue::VisibilityTypes VisTypes);
|
||||||
@ -155,20 +161,14 @@ namespace {
|
|||||||
};
|
};
|
||||||
} // end anonymous namespace.
|
} // end anonymous namespace.
|
||||||
|
|
||||||
// FIXME: Shouldn't be using globals for this.
|
formatted_raw_ostream &CppWriter::nl(formatted_raw_ostream &Out, int delta) {
|
||||||
static unsigned indent_level = 0;
|
Out << '\n';
|
||||||
static formatted_raw_ostream& nl(formatted_raw_ostream &Out, int delta = 0) {
|
|
||||||
Out << "\n";
|
|
||||||
if (delta >= 0 || indent_level >= unsigned(-delta))
|
if (delta >= 0 || indent_level >= unsigned(-delta))
|
||||||
indent_level += delta;
|
indent_level += delta;
|
||||||
for (unsigned i = 0; i < indent_level; ++i)
|
Out.indent(indent_level);
|
||||||
Out << " ";
|
|
||||||
return Out;
|
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) {
|
static inline void sanitize(std::string &str) {
|
||||||
for (size_t i = 0; i < str.length(); ++i)
|
for (size_t i = 0; i < str.length(); ++i)
|
||||||
if (!isalnum(str[i]) && str[i] != '_')
|
if (!isalnum(str[i]) && str[i] != '_')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user