aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Type.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r--lib/AST/Type.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 41536612fec8..4e061a9fbe62 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -185,6 +185,12 @@ bool Type::isStructureType() const {
return RT->getDecl()->isStruct();
return false;
}
+bool Type::isVoidPointerType() const {
+ if (const PointerType *PT = getAsPointerType())
+ return PT->getPointeeType()->isVoidType();
+ return false;
+}
+
bool Type::isUnionType() const {
if (const RecordType *RT = getAsRecordType())
return RT->getDecl()->isUnion();
@@ -938,11 +944,11 @@ bool Type::isSpecifierType() const {
}
}
-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 +1166,9 @@ TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
//===----------------------------------------------------------------------===//
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 +1180,8 @@ void QualType::dump() const {
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 +1200,8 @@ static void AppendTypeQualList(std::string &S, unsigned TypeQuals) {
std::string QualType::getAsString() const {
std::string S;
- getAsStringInternal(S, PrintingPolicy());
+ LangOptions LO;
+ getAsStringInternal(S, PrintingPolicy(LO));
return S;
}
@@ -1224,11 +1232,11 @@ QualType::getAsStringInternal(std::string &S,
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 +1478,7 @@ void FunctionProtoType::getAsStringInternal(std::string &S, const PrintingPolicy
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";
}