[cfe-commits] r83097 - in /cfe/trunk: 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

Argiris Kirtzidis akyrtzi at gmail.com
Tue Sep 29 12:45:23 PDT 2009


Author: akirtzidis
Date: Tue Sep 29 14:45:22 2009
New Revision: 83097

URL: http://llvm.org/viewvc/llvm-project?rev=83097&view=rev
Log:
Introduce ObjCInterfaceLoc which provides type source information for ObjC interfaces.

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

Modified: cfe/trunk/include/clang/AST/TypeLoc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=83097&r1=83096&r2=83097&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/TypeLoc.h (original)
+++ cfe/trunk/include/clang/AST/TypeLoc.h Tue Sep 29 14:45:22 2009
@@ -154,6 +154,38 @@
   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 {

Modified: cfe/trunk/include/clang/AST/TypeLocNodes.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLocNodes.def?rev=83097&r1=83096&r2=83097&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/TypeLocNodes.def (original)
+++ cfe/trunk/include/clang/AST/TypeLocNodes.def Tue Sep 29 14:45:22 2009
@@ -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)

Modified: cfe/trunk/lib/AST/TypeLoc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypeLoc.cpp?rev=83097&r1=83096&r2=83097&view=diff

==============================================================================
--- cfe/trunk/lib/AST/TypeLoc.cpp (original)
+++ cfe/trunk/lib/AST/TypeLoc.cpp Tue Sep 29 14:45:22 2009
@@ -230,6 +230,24 @@
 }
 
 //===----------------------------------------------------------------------===//
+// 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
 //===----------------------------------------------------------------------===//
 

Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=83097&r1=83096&r2=83097&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Tue Sep 29 14:45:22 2009
@@ -179,6 +179,9 @@
 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++]));

Modified: cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterDecl.cpp?rev=83097&r1=83096&r2=83097&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterDecl.cpp Tue Sep 29 14:45:22 2009
@@ -177,6 +177,9 @@
 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);

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=83097&r1=83096&r2=83097&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Sep 29 14:45:22 2009
@@ -1299,6 +1299,9 @@
   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());





More information about the cfe-commits mailing list