diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-05-30 00:10:16 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-05-30 00:10:16 +0000 |
commit | 22b61e937dcd8ba2e14764c367f975a392ec7da0 (patch) | |
tree | 53c080a7ecfc37edbd851e77e27de3b353317229 | |
parent | 4fe0c8e9c76b96e7aff21696a40dacc09d0237bc (diff) |
Add support for PrintingPolicy::SuppressTypeSpecifiers to type printing.
(I have a work-in-progress patch which uses this.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72598 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/Type.h | 4 | ||||
-rw-r--r-- | lib/AST/Type.cpp | 22 |
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(); } |