From: Anders Carlsson Date: Mon, 29 Oct 2007 06:33:42 +0000 (+0000) Subject: Address Chris's comments. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e8c49533521c40643653f943d47229e62d277f88;p=clang Address Chris's comments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43445 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp index 87de905a27..bab2e0fcc3 100644 --- a/AST/ASTContext.cpp +++ b/AST/ASTContext.cpp @@ -837,10 +837,11 @@ QualType ASTContext::getCFConstantStringType() { return getTagDeclType(CFConstantStringTypeDecl); } +// This returns true if a type has been typedefed to BOOL: +// typedef BOOL; static bool isTypeTypedefedAsBOOL(QualType T) { - if (const PointerType *NCPT = T->getAsPointerType()) - if (const TypedefType *TT = dyn_cast(NCPT->getPointeeType())) + if (const TypedefType *TT = dyn_cast(T)) if (!strcmp(TT->getDecl()->getName(), "BOOL")) return true; @@ -849,9 +850,15 @@ static bool isTypeTypedefedAsBOOL(QualType T) void ASTContext::getObjcEncodingForType(QualType T, std::string& S) const { - QualType Ty = T.getCanonicalType(); - - if (const BuiltinType *BT = Ty->getAsBuiltinType()) { + // FIXME: This currently doesn't encode: + // @ An object (whether statically typed or typed id) + // # A class object (Class) + // : A method selector (SEL) + // {name=type...} A structure + // (name=type...) A union + // bnum A bit field of num bits + + if (const BuiltinType *BT = T->getAsBuiltinType()) { char encoding; switch (BT->getKind()) { case BuiltinType::Void: @@ -906,13 +913,13 @@ void ASTContext::getObjcEncodingForType(QualType T, std::string& S) const } S += encoding; - } else if (const PointerType *PT = Ty->getAsPointerType()) { + } else if (const PointerType *PT = T->getAsPointerType()) { QualType PointeeTy = PT->getPointeeType(); if (PointeeTy->isCharType()) { // char pointer types should be encoded as '*' unless it is a // type that has been typedef'd to 'BOOL'. - if (!isTypeTypedefedAsBOOL(T)) { + if (!isTypeTypedefedAsBOOL(PointeeTy)) { S += '*'; return; } @@ -920,7 +927,7 @@ void ASTContext::getObjcEncodingForType(QualType T, std::string& S) const S += '^'; getObjcEncodingForType(PT->getPointeeType(), S); - } else if (const ArrayType *AT = Ty->getAsArrayType()) { + } else if (const ArrayType *AT = T->getAsArrayType()) { S += '['; if (const ConstantArrayType *CAT = dyn_cast(AT)) @@ -931,8 +938,7 @@ void ASTContext::getObjcEncodingForType(QualType T, std::string& S) const getObjcEncodingForType(AT->getElementType(), S); S += ']'; } else - fprintf(stderr, "@encode for type %s not implemented!\n", - Ty.getAsString().c_str()); + assert(0 && "@encode for type not implemented!"); } void ASTContext::setBuiltinVaListType(QualType T) 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 = "";