]> granicus.if.org Git - clang/commitdiff
Renamed getSynthesizedSelectorSize to getSynthesizedMethodSize. Compute method name
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 17 Jan 2008 17:37:26 +0000 (17:37 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 17 Jan 2008 17:37:26 +0000 (17:37 +0000)
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

AST/Decl.cpp
Sema/SemaExpr.cpp
include/clang/AST/DeclObjC.h

index d80b5eea80bb7a0f29a057abd21fce015876d56a..8ee382c2375a2d8d331d0a7c775b5bf344aa16b0 100644 (file)
@@ -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<ObjCCategoryImplDecl>(MethodContext))
+    length += strlen(CID->getName()) +1;
+  length += getSelector().getName().size(); // selector name
   return length; 
 }
 
index a80bc4352595908992e4be780aed67aeec523a44..5d446dd01ea5f8fbbe74e44c8a0030a8f4e560f4 100644 (file)
@@ -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);
index f46f324e57dd71223c3478bc8e0ad967d4e8876f..fb8143777269a6637fa8d5141a2da03984bf8ec3 100644 (file)
@@ -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.