From owner-svn-src-projects@FreeBSD.ORG Thu Oct 15 13:34:46 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E49251065672; Thu, 15 Oct 2009 13:34:45 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CFA7B8FC13; Thu, 15 Oct 2009 13:34:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9FDYjlJ074881; Thu, 15 Oct 2009 13:34:45 GMT (envelope-from rdivacky@svn.freebsd.org) Received: (from rdivacky@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9FDYjc6074873; Thu, 15 Oct 2009 13:34:45 GMT (envelope-from rdivacky@svn.freebsd.org) Message-Id: <200910151334.n9FDYjc6074873@svn.freebsd.org> From: Roman Divacky Date: Thu, 15 Oct 2009 13:34:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198131 - in projects/clangbsd/contrib/llvm/tools/clang: . include/clang/AST include/clang/Basic lib/AST lib/Analysis lib/CodeGen lib/Frontend lib/Sema test/Analysis test/CodeGen test/C... X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Oct 2009 13:34:46 -0000 Author: rdivacky Date: Thu Oct 15 13:34:45 2009 New Revision: 198131 URL: http://svn.freebsd.org/changeset/base/198131 Log: Merge clang r84175 from vendor. Modified: projects/clangbsd/contrib/llvm/tools/clang/ (props changed) projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/ASTContext.h projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/Decl.h projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/TypeLoc.h projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/TypeLocNodes.def projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/TypeLocVisitor.h projects/clangbsd/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td projects/clangbsd/contrib/llvm/tools/clang/lib/AST/ASTContext.cpp projects/clangbsd/contrib/llvm/tools/clang/lib/AST/Decl.cpp projects/clangbsd/contrib/llvm/tools/clang/lib/AST/TypeLoc.cpp projects/clangbsd/contrib/llvm/tools/clang/lib/Analysis/CFRefCount.cpp projects/clangbsd/contrib/llvm/tools/clang/lib/Analysis/RegionStore.cpp projects/clangbsd/contrib/llvm/tools/clang/lib/CodeGen/CGExpr.cpp projects/clangbsd/contrib/llvm/tools/clang/lib/CodeGen/CGVtable.cpp projects/clangbsd/contrib/llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp projects/clangbsd/contrib/llvm/tools/clang/lib/Frontend/PCHReaderDecl.cpp projects/clangbsd/contrib/llvm/tools/clang/lib/Frontend/PCHWriterDecl.cpp projects/clangbsd/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp projects/clangbsd/contrib/llvm/tools/clang/lib/Sema/SemaExpr.cpp projects/clangbsd/contrib/llvm/tools/clang/lib/Sema/SemaTemplate.cpp projects/clangbsd/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp projects/clangbsd/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp projects/clangbsd/contrib/llvm/tools/clang/lib/Sema/SemaType.cpp projects/clangbsd/contrib/llvm/tools/clang/test/Analysis/NSString.m projects/clangbsd/contrib/llvm/tools/clang/test/CodeGen/builtins-powi.c projects/clangbsd/contrib/llvm/tools/clang/test/CodeGen/builtins.c projects/clangbsd/contrib/llvm/tools/clang/test/CodeGen/const-init.c projects/clangbsd/contrib/llvm/tools/clang/test/CodeGen/mandel.c projects/clangbsd/contrib/llvm/tools/clang/test/CodeGenCXX/references.cpp projects/clangbsd/contrib/llvm/tools/clang/test/CodeGenCXX/virt.cpp projects/clangbsd/contrib/llvm/tools/clang/test/SemaCXX/incomplete-call.cpp projects/clangbsd/contrib/llvm/tools/clang/test/SemaTemplate/explicit-instantiation.cpp projects/clangbsd/contrib/llvm/tools/clang/test/SemaTemplate/temp_explicit.cpp projects/clangbsd/contrib/llvm/tools/clang/www/comparison.html Modified: projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/ASTContext.h ============================================================================== --- projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/ASTContext.h Thu Oct 15 13:29:27 2009 (r198130) +++ projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/ASTContext.h Thu Oct 15 13:34:45 2009 (r198131) @@ -174,7 +174,7 @@ class ASTContext { /// This mapping will contain an entry that maps from the VarDecl for /// X::value to the corresponding VarDecl for X::value (within the /// class template X) and will be marked TSK_ImplicitInstantiation. - llvm::DenseMap + llvm::DenseMap InstantiatedFromStaticDataMember; /// \brief Keeps track of the UnresolvedUsingDecls from which UsingDecls @@ -267,7 +267,8 @@ public: /// \brief If this variable is an instantiated static data member of a /// class template specialization, returns the templated static data member /// from which it was instantiated. - MemberSpecializationInfo *getInstantiatedFromStaticDataMember(VarDecl *Var); + MemberSpecializationInfo *getInstantiatedFromStaticDataMember( + const VarDecl *Var); /// \brief Note that the static data member \p Inst is an instantiation of /// the static data member template \p Tmpl of a class template. Modified: projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/Decl.h ============================================================================== --- projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/Decl.h Thu Oct 15 13:29:27 2009 (r198130) +++ projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/Decl.h Thu Oct 15 13:34:45 2009 (r198131) @@ -584,19 +584,23 @@ public: return getDeclContext()->isRecord(); } + /// \brief Determine whether this is or was instantiated from an out-of-line + /// definition of a static data member. + bool isOutOfLine() const; + /// \brief If this variable is an instantiated static data member of a /// class template specialization, returns the templated static data member /// from which it was instantiated. - VarDecl *getInstantiatedFromStaticDataMember(); + VarDecl *getInstantiatedFromStaticDataMember() const; /// \brief If this variable is a static data member, determine what kind of /// template specialization or instantiation this is. - TemplateSpecializationKind getTemplateSpecializationKind(); + TemplateSpecializationKind getTemplateSpecializationKind() const; /// \brief If this variable is an instantiation of a static data member of a /// class template specialization, retrieves the member specialization /// information. - MemberSpecializationInfo *getMemberSpecializationInfo(); + MemberSpecializationInfo *getMemberSpecializationInfo() const; /// \brief For a static data member that was instantiated from a static /// data member of a class template, set the template specialiation kind. Modified: projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/TypeLoc.h ============================================================================== --- projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/TypeLoc.h Thu Oct 15 13:29:27 2009 (r198130) +++ projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/TypeLoc.h Thu Oct 15 13:34:45 2009 (r198131) @@ -20,6 +20,7 @@ namespace clang { class ParmVarDecl; class TypeSpecLoc; class DeclaratorInfo; + class UnqualTypeLoc; /// \brief Base wrapper for a particular "section" of type source info. /// @@ -27,22 +28,31 @@ namespace clang { /// get at the actual information. class TypeLoc { protected: - QualType Ty; + // The correctness of this relies on the property that, for Type *Ty, + // QualType(Ty, 0).getAsOpaquePtr() == (void*) Ty + void *Ty; void *Data; public: - TypeLoc() : Data(0) { } - TypeLoc(QualType ty, void *opaqueData) : Ty(ty), Data(opaqueData) { } + TypeLoc() : Ty(0), Data(0) { } + TypeLoc(QualType ty, void *opaqueData) + : Ty(ty.getAsOpaquePtr()), Data(opaqueData) { } + TypeLoc(Type *ty, void *opaqueData) + : Ty(ty), Data(opaqueData) { } - bool isNull() const { return Ty.isNull(); } - operator bool() const { return !isNull(); } + bool isNull() const { return !Ty; } + operator bool() const { return Ty; } /// \brief Returns the size of type source info data block for the given type. static unsigned getFullDataSizeForType(QualType Ty); /// \brief Get the type for which this source info wrapper provides /// information. - QualType getSourceType() const { return Ty; } + QualType getSourceType() const { return QualType::getFromOpaquePtr(Ty); } + + Type *getSourceTypePtr() const { + return QualType::getFromOpaquePtr(Ty).getTypePtr(); + } /// \brief Get the pointer where source information is stored. void *getOpaqueData() const { return Data; } @@ -57,12 +67,17 @@ public: SourceRange getTypeSpecRange() const; /// \brief Returns the size of the type source info data block. - unsigned getFullDataSize() const; + unsigned getFullDataSize() const { + return getFullDataSizeForType(getSourceType()); + } /// \brief Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the /// TypeLoc is a PointerLoc and next TypeLoc is for "int". TypeLoc getNextTypeLoc() const; + /// \brief Skips past any qualifiers, if this is qualified. + UnqualTypeLoc getUnqualifiedLoc() const; + friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS) { return LHS.Ty == RHS.Ty && LHS.Data == RHS.Data; } @@ -74,144 +89,300 @@ public: static bool classof(const TypeLoc *TL) { return true; } }; +/// \brief Wrapper of type source information for a type with +/// no direct quqlaifiers. +class UnqualTypeLoc : public TypeLoc { +public: + UnqualTypeLoc() {} + UnqualTypeLoc(Type *Ty, void *Data) : TypeLoc(Ty, Data) {} + + Type *getSourceTypePtr() const { + return reinterpret_cast(Ty); + } + + static bool classof(const TypeLoc *TL) { + return !TL->getSourceType().hasQualifiers(); + } + static bool classof(const UnqualTypeLoc *TL) { return true; } +}; + +/// \brief Wrapper of type source information for a type with +/// non-trivial direct qualifiers. +/// +/// Currently, we intentionally do not provide source location for +/// type qualifiers. +class QualifiedLoc : public TypeLoc { +public: + SourceRange getSourceRange() const { + return SourceRange(); + } + + UnqualTypeLoc getUnqualifiedLoc() const { + return UnqualTypeLoc(getSourceTypePtr(), Data); + } + + /// \brief Returns the size of the type source info data block that is + /// specific to this type. + unsigned getLocalDataSize() const { + // In fact, we don't currently preserve any location information + // for qualifiers. + return 0; + } + + /// \brief Returns the size of the type source info data block. + unsigned getFullDataSize() const { + return getLocalDataSize() + + getFullDataSizeForType(getSourceType().getUnqualifiedType()); + } + + static bool classof(const TypeLoc *TL) { + return TL->getSourceType().hasQualifiers(); + } + static bool classof(const QualifiedLoc *TL) { return true; } +}; + +inline UnqualTypeLoc TypeLoc::getUnqualifiedLoc() const { + if (isa(this)) + return cast(this)->getUnqualifiedLoc(); + return cast(*this); +} + /// \brief Base wrapper of type source info data for type-spec types. -class TypeSpecLoc : public TypeLoc { +class TypeSpecLoc : public UnqualTypeLoc { public: - static bool classof(const TypeLoc *TL); + static bool classof(const TypeLoc *TL) { + return (UnqualTypeLoc::classof(TL) && + classof(static_cast(TL))); + } + static bool classof(const UnqualTypeLoc *TL); static bool classof(const TypeSpecLoc *TL) { return true; } }; +inline SourceRange TypeLoc::getTypeSpecRange() const { + return getTypeSpecLoc().getSourceRange(); +} + /// \brief Base wrapper of type source info data for types part of a declarator, /// excluding type-spec types. -class DeclaratorLoc : public TypeLoc { +class DeclaratorLoc : public UnqualTypeLoc { public: /// \brief Find the TypeSpecLoc that is part of this DeclaratorLoc. TypeSpecLoc getTypeSpecLoc() const; - static bool classof(const TypeLoc *TL); + static bool classof(const TypeLoc *TL) { + return (UnqualTypeLoc::classof(TL) && + classof(static_cast(TL))); + } + static bool classof(const UnqualTypeLoc *TL); static bool classof(const DeclaratorLoc *TL) { return true; } }; + +/// A metaprogramming base class for TypeLoc classes which correspond +/// to a particular Type subclass. It is accepted for a single +/// TypeLoc class to correspond to multiple Type classes. +/// +/// \param Base a class from which to derive +/// \param Derived the class deriving from this one +/// \param TypeClass the concrete Type subclass associated with this +/// location type +/// \param LocalData the structure type of local location data for +/// this type +/// +/// sizeof(LocalData) needs to be a multiple of sizeof(void*) or +/// else the world will end. +/// +/// TypeLocs with non-constant amounts of local data should override +/// getExtraLocalDataSize(); getExtraLocalData() will then point to +/// this extra memory. +/// +/// TypeLocs with an inner type should override hasInnerType() and +/// getInnerType(); getInnerTypeLoc() will then point to this inner +/// type's location data. +template +class ConcreteTypeLoc : public Base { + + const Derived *asDerived() const { + return static_cast(this); + } + +public: + unsigned getLocalDataSize() const { + return sizeof(LocalData) + asDerived()->getExtraLocalDataSize(); + } + // Give a default implementation that's useful for leaf types. + unsigned getFullDataSize() const { + return asDerived()->getLocalDataSize() + getInnerTypeSize(); + } + + static bool classof(const TypeLoc *TL) { + return Derived::classofType(TL->getSourceTypePtr()); + } + static bool classof(const UnqualTypeLoc *TL) { + return Derived::classofType(TL->getSourceTypePtr()); + } + static bool classof(const Derived *TL) { + return true; + } + + static bool classofType(const Type *Ty) { + return TypeClass::classof(Ty); + } + +protected: + TypeClass *getTypePtr() const { + return cast(Base::getSourceTypePtr()); + } + + unsigned getExtraLocalDataSize() const { + return 0; + } + + LocalData *getLocalData() const { + return static_cast(Base::Data); + } + + /// Gets a pointer past the Info structure; useful for classes with + /// local data that can't be captured in the Info (e.g. because it's + /// of variable size). + void *getExtraLocalData() const { + return getLocalData() + 1; + } + + void *getNonLocalData() const { + return static_cast(Base::Data) + asDerived()->getLocalDataSize(); + } + + bool hasInnerType() const { + return false; + } + + TypeLoc getInnerTypeLoc() const { + assert(asDerived()->hasInnerType()); + return TypeLoc(asDerived()->getInnerType(), getNonLocalData()); + } + +private: + unsigned getInnerTypeSize() const { + if (asDerived()->hasInnerType()) + return getInnerTypeLoc().getFullDataSize(); + return 0; + } + + // Required here because my metaprogramming is too weak to avoid it. + QualType getInnerType() const { + assert(0 && "getInnerType() not overridden"); + return QualType(); + } +}; + + +struct DefaultTypeSpecLocInfo { + SourceLocation StartLoc; +}; + /// \brief The default wrapper for type-spec types that are not handled by /// another specific wrapper. -class DefaultTypeSpecLoc : public TypeSpecLoc { - struct Info { - SourceLocation StartLoc; - }; - +class DefaultTypeSpecLoc : public ConcreteTypeLoc { public: SourceLocation getStartLoc() const { - return static_cast(Data)->StartLoc; + return getLocalData()->StartLoc; } void setStartLoc(SourceLocation Loc) { - static_cast(Data)->StartLoc = Loc; + getLocalData()->StartLoc = Loc; } SourceRange getSourceRange() const { return SourceRange(getStartLoc(), getStartLoc()); } - /// \brief Returns the size of the type source info data block that is - /// specific to this type. - unsigned getLocalDataSize() const { return sizeof(Info); } + static bool classofType(const Type *T); +}; - /// \brief Returns the size of the type source info data block. - unsigned getFullDataSize() const { return getLocalDataSize(); } - static bool classof(const TypeLoc *TL); - static bool classof(const DefaultTypeSpecLoc *TL) { return true; } +struct TypedefLocInfo { + SourceLocation NameLoc; }; /// \brief Wrapper for source info for typedefs. -class TypedefLoc : public TypeSpecLoc { - struct Info { - SourceLocation NameLoc; - }; - +class TypedefLoc : public ConcreteTypeLoc { public: SourceLocation getNameLoc() const { - return static_cast(Data)->NameLoc; + return getLocalData()->NameLoc; } void setNameLoc(SourceLocation Loc) { - static_cast(Data)->NameLoc = Loc; + getLocalData()->NameLoc = Loc; } SourceRange getSourceRange() const { return SourceRange(getNameLoc(), getNameLoc()); } TypedefDecl *getTypedefDecl() const { - return cast(Ty)->getDecl(); + return getTypePtr()->getDecl(); } +}; - /// \brief Returns the size of the type source info data block that is - /// specific to this type. - unsigned getLocalDataSize() const { return sizeof(Info); } - - /// \brief Returns the size of the type source info data block. - unsigned getFullDataSize() const { return getLocalDataSize(); } - static bool classof(const TypeLoc *TL); - static bool classof(const TypedefLoc *TL) { return true; } +struct ObjCInterfaceLocInfo { + SourceLocation NameLoc; }; /// \brief Wrapper for source info for ObjC interfaces. -class ObjCInterfaceLoc : public TypeSpecLoc { - struct Info { - SourceLocation NameLoc; - }; - +class ObjCInterfaceLoc : public ConcreteTypeLoc { public: SourceLocation getNameLoc() const { - return static_cast(Data)->NameLoc; + return getLocalData()->NameLoc; } void setNameLoc(SourceLocation Loc) { - static_cast(Data)->NameLoc = Loc; + getLocalData()->NameLoc = Loc; } SourceRange getSourceRange() const { return SourceRange(getNameLoc(), getNameLoc()); } ObjCInterfaceDecl *getIFaceDecl() const { - return cast(Ty)->getDecl(); + return getTypePtr()->getDecl(); } +}; - /// \brief Returns the size of the type source info data block that is - /// specific to this type. - unsigned getLocalDataSize() const { return sizeof(Info); } - - /// \brief Returns the size of the type source info data block. - unsigned getFullDataSize() const { return getLocalDataSize(); } - static bool classof(const TypeLoc *TL); - static bool classof(const TypedefLoc *TL) { return true; } +struct ObjCProtocolListLocInfo { + SourceLocation LAngleLoc, RAngleLoc; }; /// \brief Wrapper for source info for ObjC protocol lists. -class ObjCProtocolListLoc : public TypeSpecLoc { - struct Info { - SourceLocation LAngleLoc, RAngleLoc; - }; +class ObjCProtocolListLoc : public ConcreteTypeLoc { // SourceLocations are stored after Info, one for each Protocol. SourceLocation *getProtocolLocArray() const { - return reinterpret_cast(static_cast(Data) + 1); + return (SourceLocation*) getExtraLocalData(); } public: SourceLocation getLAngleLoc() const { - return static_cast(Data)->LAngleLoc; + return getLocalData()->LAngleLoc; } void setLAngleLoc(SourceLocation Loc) { - static_cast(Data)->LAngleLoc = Loc; + getLocalData()->LAngleLoc = Loc; } SourceLocation getRAngleLoc() const { - return static_cast(Data)->RAngleLoc; + return getLocalData()->RAngleLoc; } void setRAngleLoc(SourceLocation Loc) { - static_cast(Data)->RAngleLoc = Loc; + getLocalData()->RAngleLoc = Loc; } unsigned getNumProtocols() const { - return cast(Ty)->getNumProtocols(); + return getTypePtr()->getNumProtocols(); } SourceLocation getProtocolLoc(unsigned i) const { @@ -225,12 +396,11 @@ public: ObjCProtocolDecl *getProtocol(unsigned i) const { assert(i < getNumProtocols() && "Index is out of bounds!"); - return *(cast(Ty)->qual_begin() + i); + return *(getTypePtr()->qual_begin() + i); } TypeLoc getBaseTypeLoc() const { - void *Next = static_cast(Data) + getLocalDataSize(); - return TypeLoc(cast(Ty)->getBaseType(), Next); + return getInnerTypeLoc(); } SourceRange getSourceRange() const { @@ -239,36 +409,34 @@ public: /// \brief Returns the size of the type source info data block that is /// specific to this type. - unsigned getLocalDataSize() const { - return sizeof(Info) + getNumProtocols() * sizeof(SourceLocation); + unsigned getExtraLocalDataSize() const { + return getNumProtocols() * sizeof(SourceLocation); } - /// \brief Returns the size of the type source info data block. - unsigned getFullDataSize() const { - return getLocalDataSize() + getBaseTypeLoc().getFullDataSize(); - } + bool hasInnerType() const { return true; } + QualType getInnerType() const { return getTypePtr()->getBaseType(); } +}; - static bool classof(const TypeLoc *TL); - static bool classof(const ObjCProtocolListLoc *TL) { return true; } + +struct PointerLocInfo { + SourceLocation StarLoc; }; /// \brief Wrapper for source info for pointers. -class PointerLoc : public DeclaratorLoc { - struct Info { - SourceLocation StarLoc; - }; - +class PointerLoc : public ConcreteTypeLoc { public: SourceLocation getStarLoc() const { - return static_cast(Data)->StarLoc; + return getLocalData()->StarLoc; } void setStarLoc(SourceLocation Loc) { - static_cast(Data)->StarLoc = Loc; + getLocalData()->StarLoc = Loc; } TypeLoc getPointeeLoc() const { - void *Next = static_cast(Data) + getLocalDataSize(); - return TypeLoc(cast(Ty)->getPointeeType(), Next); + return getInnerTypeLoc(); } /// \brief Find the TypeSpecLoc that is part of this PointerLoc. @@ -280,36 +448,30 @@ public: return SourceRange(getStarLoc(), getStarLoc()); } - /// \brief Returns the size of the type source info data block that is - /// specific to this type. - unsigned getLocalDataSize() const { return sizeof(Info); } + bool hasInnerType() const { return true; } + QualType getInnerType() const { return getTypePtr()->getPointeeType(); } +}; - /// \brief Returns the size of the type source info data block. - unsigned getFullDataSize() const { - return getLocalDataSize() + getPointeeLoc().getFullDataSize(); - } - static bool classof(const TypeLoc *TL); - static bool classof(const PointerLoc *TL) { return true; } +struct BlockPointerLocInfo { + SourceLocation CaretLoc; }; /// \brief Wrapper for source info for block pointers. -class BlockPointerLoc : public DeclaratorLoc { - struct Info { - SourceLocation CaretLoc; - }; - +class BlockPointerLoc : public ConcreteTypeLoc { public: SourceLocation getCaretLoc() const { - return static_cast(Data)->CaretLoc; + return getLocalData()->CaretLoc; } void setCaretLoc(SourceLocation Loc) { - static_cast(Data)->CaretLoc = Loc; + getLocalData()->CaretLoc = Loc; } TypeLoc getPointeeLoc() const { - void *Next = static_cast(Data) + getLocalDataSize(); - return TypeLoc(cast(Ty)->getPointeeType(), Next); + return getInnerTypeLoc(); } /// \brief Find the TypeSpecLoc that is part of this BlockPointerLoc. @@ -321,36 +483,30 @@ public: return SourceRange(getCaretLoc(), getCaretLoc()); } - /// \brief Returns the size of the type source info data block that is - /// specific to this type. - unsigned getLocalDataSize() const { return sizeof(Info); } + bool hasInnerType() const { return true; } + QualType getInnerType() const { return getTypePtr()->getPointeeType(); } +}; - /// \brief Returns the size of the type source info data block. - unsigned getFullDataSize() const { - return getLocalDataSize() + getPointeeLoc().getFullDataSize(); - } - static bool classof(const TypeLoc *TL); - static bool classof(const BlockPointerLoc *TL) { return true; } +struct MemberPointerLocInfo { + SourceLocation StarLoc; }; /// \brief Wrapper for source info for member pointers. -class MemberPointerLoc : public DeclaratorLoc { - struct Info { - SourceLocation StarLoc; - }; - +class MemberPointerLoc : public ConcreteTypeLoc { public: SourceLocation getStarLoc() const { - return static_cast(Data)->StarLoc; + return getLocalData()->StarLoc; } void setStarLoc(SourceLocation Loc) { - static_cast(Data)->StarLoc = Loc; + getLocalData()->StarLoc = Loc; } TypeLoc getPointeeLoc() const { - void *Next = static_cast(Data) + getLocalDataSize(); - return TypeLoc(cast(Ty)->getPointeeType(), Next); + return getInnerTypeLoc(); } /// \brief Find the TypeSpecLoc that is part of this MemberPointerLoc. @@ -362,36 +518,30 @@ public: return SourceRange(getStarLoc(), getStarLoc()); } - /// \brief Returns the size of the type source info data block that is - /// specific to this type. - unsigned getLocalDataSize() const { return sizeof(Info); } + bool hasInnerType() const { return true; } + QualType getInnerType() const { return getTypePtr()->getPointeeType(); } +}; - /// \brief Returns the size of the type source info data block. - unsigned getFullDataSize() const { - return getLocalDataSize() + getPointeeLoc().getFullDataSize(); - } - static bool classof(const TypeLoc *TL); - static bool classof(const MemberPointerLoc *TL) { return true; } +struct ReferenceLocInfo { + SourceLocation AmpLoc; }; /// \brief Wrapper for source info for references. -class ReferenceLoc : public DeclaratorLoc { - struct Info { - SourceLocation AmpLoc; - }; - +class ReferenceLoc : public ConcreteTypeLoc { public: SourceLocation getAmpLoc() const { - return static_cast(Data)->AmpLoc; + return getLocalData()->AmpLoc; } void setAmpLoc(SourceLocation Loc) { - static_cast(Data)->AmpLoc = Loc; + getLocalData()->AmpLoc = Loc; } TypeLoc getPointeeLoc() const { - void *Next = static_cast(Data) + getLocalDataSize(); - return TypeLoc(cast(Ty)->getPointeeType(), Next); + return TypeLoc(getTypePtr()->getPointeeType(), getNonLocalData()); } /// \brief Find the TypeSpecLoc that is part of this ReferenceLoc. @@ -403,48 +553,44 @@ public: return SourceRange(getAmpLoc(), getAmpLoc()); } - /// \brief Returns the size of the type source info data block that is - /// specific to this type. - unsigned getLocalDataSize() const { return sizeof(Info); } + bool hasInnerType() const { return true; } + QualType getInnerType() const { return getTypePtr()->getPointeeType(); } +}; - /// \brief Returns the size of the type source info data block. - unsigned getFullDataSize() const { - return getLocalDataSize() + getPointeeLoc().getFullDataSize(); - } - static bool classof(const TypeLoc *TL); - static bool classof(const ReferenceLoc *TL) { return true; } +struct FunctionLocInfo { + SourceLocation LParenLoc, RParenLoc; }; /// \brief Wrapper for source info for functions. -class FunctionLoc : public DeclaratorLoc { - struct Info { - SourceLocation LParenLoc, RParenLoc; - }; +class FunctionLoc : public ConcreteTypeLoc { // ParmVarDecls* are stored after Info, one for each argument. ParmVarDecl **getParmArray() const { - return reinterpret_cast(static_cast(Data) + 1); + return (ParmVarDecl**) getExtraLocalData(); } public: SourceLocation getLParenLoc() const { - return static_cast(Data)->LParenLoc; + return getLocalData()->LParenLoc; } void setLParenLoc(SourceLocation Loc) { - static_cast(Data)->LParenLoc = Loc; + getLocalData()->LParenLoc = Loc; } SourceLocation getRParenLoc() const { - return static_cast(Data)->RParenLoc; + return getLocalData()->RParenLoc; } void setRParenLoc(SourceLocation Loc) { - static_cast(Data)->RParenLoc = Loc; + getLocalData()->RParenLoc = Loc; } unsigned getNumArgs() const { - if (isa(Ty)) + if (isa(getTypePtr())) return 0; - return cast(Ty)->getNumArgs(); + return cast(getTypePtr())->getNumArgs(); } ParmVarDecl *getArg(unsigned i) const { return getParmArray()[i]; } void setArg(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; } @@ -452,8 +598,7 @@ public: TypeLoc getArgLoc(unsigned i) const; TypeLoc getResultLoc() const { - void *Next = static_cast(Data) + getLocalDataSize(); - return TypeLoc(cast(Ty)->getResultType(), Next); + return getInnerTypeLoc(); } /// \brief Find the TypeSpecLoc that is part of this FunctionLoc. @@ -466,50 +611,49 @@ public: /// \brief Returns the size of the type source info data block that is /// specific to this type. - unsigned getLocalDataSize() const { - return sizeof(Info) + getNumArgs() * sizeof(ParmVarDecl*); + unsigned getExtraLocalDataSize() const { + return getNumArgs() * sizeof(ParmVarDecl*); } - /// \brief Returns the size of the type source info data block. - unsigned getFullDataSize() const { - return getLocalDataSize() + getResultLoc().getFullDataSize(); - } + bool hasInnerType() const { return true; } + QualType getInnerType() const { return getTypePtr()->getResultType(); } +}; + - static bool classof(const TypeLoc *TL); - static bool classof(const FunctionLoc *TL) { return true; } +struct ArrayLocInfo { + SourceLocation LBracketLoc, RBracketLoc; + Expr *Size; }; /// \brief Wrapper for source info for arrays. -class ArrayLoc : public DeclaratorLoc { - struct Info { - SourceLocation LBracketLoc, RBracketLoc; - Expr *Size; - }; +class ArrayLoc : public ConcreteTypeLoc { public: SourceLocation getLBracketLoc() const { - return static_cast(Data)->LBracketLoc; + return getLocalData()->LBracketLoc; } void setLBracketLoc(SourceLocation Loc) { - static_cast(Data)->LBracketLoc = Loc; + getLocalData()->LBracketLoc = Loc; } SourceLocation getRBracketLoc() const { - return static_cast(Data)->RBracketLoc; + return getLocalData()->RBracketLoc; } void setRBracketLoc(SourceLocation Loc) { - static_cast(Data)->RBracketLoc = Loc; + getLocalData()->RBracketLoc = Loc; } Expr *getSizeExpr() const { - return static_cast(Data)->Size; + return getLocalData()->Size; } void setSizeExpr(Expr *Size) { - static_cast(Data)->Size = Size; + getLocalData()->Size = Size; } TypeLoc getElementLoc() const { - void *Next = static_cast(Data) + getLocalDataSize(); - return TypeLoc(cast(Ty)->getElementType(), Next); + return getInnerTypeLoc(); } /// \brief Find the TypeSpecLoc that is part of this ArrayLoc. @@ -520,17 +664,8 @@ public: return SourceRange(getLBracketLoc(), getRBracketLoc()); } - /// \brief Returns the size of the type source info data block that is - /// specific to this type. - unsigned getLocalDataSize() const { return sizeof(Info); } - - /// \brief Returns the size of the type source info data block. - unsigned getFullDataSize() const { - return getLocalDataSize() + getElementLoc().getFullDataSize(); - } - - static bool classof(const TypeLoc *TL); - static bool classof(const ArrayLoc *TL) { return true; } + bool hasInnerType() const { return true; } + QualType getInnerType() const { return getTypePtr()->getElementType(); } }; } Modified: projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/TypeLocNodes.def ============================================================================== --- projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/TypeLocNodes.def Thu Oct 15 13:29:27 2009 (r198130) +++ projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/TypeLocNodes.def Thu Oct 15 13:34:45 2009 (r198131) @@ -12,7 +12,9 @@ // base class (e.g., "TypeSpecLoc" or "DeclaratorLoc"), and the Type subclass // that the TypeLoc is associated with. // -// TYPELOC(Class, Base, Type) - Description of the TypeLoc subclass. +// TYPELOC(Class, Base) - A TypeLoc subclass. +// +// UNQUAL_TYPELOC(Class, Base, Type) - An UnqualTypeLoc subclass. // // ABSTRACT_TYPELOC(Class) - Refers to TypeSpecLoc and DeclaratorLoc. // @@ -23,16 +25,20 @@ // //===----------------------------------------------------------------------===// +#ifndef UNQUAL_TYPELOC +# define UNQUAL_TYPELOC(Class, Base, Type) TYPELOC(Class, Base) +#endif + #ifndef ABSTRACT_TYPELOC -# define ABSTRACT_TYPELOC(Class) TYPELOC(Class, TypeLoc, Type) +# define ABSTRACT_TYPELOC(Class) TYPELOC(Class, TypeLoc) #endif #ifndef TYPESPEC_TYPELOC -# define TYPESPEC_TYPELOC(Class, Type) TYPELOC(Class, TypeSpecLoc, Type) +# define TYPESPEC_TYPELOC(Class, Type) UNQUAL_TYPELOC(Class, TypeSpecLoc, Type) #endif #ifndef DECLARATOR_TYPELOC -# define DECLARATOR_TYPELOC(Class, Type) TYPELOC(Class, DeclaratorLoc, Type) +# define DECLARATOR_TYPELOC(Class, Type) UNQUAL_TYPELOC(Class, DeclaratorLoc, Type) #endif TYPESPEC_TYPELOC(DefaultTypeSpecLoc, Type) @@ -47,9 +53,11 @@ DECLARATOR_TYPELOC(FunctionLoc, Function DECLARATOR_TYPELOC(ArrayLoc, ArrayType) ABSTRACT_TYPELOC(DeclaratorLoc) ABSTRACT_TYPELOC(TypeSpecLoc) +TYPELOC(QualifiedLoc, TypeLoc) #undef DECLARATOR_TYPELOC #undef TYPESPEC_TYPELOC #undef ABSTRACT_TYPELOC +#undef UNQUAL_TYPELOC #undef TYPELOC Modified: projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/TypeLocVisitor.h ============================================================================== --- projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/TypeLocVisitor.h Thu Oct 15 13:29:27 2009 (r198130) +++ projects/clangbsd/contrib/llvm/tools/clang/include/clang/AST/TypeLocVisitor.h Thu Oct 15 13:34:45 2009 (r198131) @@ -25,12 +25,14 @@ template { ImplClass *Impl; - TypeLoc TyLoc; + UnqualTypeLoc TyLoc; public: - TypeDispatch(ImplClass *impl, TypeLoc &tyLoc) : Impl(impl), TyLoc(tyLoc) { } + TypeDispatch(ImplClass *impl, UnqualTypeLoc &tyLoc) + : Impl(impl), TyLoc(tyLoc) { } +#define TYPELOC(CLASS, BASE) #define ABSTRACT_TYPELOC(CLASS) -#define TYPELOC(CLASS, PARENT, TYPE) \ +#define UNQUAL_TYPELOC(CLASS, PARENT, TYPE) \ RetTy Visit##TYPE(TYPE *) { \ return Impl->Visit##CLASS(reinterpret_cast(TyLoc)); \ } @@ -39,13 +41,22 @@ class TypeLocVisitor { public: RetTy Visit(TypeLoc TyLoc) { + if (isa(TyLoc)) + return static_cast(this)-> + VisitQualifiedLoc(cast(TyLoc)); + + return Visit(cast(TyLoc)); + } + + RetTy Visit(UnqualTypeLoc TyLoc) { TypeDispatch TD(static_cast(this), TyLoc); - return TD.Visit(TyLoc.getSourceType().getTypePtr()); + return TD.Visit(TyLoc.getSourceTypePtr()); } -#define TYPELOC(CLASS, PARENT, TYPE) RetTy Visit##CLASS(CLASS TyLoc) { \ - DISPATCH(PARENT); \ -} +#define TYPELOC(CLASS, PARENT) \ + RetTy Visit##CLASS(CLASS TyLoc) { \ + DISPATCH(PARENT); \ + } #include "clang/AST/TypeLocNodes.def" RetTy VisitTypeLoc(TypeLoc TyLoc) { return RetTy(); } Modified: projects/clangbsd/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td ============================================================================== --- projects/clangbsd/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 15 13:29:27 2009 (r198130) +++ projects/clangbsd/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 15 13:34:45 2009 (r198131) @@ -936,18 +936,15 @@ def err_template_arg_extra_parens : Erro // C++ template specialization def err_template_spec_unknown_kind : Error< - "can only provide an explicit %select{||specialization|" - "instantiation|instantiation}0 for a class template, function template, or " - "a member function, static data member, or member class of a class template">; + "can only provide an explicit specialization for a class template, function " + "template, or a member function, static data member, or member class of a " + "class template">; def note_specialized_entity : Note< - "explicitly %select{||specialized|instantiated|instantiated}0 " - "declaration is here">; + "explicitly specialized declaration is here">; def err_template_spec_decl_function_scope : Error< - "explicit %select{||specialization|instantiation|" - "instantiation}0 of %1 in function scope">; + "explicit specialization of %0 in function scope">; def err_template_spec_decl_class_scope : Error< - "explicit %select{||specialization|instantiation|" - "instantiation}0 of %1 in class scope">; + "explicit specialization of %0 in class scope">; def err_template_spec_decl_out_of_scope_global : Error< "%select{class template|class template partial|function template|member " "function|static data member|member class}0 specialization of %1 must " @@ -1085,6 +1082,9 @@ def note_nontemplate_decl_here : Note< "non-templated declaration is here">; def err_explicit_instantiation_out_of_scope : Error< "explicit instantiation of %0 not in a namespace enclosing %1">; +def err_explicit_instantiation_must_be_global : Error< + "explicit instantiation of %0 must occur at global scope">; + def err_explicit_instantiation_requires_name : Error< "explicit instantiation declaration requires a name">; def err_explicit_instantiation_of_typedef : Error< @@ -1104,7 +1104,15 @@ def err_explicit_instantiation_ambiguous "partial ordering for explicit instantiation of %0 is ambiguous">; def note_explicit_instantiation_candidate : Note< "explicit instantiation candidate function template here %0">; - +def err_explicit_instantiation_inline : Error< + "explicit instantiation cannot be 'inline'">; +def err_explicit_instantiation_without_qualified_id : Error< + "qualifier in explicit instantiation of %q0 requires a template-id">; *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***