]> granicus.if.org Git - clang/commitdiff
Introduce ObjCInterfaceLoc which provides type source information for ObjC interfaces.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 29 Sep 2009 19:45:22 +0000 (19:45 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 29 Sep 2009 19:45:22 +0000 (19:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83097 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/TypeLoc.h
include/clang/AST/TypeLocNodes.def
lib/AST/TypeLoc.cpp
lib/Frontend/PCHReaderDecl.cpp
lib/Frontend/PCHWriterDecl.cpp
lib/Sema/SemaType.cpp

index dfa69a979ea94370f32fea50360661d2ac9843db..100003929d1c8be15f3d50f6ba1f4a9197ef20b0 100644 (file)
@@ -154,6 +154,38 @@ public:
   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.
 class ObjCProtocolListLoc : public TypeSpecLoc {
   struct Info {
index de20182c0ee675780a84d9f218de610b0e3d4906..107ea85479f9fec0cd6079749f6c7f351f67c9de 100644 (file)
@@ -37,6 +37,7 @@
 
 TYPESPEC_TYPELOC(DefaultTypeSpecLoc, Type)
 TYPESPEC_TYPELOC(TypedefLoc, TypedefType)
+TYPESPEC_TYPELOC(ObjCInterfaceLoc, ObjCInterfaceType)
 TYPESPEC_TYPELOC(ObjCProtocolListLoc, ObjCProtocolListType)
 DECLARATOR_TYPELOC(PointerLoc, PointerType)
 DECLARATOR_TYPELOC(BlockPointerLoc, BlockPointerType)
index fbd7caa3268e4f8ef7de07e9bc2264b78b816538..1337def2a0508a3b4a2d48018dd3882d05d99e9b 100644 (file)
@@ -229,6 +229,24 @@ bool TypedefLoc::classof(const TypeLoc *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
 //===----------------------------------------------------------------------===//
index 550f4dba79907315d5db55327ff528f1e883df59..9b28e8bac79c1142fea1d1e012edf4d6172d8d47 100644 (file)
@@ -179,6 +179,9 @@ void TypeLocReader::VisitDefaultTypeSpecLoc(DefaultTypeSpecLoc TyLoc) {
 void TypeLocReader::VisitTypedefLoc(TypedefLoc TyLoc) {
   TyLoc.setNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
 }
+void TypeLocReader::VisitObjCInterfaceLoc(ObjCInterfaceLoc TyLoc) {
+  TyLoc.setNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
+}
 void TypeLocReader::VisitObjCProtocolListLoc(ObjCProtocolListLoc TyLoc) {
   TyLoc.setLAngleLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
   TyLoc.setRAngleLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
index 7a8f3e85021255d1ee9c032393211a2b8174dcfa..9573d43c7173c2eb636687a1941c33039d3db8d6 100644 (file)
@@ -177,6 +177,9 @@ void TypeLocWriter::VisitDefaultTypeSpecLoc(DefaultTypeSpecLoc TyLoc) {
 void TypeLocWriter::VisitTypedefLoc(TypedefLoc TyLoc) {
   Writer.AddSourceLocation(TyLoc.getNameLoc(), Record);
 }
+void TypeLocWriter::VisitObjCInterfaceLoc(ObjCInterfaceLoc TyLoc) {
+  Writer.AddSourceLocation(TyLoc.getNameLoc(), Record);
+}
 void TypeLocWriter::VisitObjCProtocolListLoc(ObjCProtocolListLoc TyLoc) {
   Writer.AddSourceLocation(TyLoc.getLAngleLoc(), Record);
   Writer.AddSourceLocation(TyLoc.getRAngleLoc(), Record);
index 89e9e4942b5a8b063e5f20445442e15edd0c629f..333895b6c09a08321d68ebce3a0990ffd1a8c885 100644 (file)
@@ -1299,6 +1299,9 @@ static void FillTypeSpecLoc(TypeLoc TSL, const DeclSpec &DS) {
   if (TypedefLoc *TL = dyn_cast<TypedefLoc>(&TSL)) {
     TL->setNameLoc(DS.getTypeSpecTypeLoc());
 
+  } else if (ObjCInterfaceLoc *TL = dyn_cast<ObjCInterfaceLoc>(&TSL)) {
+    TL->setNameLoc(DS.getTypeSpecTypeLoc());
+
   } else if (ObjCProtocolListLoc *PLL = dyn_cast<ObjCProtocolListLoc>(&TSL)) {
     assert(PLL->getNumProtocols() == DS.getNumProtocolQualifiers());
     PLL->setLAngleLoc(DS.getProtocolLAngleLoc());