From: Fariborz Jahanian Date: Thu, 17 Jan 2008 17:37:26 +0000 (+0000) Subject: Renamed getSynthesizedSelectorSize to getSynthesizedMethodSize. Compute method name X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=faf5e779d16bb4590f2a97e1c7ded255eddd90f3;p=clang Renamed getSynthesizedSelectorSize to getSynthesizedMethodSize. Compute method name size in accordance with how rewriter synthesizes method name. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46131 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/AST/Decl.cpp b/AST/Decl.cpp index d80b5eea80..8ee382c237 100644 --- a/AST/Decl.cpp +++ b/AST/Decl.cpp @@ -549,12 +549,19 @@ ObjCMethodDecl *ObjCProtocolDecl::lookupClassMethod(Selector Sel) { return NULL; } -int ObjCMethodDecl::getSynthesizedSelectorSize() const { +/// getSynthesizedMethodSize - Compute size of synthesized method name +/// as done be the rewrite. +/// +unsigned ObjCMethodDecl::getSynthesizedMethodSize() const { // syntesized method name is a concatenation of -/+[class-name selector] // Get length of this name. - int length = 4; // for '+' or '-', '[', space in between and ']' - length += getSelector().getName().size(); // for selector name. - length += strlen(getMethodContext()->getName()); // for its class name + unsigned length = 3; // _I_ or _C_ + length += strlen(getClassInterface()->getName()) +1; // extra for _ + NamedDecl *MethodContext = getMethodContext(); + if (ObjCCategoryImplDecl *CID = + dyn_cast(MethodContext)) + length += strlen(CID->getName()) +1; + length += getSelector().getName().size(); // selector name return length; } diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp index a80bc43525..5d446dd01e 100644 --- a/Sema/SemaExpr.cpp +++ b/Sema/SemaExpr.cpp @@ -131,7 +131,7 @@ Sema::ExprResult Sema::ActOnPreDefinedExpr(SourceLocation Loc, if (CurFunctionDecl) Length = CurFunctionDecl->getIdentifier()->getLength(); else - Length = CurMethodDecl->getSynthesizedSelectorSize(); + Length = CurMethodDecl->getSynthesizedMethodSize(); llvm::APInt LengthI(32, Length + 1); QualType ResTy = Context.CharTy.getQualifiedType(QualType::Const); diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index f46f324e57..fb81437772 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -116,7 +116,7 @@ public: ObjCInterfaceDecl *const getClassInterface() const; Selector getSelector() const { return SelName; } - int getSynthesizedSelectorSize() const; + unsigned getSynthesizedMethodSize() const; QualType getResultType() const { return MethodDeclType; } // Iterator access to formal parameters.