From 005f6b222dfddc12ada571e479ff2d7a58114d07 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Mon, 16 Feb 2009 14:31:00 +0000 Subject: [PATCH] castToDeclContext/castFromDeclContext are only required to be included in the class of decls that directly derive from DeclContext. Their subclasses don't need them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64632 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Decl.h | 12 ------------ include/clang/AST/DeclCXX.h | 36 ++++++------------------------------ include/clang/AST/DeclObjC.h | 18 ------------------ 3 files changed, 6 insertions(+), 60 deletions(-) diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index b39467a55f..337f041b47 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -954,12 +954,6 @@ public: static bool classof(const Decl *D) { return D->getKind() == Enum; } static bool classof(const EnumDecl *D) { return true; } - static DeclContext *castToDeclContext(const EnumDecl *D) { - return static_cast(const_cast(D)); - } - static EnumDecl *castFromDeclContext(const DeclContext *DC) { - return static_cast(const_cast(DC)); - } protected: /// EmitImpl - Serialize this EnumDecl. Called by Decl::Emit. @@ -1054,12 +1048,6 @@ public: return D->getKind() >= RecordFirst && D->getKind() <= RecordLast; } static bool classof(const RecordDecl *D) { return true; } - static DeclContext *castToDeclContext(const RecordDecl *D) { - return static_cast(const_cast(D)); - } - static RecordDecl *castFromDeclContext(const DeclContext *DC) { - return static_cast(const_cast(DC)); - } protected: /// EmitImpl - Serialize this RecordDecl. Called by Decl::Emit. virtual void EmitImpl(llvm::Serializer& S) const; diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index e41dc1802d..9b25e29c69 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -357,12 +357,6 @@ public: static bool classof(const Decl *D) { return D->getKind() == CXXRecord; } static bool classof(const CXXRecordDecl *D) { return true; } - static DeclContext *castToDeclContext(const CXXRecordDecl *D) { - return static_cast(const_cast(D)); - } - static CXXRecordDecl *castFromDeclContext(const DeclContext *DC) { - return static_cast(const_cast(DC)); - } protected: /// EmitImpl - Serialize this CXXRecordDecl. Called by Decl::Emit. @@ -425,12 +419,6 @@ public: return D->getKind() >= CXXMethod && D->getKind() <= CXXConversion; } static bool classof(const CXXMethodDecl *D) { return true; } - static DeclContext *castToDeclContext(const CXXMethodDecl *D) { - return static_cast(const_cast(D)); - } - static CXXMethodDecl *castFromDeclContext(const DeclContext *DC) { - return static_cast(const_cast(DC)); - } protected: /// EmitImpl - Serialize this CXXMethodDecl. Called by Decl::Emit. @@ -638,12 +626,6 @@ public: return D->getKind() == CXXConstructor; } static bool classof(const CXXConstructorDecl *D) { return true; } - static DeclContext *castToDeclContext(const CXXConstructorDecl *D) { - return static_cast(const_cast(D)); - } - static CXXConstructorDecl *castFromDeclContext(const DeclContext *DC) { - return static_cast(const_cast(DC)); - } /// EmitImpl - Serialize this CXXConstructorDecl. Called by Decl::Emit. // FIXME: Implement this. //virtual void EmitImpl(llvm::Serializer& S) const; @@ -708,12 +690,6 @@ public: return D->getKind() == CXXDestructor; } static bool classof(const CXXDestructorDecl *D) { return true; } - static DeclContext *castToDeclContext(const CXXDestructorDecl *D) { - return static_cast(const_cast(D)); - } - static CXXDestructorDecl *castFromDeclContext(const DeclContext *DC) { - return static_cast(const_cast(DC)); - } /// EmitImpl - Serialize this CXXDestructorDecl. Called by Decl::Emit. // FIXME: Implement this. //virtual void EmitImpl(llvm::Serializer& S) const; @@ -766,12 +742,6 @@ public: return D->getKind() == CXXConversion; } static bool classof(const CXXConversionDecl *D) { return true; } - static DeclContext *castToDeclContext(const CXXConversionDecl *D) { - return static_cast(const_cast(D)); - } - static CXXConversionDecl *castFromDeclContext(const DeclContext *DC) { - return static_cast(const_cast(DC)); - } /// EmitImpl - Serialize this CXXConversionDecl. Called by Decl::Emit. // FIXME: Implement this. //virtual void EmitImpl(llvm::Serializer& S) const; @@ -878,6 +848,12 @@ public: return D->getKind() == LinkageSpec; } static bool classof(const LinkageSpecDecl *D) { return true; } + static DeclContext *castToDeclContext(const LinkageSpecDecl *D) { + return static_cast(const_cast(D)); + } + static LinkageSpecDecl *castFromDeclContext(const DeclContext *DC) { + return static_cast(const_cast(DC)); + } protected: void EmitInRec(llvm::Serializer& S) const; diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index c77cc15e75..e297434170 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -478,12 +478,6 @@ public: static bool classof(const Decl *D) { return D->getKind() == ObjCInterface; } static bool classof(const ObjCInterfaceDecl *D) { return true; } - static DeclContext *castToDeclContext(const ObjCInterfaceDecl *D) { - return static_cast(const_cast(D)); - } - static ObjCInterfaceDecl *castFromDeclContext(const DeclContext *DC) { - return static_cast(const_cast(DC)); - } }; /// ObjCIvarDecl - Represents an ObjC instance variable. In general, ObjC @@ -633,12 +627,6 @@ public: static bool classof(const Decl *D) { return D->getKind() == ObjCProtocol; } static bool classof(const ObjCProtocolDecl *D) { return true; } - static DeclContext *castToDeclContext(const ObjCProtocolDecl *D) { - return static_cast(const_cast(D)); - } - static ObjCProtocolDecl *castFromDeclContext(const DeclContext *DC) { - return static_cast(const_cast(DC)); - } }; /// ObjCClassDecl - Specifies a list of forward class declarations. For example: @@ -816,12 +804,6 @@ public: static bool classof(const Decl *D) { return D->getKind() == ObjCCategory; } static bool classof(const ObjCCategoryDecl *D) { return true; } - static DeclContext *castToDeclContext(const ObjCCategoryDecl *D) { - return static_cast(const_cast(D)); - } - static ObjCCategoryDecl *castFromDeclContext(const DeclContext *DC) { - return static_cast(const_cast(DC)); - } }; /// ObjCCategoryImplDecl - An object of this class encapsulates a category -- 2.40.0