From c2939bc82ce177c0413feb0cd9ce70aefd6235fb Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 30 Oct 2007 17:06:23 +0000 Subject: [PATCH] Added type encoding for 'id' type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43504 91177308-0d34-0410-b5e6-96231b3b80d8 --- AST/ASTContext.cpp | 4 ++++ Sema/SemaDecl.cpp | 8 ++++++++ clang.xcodeproj/project.pbxproj | 1 + test/Sema/method-encoding-1.m | 18 ++++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 test/Sema/method-encoding-1.m diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp index ee45c00831..40b7b647e9 100644 --- a/AST/ASTContext.cpp +++ b/AST/ASTContext.cpp @@ -1010,6 +1010,10 @@ void ASTContext::getObjcEncodingForType(QualType T, std::string& S) const S += encoding; } else if (const PointerType *PT = T->getAsPointerType()) { QualType PointeeTy = PT->getPointeeType(); + if (isObjcIdType(PointeeTy)) { + S += '@'; + return; + } if (PointeeTy->isCharType()) { // char pointer types should be encoded as '*' unless it is a diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index e125ce54ab..f4717ce66b 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -1963,6 +1963,14 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration( TypeTy **ArgTypes, IdentifierInfo **ArgNames, AttributeList *AttrList, tok::ObjCKeywordKind MethodDeclKind) { llvm::SmallVector Params; + + // We cannot build type 'id' laziliy. It is needed when checking if a + // type is an 'id' (via call to isObjcIdType) even if there is no + // need for the dafult 'id' type. + // FIXME: Depending on the need to compare to 'id', this may have to go + // somewhere else. At this time, this is a good enough place to do type + // encoding of methods and ivars for the rewrite client. + GetObjcIdType(MethodLoc); for (unsigned i = 0; i < Sel.getNumArgs(); i++) { // FIXME: arg->AttrList must be stored too! diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj index de41b4628d..fe4cf8d85b 100644 --- a/clang.xcodeproj/project.pbxproj +++ b/clang.xcodeproj/project.pbxproj @@ -756,6 +756,7 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */; + compatibilityVersion = "Xcode 2.4"; hasScannedForEncodings = 1; mainGroup = 08FB7794FE84155DC02AAC07 /* clang */; projectDirPath = ""; diff --git a/test/Sema/method-encoding-1.m b/test/Sema/method-encoding-1.m new file mode 100644 index 0000000000..0029d4e1f9 --- /dev/null +++ b/test/Sema/method-encoding-1.m @@ -0,0 +1,18 @@ +// RUN: clang -rewrite-test -verify %s + +@protocol P1 +- (void) MyProtoMeth : (int **) arg1 : (void*) arg2; ++ (void) MyProtoMeth : (int **) arg1 : (void*) arg2; +@end + +@interface Intf +- (char *) MyMeth : (double) arg1 : (char *[12]) arg2; +- (id) address:(void *)location with:(unsigned **)arg2; +@end + +@implementation Intf +- (char *) MyMeth : (double) arg1 : (char *[12]) arg2{} +- (void) MyProtoMeth : (int **) arg1 : (void*) arg2 {} ++ (void) MyProtoMeth : (int **) arg1 : (void*) arg2 {} +- (id) address:(void *)location with:(unsigned **)arg2{} +@end -- 2.40.0