aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/Type.h4
-rw-r--r--lib/AST/Type.cpp22
2 files changed, 24 insertions, 2 deletions
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index beca7088be..15c6b6654f 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -484,6 +484,10 @@ public:
/// incomplete types.
bool isConstantSizeType() const;
+ /// isSpecifierType - Returns true if this type can be represented by some
+ /// set of type specifiers.
+ bool isSpecifierType() const;
+
QualType getCanonicalTypeInternal() const { return CanonicalType; }
void dump() const;
virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const = 0;
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 64433cd89b..e63e12b3d6 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -896,6 +896,19 @@ bool Type::isNullPtrType() const {
return false;
}
+bool Type::isSpecifierType() const {
+ // Note that this intentionally does not use the canonical type.
+ switch (getTypeClass()) {
+ case Builtin:
+ case Record:
+ case Enum:
+ case Typedef:
+ return true;
+ default:
+ return false;
+ }
+}
+
const char *BuiltinType::getName(bool CPlusPlus) const {
switch (getKind()) {
default: assert(0 && "Unknown builtin type!");
@@ -1144,7 +1157,10 @@ QualType::getAsStringInternal(std::string &S,
S += "NULL TYPE";
return;
}
-
+
+ if (Policy.SuppressTypeSpecifiers && getTypePtr()->isSpecifierType())
+ return;
+
// Print qualifiers as appropriate.
if (unsigned Tq = getCVRQualifiers()) {
std::string TQS;
@@ -1371,9 +1387,11 @@ void FunctionProtoType::getAsStringInternal(std::string &S, const PrintingPolicy
S += "(";
std::string Tmp;
+ PrintingPolicy ParamPolicy(Policy);
+ ParamPolicy.SuppressTypeSpecifiers = false;
for (unsigned i = 0, e = getNumArgs(); i != e; ++i) {
if (i) S += ", ";
- getArgType(i).getAsStringInternal(Tmp, Policy);
+ getArgType(i).getAsStringInternal(Tmp, ParamPolicy);
S += Tmp;
Tmp.clear();
}