forked from OSchip/llvm-project
Introduce ObjCInterfaceLoc which provides type source information for ObjC interfaces.
llvm-svn: 83097
This commit is contained in:
parent
d4bcfaf351
commit
0643e333a3
|
@ -154,6 +154,38 @@ public:
|
||||||
static bool classof(const TypedefLoc *TL) { return true; }
|
static bool classof(const TypedefLoc *TL) { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// \brief Wrapper for source info for ObjC interfaces.
|
||||||
|
class ObjCInterfaceLoc : public TypeSpecLoc {
|
||||||
|
struct Info {
|
||||||
|
SourceLocation NameLoc;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
SourceLocation getNameLoc() const {
|
||||||
|
return static_cast<Info*>(Data)->NameLoc;
|
||||||
|
}
|
||||||
|
void setNameLoc(SourceLocation Loc) {
|
||||||
|
static_cast<Info*>(Data)->NameLoc = Loc;
|
||||||
|
}
|
||||||
|
SourceRange getSourceRange() const {
|
||||||
|
return SourceRange(getNameLoc(), getNameLoc());
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjCInterfaceDecl *getIFaceDecl() const {
|
||||||
|
return cast<ObjCInterfaceType>(Ty)->getDecl();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \brief Returns the size of the type source info data block that is
|
||||||
|
/// specific to this type.
|
||||||
|
unsigned getLocalDataSize() const { return sizeof(Info); }
|
||||||
|
|
||||||
|
/// \brief Returns the size of the type source info data block.
|
||||||
|
unsigned getFullDataSize() const { return getLocalDataSize(); }
|
||||||
|
|
||||||
|
static bool classof(const TypeLoc *TL);
|
||||||
|
static bool classof(const TypedefLoc *TL) { return true; }
|
||||||
|
};
|
||||||
|
|
||||||
/// \brief Wrapper for source info for ObjC protocol lists.
|
/// \brief Wrapper for source info for ObjC protocol lists.
|
||||||
class ObjCProtocolListLoc : public TypeSpecLoc {
|
class ObjCProtocolListLoc : public TypeSpecLoc {
|
||||||
struct Info {
|
struct Info {
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
TYPESPEC_TYPELOC(DefaultTypeSpecLoc, Type)
|
TYPESPEC_TYPELOC(DefaultTypeSpecLoc, Type)
|
||||||
TYPESPEC_TYPELOC(TypedefLoc, TypedefType)
|
TYPESPEC_TYPELOC(TypedefLoc, TypedefType)
|
||||||
|
TYPESPEC_TYPELOC(ObjCInterfaceLoc, ObjCInterfaceType)
|
||||||
TYPESPEC_TYPELOC(ObjCProtocolListLoc, ObjCProtocolListType)
|
TYPESPEC_TYPELOC(ObjCProtocolListLoc, ObjCProtocolListType)
|
||||||
DECLARATOR_TYPELOC(PointerLoc, PointerType)
|
DECLARATOR_TYPELOC(PointerLoc, PointerType)
|
||||||
DECLARATOR_TYPELOC(BlockPointerLoc, BlockPointerType)
|
DECLARATOR_TYPELOC(BlockPointerLoc, BlockPointerType)
|
||||||
|
|
|
@ -229,6 +229,24 @@ bool TypedefLoc::classof(const TypeLoc *TL) {
|
||||||
return TypedefLocChecker().Visit(*TL);
|
return TypedefLocChecker().Visit(*TL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// ObjCInterfaceLoc Implementation
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class ObjCInterfaceLocChecker :
|
||||||
|
public TypeLocVisitor<ObjCInterfaceLocChecker, bool> {
|
||||||
|
public:
|
||||||
|
bool VisitObjCInterfaceLoc(ObjCInterfaceLoc TyLoc) { return true; }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ObjCInterfaceLoc::classof(const TypeLoc *TL) {
|
||||||
|
return ObjCInterfaceLocChecker().Visit(*TL);
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// ObjCProtocolListLoc Implementation
|
// ObjCProtocolListLoc Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
|
@ -179,6 +179,9 @@ void TypeLocReader::VisitDefaultTypeSpecLoc(DefaultTypeSpecLoc TyLoc) {
|
||||||
void TypeLocReader::VisitTypedefLoc(TypedefLoc TyLoc) {
|
void TypeLocReader::VisitTypedefLoc(TypedefLoc TyLoc) {
|
||||||
TyLoc.setNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
TyLoc.setNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
||||||
}
|
}
|
||||||
|
void TypeLocReader::VisitObjCInterfaceLoc(ObjCInterfaceLoc TyLoc) {
|
||||||
|
TyLoc.setNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
||||||
|
}
|
||||||
void TypeLocReader::VisitObjCProtocolListLoc(ObjCProtocolListLoc TyLoc) {
|
void TypeLocReader::VisitObjCProtocolListLoc(ObjCProtocolListLoc TyLoc) {
|
||||||
TyLoc.setLAngleLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
TyLoc.setLAngleLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
||||||
TyLoc.setRAngleLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
TyLoc.setRAngleLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
||||||
|
|
|
@ -177,6 +177,9 @@ void TypeLocWriter::VisitDefaultTypeSpecLoc(DefaultTypeSpecLoc TyLoc) {
|
||||||
void TypeLocWriter::VisitTypedefLoc(TypedefLoc TyLoc) {
|
void TypeLocWriter::VisitTypedefLoc(TypedefLoc TyLoc) {
|
||||||
Writer.AddSourceLocation(TyLoc.getNameLoc(), Record);
|
Writer.AddSourceLocation(TyLoc.getNameLoc(), Record);
|
||||||
}
|
}
|
||||||
|
void TypeLocWriter::VisitObjCInterfaceLoc(ObjCInterfaceLoc TyLoc) {
|
||||||
|
Writer.AddSourceLocation(TyLoc.getNameLoc(), Record);
|
||||||
|
}
|
||||||
void TypeLocWriter::VisitObjCProtocolListLoc(ObjCProtocolListLoc TyLoc) {
|
void TypeLocWriter::VisitObjCProtocolListLoc(ObjCProtocolListLoc TyLoc) {
|
||||||
Writer.AddSourceLocation(TyLoc.getLAngleLoc(), Record);
|
Writer.AddSourceLocation(TyLoc.getLAngleLoc(), Record);
|
||||||
Writer.AddSourceLocation(TyLoc.getRAngleLoc(), Record);
|
Writer.AddSourceLocation(TyLoc.getRAngleLoc(), Record);
|
||||||
|
|
|
@ -1299,6 +1299,9 @@ static void FillTypeSpecLoc(TypeLoc TSL, const DeclSpec &DS) {
|
||||||
if (TypedefLoc *TL = dyn_cast<TypedefLoc>(&TSL)) {
|
if (TypedefLoc *TL = dyn_cast<TypedefLoc>(&TSL)) {
|
||||||
TL->setNameLoc(DS.getTypeSpecTypeLoc());
|
TL->setNameLoc(DS.getTypeSpecTypeLoc());
|
||||||
|
|
||||||
|
} else if (ObjCInterfaceLoc *TL = dyn_cast<ObjCInterfaceLoc>(&TSL)) {
|
||||||
|
TL->setNameLoc(DS.getTypeSpecTypeLoc());
|
||||||
|
|
||||||
} else if (ObjCProtocolListLoc *PLL = dyn_cast<ObjCProtocolListLoc>(&TSL)) {
|
} else if (ObjCProtocolListLoc *PLL = dyn_cast<ObjCProtocolListLoc>(&TSL)) {
|
||||||
assert(PLL->getNumProtocols() == DS.getNumProtocolQualifiers());
|
assert(PLL->getNumProtocols() == DS.getNumProtocolQualifiers());
|
||||||
PLL->setLAngleLoc(DS.getProtocolLAngleLoc());
|
PLL->setLAngleLoc(DS.getProtocolLAngleLoc());
|
||||||
|
|
Loading…
Reference in New Issue