зеркало из https://github.com/microsoft/clang-1.git
Added a new class for Interfaces qualified by protocol list.
Protocols are now sorted and made unique in the list. Enhanced pretty printer for @interface (So, I can see the protocol list). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42776 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
22cdd239dc
Коммит
e37882ad33
|
@ -140,6 +140,10 @@ const llvm::Type *CodeGenTypes::ConvertType(QualType T) {
|
||||||
case Type::ObjcInterface:
|
case Type::ObjcInterface:
|
||||||
assert(0 && "FIXME: add missing functionality here");
|
assert(0 && "FIXME: add missing functionality here");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Type::ObjcQualifiedInterface:
|
||||||
|
assert(0 && "FIXME: add missing functionality here");
|
||||||
|
break;
|
||||||
|
|
||||||
case Type::Tagged:
|
case Type::Tagged:
|
||||||
const TagType &TT = cast<TagType>(Ty);
|
const TagType &TT = cast<TagType>(Ty);
|
||||||
|
|
|
@ -74,8 +74,26 @@ static void PrintTypeDefDecl(TypedefDecl *TD) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrintObjcInterfaceDecl(ObjcInterfaceDecl *OID) {
|
static void PrintObjcInterfaceDecl(ObjcInterfaceDecl *OID) {
|
||||||
std::string S = OID->getName();
|
std::string I = OID->getName();
|
||||||
fprintf(stderr, "@interface %s;\n", S.c_str());
|
ObjcInterfaceDecl *SID = OID->getSuperClass();
|
||||||
|
if (SID) {
|
||||||
|
std::string S = SID->getName();
|
||||||
|
fprintf(stderr, "@interface %s : %s", I.c_str(), S.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fprintf(stderr, "@interface %s", I.c_str());
|
||||||
|
// Protocols?
|
||||||
|
int count = OID->getNumIntfRefProtocols();
|
||||||
|
if (count > 0) {
|
||||||
|
ObjcProtocolDecl **refProtocols = OID->getReferencedProtocols();
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
fprintf(stderr, "%c%s", (i == 0 ? '<' : ','),
|
||||||
|
refProtocols[i]->getName());
|
||||||
|
}
|
||||||
|
if (count > 0)
|
||||||
|
fprintf(stderr, ">;\n");
|
||||||
|
else
|
||||||
|
fprintf(stderr, ";\n");
|
||||||
// FIXME: implement the rest...
|
// FIXME: implement the rest...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -618,6 +618,12 @@ Parser::DeclTy *Parser::ParseObjCMethodDecl(tok::TokenKind mType,
|
||||||
MethodAttrs, MethodImplKind);
|
MethodAttrs, MethodImplKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// CmpProtocolVals - Comparison predicate for sorting protocols.
|
||||||
|
static bool CmpProtocolVals(const IdentifierInfo* const& lhs,
|
||||||
|
const IdentifierInfo* const& rhs) {
|
||||||
|
return strcmp(lhs->getName(), rhs->getName()) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
/// objc-protocol-refs:
|
/// objc-protocol-refs:
|
||||||
/// '<' identifier-list '>'
|
/// '<' identifier-list '>'
|
||||||
///
|
///
|
||||||
|
@ -640,6 +646,15 @@ bool Parser::ParseObjCProtocolReferences(
|
||||||
break;
|
break;
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort protocols, keyed by name.
|
||||||
|
// Later on, we remove duplicates.
|
||||||
|
std::stable_sort(ProtocolRefs.begin(), ProtocolRefs.end(), CmpProtocolVals);
|
||||||
|
|
||||||
|
// Make protocol names unique.
|
||||||
|
ProtocolRefs.erase(std::unique(ProtocolRefs.begin(), ProtocolRefs.end()),
|
||||||
|
ProtocolRefs.end());
|
||||||
|
|
||||||
// Consume the '>'.
|
// Consume the '>'.
|
||||||
return ExpectAndConsume(tok::greater, diag::err_expected_greater);
|
return ExpectAndConsume(tok::greater, diag::err_expected_greater);
|
||||||
}
|
}
|
||||||
|
|
|
@ -739,6 +739,7 @@
|
||||||
08FB7793FE84155DC02AAC07 /* Project object */ = {
|
08FB7793FE84155DC02AAC07 /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
|
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
|
||||||
|
compatibilityVersion = "Xcode 2.4";
|
||||||
hasScannedForEncodings = 1;
|
hasScannedForEncodings = 1;
|
||||||
mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
|
mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
|
|
|
@ -32,6 +32,7 @@ namespace clang {
|
||||||
class RecordDecl;
|
class RecordDecl;
|
||||||
class EnumDecl;
|
class EnumDecl;
|
||||||
class ObjcInterfaceDecl;
|
class ObjcInterfaceDecl;
|
||||||
|
class ObjcProtocolDecl;
|
||||||
class Expr;
|
class Expr;
|
||||||
class SourceLocation;
|
class SourceLocation;
|
||||||
class PointerType;
|
class PointerType;
|
||||||
|
@ -204,7 +205,7 @@ public:
|
||||||
Vector, OCUVector,
|
Vector, OCUVector,
|
||||||
FunctionNoProto, FunctionProto,
|
FunctionNoProto, FunctionProto,
|
||||||
TypeName, Tagged,
|
TypeName, Tagged,
|
||||||
ObjcInterface,
|
ObjcInterface, ObjcQualifiedInterface,
|
||||||
TypeOfExp, TypeOfTyp // GNU typeof extension.
|
TypeOfExp, TypeOfTyp // GNU typeof extension.
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
|
@ -831,6 +832,28 @@ public:
|
||||||
static bool classof(const ObjcInterfaceType *) { return true; }
|
static bool classof(const ObjcInterfaceType *) { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// - ObjcQualifiedInterfaceType - This class represense interface types
|
||||||
|
/// conforming to a list of protocols; such as, INTF<Proto1, Proto2, Proto1>.
|
||||||
|
class ObjcQualifiedInterfaceType : public Type {
|
||||||
|
// Interface type for this protocol conforming object type
|
||||||
|
ObjcInterfaceType *InterfaceType;
|
||||||
|
|
||||||
|
// List of protocols for this protocol conforming object type
|
||||||
|
// List is sorted on protocol name. No protocol is enterred more than once.
|
||||||
|
llvm::SmallVector<ObjcProtocolDecl*, 8> Protocols;
|
||||||
|
|
||||||
|
ObjcQualifiedInterfaceType(ObjcInterfaceType *T) :
|
||||||
|
Type(ObjcQualifiedInterface, QualType()), InterfaceType(T) { }
|
||||||
|
public:
|
||||||
|
|
||||||
|
ObjcInterfaceType *getInterfaceType() const { return InterfaceType; }
|
||||||
|
|
||||||
|
static bool classof(const Type *T) {
|
||||||
|
return T->getTypeClass() == ObjcQualifiedInterface;
|
||||||
|
}
|
||||||
|
static bool classof(const ObjcQualifiedInterfaceType *) { return true; }
|
||||||
|
};
|
||||||
|
|
||||||
/// RecordType - This is a helper class that allows the use of isa/cast/dyncast
|
/// RecordType - This is a helper class that allows the use of isa/cast/dyncast
|
||||||
/// to detect TagType objects of structs/unions/classes.
|
/// to detect TagType objects of structs/unions/classes.
|
||||||
class RecordType : public TagType {
|
class RecordType : public TagType {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче