From: Argyrios Kyrtzidis Date: Mon, 3 Oct 2011 06:36:29 +0000 (+0000) Subject: Don't keep NumSelectorArgs in the ObjCMethodDecl, the number can be derived from... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=da92a7f91cf88f49e02050919676f7fb8e3bdff8;p=clang Don't keep NumSelectorArgs in the ObjCMethodDecl, the number can be derived from the selector. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140983 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index b9d2ba3a7b..d4ce117b30 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -137,9 +137,6 @@ private: /// \brief Indicates whether this method has a related result type. unsigned RelatedResultType : 1; - - // Number of args separated by ':' in a method declaration. - unsigned NumSelectorArgs; // Result type of this method. QualType MethodDeclType; @@ -175,15 +172,14 @@ private: bool isImplicitlyDeclared = false, bool isDefined = false, ImplementationControl impControl = None, - bool HasRelatedResultType = false, - unsigned numSelectorArgs = 0) + bool HasRelatedResultType = false) : NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo), DeclContext(ObjCMethod), Family(InvalidObjCMethodFamily), IsInstance(isInstance), IsVariadic(isVariadic), IsSynthesized(isSynthesized), IsDefined(isDefined), DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None), - RelatedResultType(HasRelatedResultType), NumSelectorArgs(numSelectorArgs), + RelatedResultType(HasRelatedResultType), MethodDeclType(T), ResultTInfo(ResultTInfo), EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) { setImplicit(isImplicitlyDeclared); @@ -207,8 +203,7 @@ public: bool isImplicitlyDeclared = false, bool isDefined = false, ImplementationControl impControl = None, - bool HasRelatedResultType = false, - unsigned numSelectorArgs = 0); + bool HasRelatedResultType = false); virtual ObjCMethodDecl *getCanonicalDecl(); const ObjCMethodDecl *getCanonicalDecl() const { @@ -227,11 +222,6 @@ public: /// \brief Note whether this method has a related result type. void SetRelatedResultType(bool RRT = true) { RelatedResultType = RRT; } - unsigned getNumSelectorArgs() const { return NumSelectorArgs; } - void setNumSelectorArgs(unsigned numSelectorArgs) { - NumSelectorArgs = numSelectorArgs; - } - // Location information, modeled after the Stmt API. SourceLocation getLocStart() const { return getLocation(); } SourceLocation getLocEnd() const { return EndLoc; } @@ -267,13 +257,11 @@ public: // This method returns and of the parameters which are part of the selector // name mangling requirements. param_iterator sel_param_end() const { - return ParamInfo.begin() + NumSelectorArgs; + return ParamInfo.begin() + getSelector().getNumArgs(); } - void setMethodParams(ASTContext &C, ParmVarDecl *const *List, unsigned Num, - unsigned numSelectorArgs) { + void setMethodParams(ASTContext &C, ParmVarDecl *const *List, unsigned Num) { ParamInfo.set(List, Num, C); - NumSelectorArgs = numSelectorArgs; } // Iterator access to parameter types. diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 55610cbc63..09151a7888 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -2955,8 +2955,7 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) { ToMethod->addDecl(ToParams[I]); } ToMethod->setMethodParams(Importer.getToContext(), - ToParams.data(), ToParams.size(), - ToParams.size()); + ToParams.data(), ToParams.size()); ToMethod->setLexicalDeclContext(LexicalDC); Importer.Imported(D, ToMethod); diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 97f215fb7f..a461eaaeae 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -341,16 +341,14 @@ ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C, bool isImplicitlyDeclared, bool isDefined, ImplementationControl impControl, - bool HasRelatedResultType, - unsigned numSelectorArgs) { + bool HasRelatedResultType) { return new (C) ObjCMethodDecl(beginLoc, endLoc, SelInfo, T, ResultTInfo, contextDecl, isInstance, isVariadic, isSynthesized, isImplicitlyDeclared, isDefined, impControl, - HasRelatedResultType, - numSelectorArgs); + HasRelatedResultType); } /// \brief A definition will return its interface declaration. diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index f1a2637077..23e44748c8 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -2609,8 +2609,7 @@ Decl *Sema::ActOnMethodDeclaration( Params.push_back(Param); } - ObjCMethod->setMethodParams(Context, Params.data(), Params.size(), - Sel.getNumArgs()); + ObjCMethod->setMethodParams(Context, Params.data(), Params.size()); ObjCMethod->setObjCDeclQualifier( CvtQTToAstBitMask(ReturnQT.getObjCDeclQualifier())); diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 34c7020765..655adde37e 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -1576,7 +1576,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, SC_None, SC_None, 0); - SetterMethod->setMethodParams(Context, &Argument, 1, 1); + SetterMethod->setMethodParams(Context, &Argument, 1); AddPropertyAttrs(*this, SetterMethod, property); diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 1ed8a266a0..53155b118e 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -485,7 +485,6 @@ void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) { MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]); MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]); MD->SetRelatedResultType(Record[Idx++]); - MD->setNumSelectorArgs(unsigned(Record[Idx++])); MD->setResultType(Reader.readType(F, Record, Idx)); MD->setResultTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); MD->setEndLoc(ReadSourceLocation(Record, Idx)); @@ -494,8 +493,7 @@ void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) { Params.reserve(NumParams); for (unsigned I = 0; I != NumParams; ++I) Params.push_back(ReadDeclAs(Record, Idx)); - MD->setMethodParams(Reader.getContext(), Params.data(), NumParams, - NumParams); + MD->setMethodParams(Reader.getContext(), Params.data(), NumParams); } void ASTDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) { diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp index 46eb53b731..77fc3f0988 100644 --- a/lib/Serialization/ASTWriterDecl.cpp +++ b/lib/Serialization/ASTWriterDecl.cpp @@ -407,7 +407,6 @@ void ASTDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) { // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway Record.push_back(D->getObjCDeclQualifier()); Record.push_back(D->hasRelatedResultType()); - Record.push_back(D->getNumSelectorArgs()); Writer.AddTypeRef(D->getResultType(), Record); Writer.AddTypeSourceInfo(D->getResultTypeSourceInfo(), Record); Writer.AddSourceLocation(D->getLocEnd(), Record);