Key decisions about 'bool' vs '_Bool' to be based on a new flag in langoptions.
This is simple enough, but then I thought it would be nice to make PrintingPolicy
get a LangOptions so that various things can key off "bool" and "C++" independently.
This spiraled out of control. There are many fixme's, but I think things are slightly
better than they were before.
One thing that can be improved: CFG should probably have an ASTContext pointer in it,
which would simplify its clients.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74493 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 4153661..eaa7d3b 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -938,11 +938,11 @@
}
}
-const char *BuiltinType::getName(bool CPlusPlus) const {
+const char *BuiltinType::getName(const LangOptions &LO) const {
switch (getKind()) {
default: assert(0 && "Unknown builtin type!");
case Void: return "void";
- case Bool: return CPlusPlus? "bool" : "_Bool";
+ case Bool: return LO.Bool ? "bool" : "_Bool";
case Char_S: return "char";
case Char_U: return "char";
case SChar: return "signed char";
@@ -1160,9 +1160,9 @@
//===----------------------------------------------------------------------===//
void QualType::dump(const char *msg) const {
- PrintingPolicy Policy;
std::string R = "identifier";
- getAsStringInternal(R, Policy);
+ LangOptions LO;
+ getAsStringInternal(R, PrintingPolicy(LO));
if (msg)
fprintf(stderr, "%s: %s\n", msg, R.c_str());
else
@@ -1174,7 +1174,8 @@
void Type::dump() const {
std::string S = "identifier";
- getAsStringInternal(S, PrintingPolicy());
+ LangOptions LO;
+ getAsStringInternal(S, PrintingPolicy(LO));
fprintf(stderr, "%s\n", S.c_str());
}
@@ -1193,7 +1194,8 @@
std::string QualType::getAsString() const {
std::string S;
- getAsStringInternal(S, PrintingPolicy());
+ LangOptions LO;
+ getAsStringInternal(S, PrintingPolicy(LO));
return S;
}
@@ -1224,11 +1226,11 @@
void BuiltinType::getAsStringInternal(std::string &S,
const PrintingPolicy &Policy) const {
if (S.empty()) {
- S = getName(Policy.CPlusPlus);
+ S = getName(Policy.LangOpts);
} else {
// Prefix the basic type, e.g. 'int X'.
S = ' ' + S;
- S = getName(Policy.CPlusPlus) + S;
+ S = getName(Policy.LangOpts) + S;
}
}
@@ -1470,7 +1472,7 @@
if (getNumArgs())
S += ", ";
S += "...";
- } else if (getNumArgs() == 0 && !Policy.CPlusPlus) {
+ } else if (getNumArgs() == 0 && !Policy.LangOpts.CPlusPlus) {
// Do not emit int() if we have a proto, emit 'int(void)'.
S += "void";
}