diff options
-rw-r--r-- | AST/Decl.cpp | 9 | ||||
-rw-r--r-- | Sema/SemaExpr.cpp | 2 | ||||
-rw-r--r-- | include/clang/AST/DeclObjC.h | 1 |
3 files changed, 11 insertions, 1 deletions
diff --git a/AST/Decl.cpp b/AST/Decl.cpp index bf1ffee832..d80b5eea80 100644 --- a/AST/Decl.cpp +++ b/AST/Decl.cpp @@ -549,6 +549,15 @@ ObjCMethodDecl *ObjCProtocolDecl::lookupClassMethod(Selector Sel) { return NULL; } +int ObjCMethodDecl::getSynthesizedSelectorSize() 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 + return length; +} + ObjCInterfaceDecl *const ObjCMethodDecl::getClassInterface() const { if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(MethodContext)) return ID; diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp index c88985f75a..81376a6500 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->getSelector().getName().size(); + Length = CurMethodDecl->getSynthesizedSelectorSize(); 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 34abdb06a8..f46f324e57 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -116,6 +116,7 @@ public: ObjCInterfaceDecl *const getClassInterface() const; Selector getSelector() const { return SelName; } + int getSynthesizedSelectorSize() const; QualType getResultType() const { return MethodDeclType; } // Iterator access to formal parameters. |