[cfe-commits] r72598 - in /cfe/trunk: include/clang/AST/Type.h lib/AST/Type.cpp

Douglas Gregor dgregor at apple.com
Fri May 29 17:14:49 PDT 2009


On May 29, 2009, at 5:10 PM, Eli Friedman wrote:

> Author: efriedma
> Date: Fri May 29 19:10:16 2009
> New Revision: 72598
>
> URL: http://llvm.org/viewvc/llvm-project?rev=72598&view=rev
> Log:
> Add support for PrintingPolicy::SuppressTypeSpecifiers to type  
> printing.
> (I have a work-in-progress patch which uses this.)

Making DeclGroups print well? ;)

(Comment below)

>
> Modified:
>    cfe/trunk/include/clang/AST/Type.h
>    cfe/trunk/lib/AST/Type.cpp
>
> Modified: cfe/trunk/include/clang/AST/Type.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=72598&r1=72597&r2=72598&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/include/clang/AST/Type.h (original)
> +++ cfe/trunk/include/clang/AST/Type.h Fri May 29 19:10:16 2009
> @@ -484,6 +484,10 @@
>   /// 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;
>
> Modified: cfe/trunk/lib/AST/Type.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=72598&r1=72597&r2=72598&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/AST/Type.cpp (original)
> +++ cfe/trunk/lib/AST/Type.cpp Fri May 29 19:10:16 2009
> @@ -896,6 +896,19 @@
>   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;
> +  }
> +}

Wouldn't it be easier to enumerate the non-specifier types? Pointers,  
lvalue references, rvalue references, array types, and then the result  
types of function types.

   - Doug




More information about the cfe-commits mailing list