[cfe-commits] r84907 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/Type.h include/clang/AST/TypeLoc.h include/clang/AST/TypeNodes.def include/clang/Frontend/PCHBitCodes.h lib/AST/ASTContext.cpp lib/AST/Type.cpp lib/CodeGen/Mangle.cpp lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp lib/Index/ResolveLocation.cpp lib/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaType.cpp lib/Sema/TreeTransform.h test/SemaCXX/overloaded-operator.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Fri Oct 23 02:01:46 PDT 2009


John McCall wrote:
> Author: rjmccall
> Date: Thu Oct 22 17:37:11 2009
> New Revision: 84907
>
> URL: http://llvm.org/viewvc/llvm-project?rev=84907&view=rev
> Log:
> When building types from declarators, instead of building two types (one for
> the DeclaratorInfo, one for semantic analysis), just build a single type whose
> canonical type will reflect the semantic analysis (assuming the type is
> well-formed, of course).
>
> To make that work, make a few changes to the type system:
> * allow the nominal pointee type of a reference type to be a (possibly sugared)
>   reference type.  Also, preserve the original spelling of the reference type.
>   Both of these can be ignored on canonical reference types.
>   


> -  QualType getPointeeType() const { return PointeeType; }
> +  bool isSpelledAsLValue() const { return SpelledAsLValue; }
> +
> +  QualType getPointeeTypeAsWritten() const { return PointeeType; }
> +  QualType getPointeeType() const {
> +    // FIXME: this might strip inner qualifiers; okay?
> +    const ReferenceType *T = this;
> +    while (T->InnerRef)
> +      T = T->PointeeType->getAs<ReferenceType>();
> +    return T->PointeeType;
> +  }
>   
Yes, I believe this is OK. Technically, there can't be any other 
qualifiers, since references cannot be qualified. If we accept them, 
they're still ignored.

typedef const int &IRef; // This const must be preserved
typedef const IRef &IRefRef; // This const will get lost, but is 
meaningless anyway.

Hmm ... it might not be OK for the restrict qualifier.

Sebastian



More information about the cfe-commits mailing list