PropertyDecl,
// ScopedDecl
// TypeDecl
- ObjCInterface,
Typedef,
// TagDecl
Enum,
BlockVar,
FileVar,
ParmVar,
+ ObjCInterface,
ObjCCompatibleAlias,
ObjCMethod,
ObjCClass,
// of the class, to allow efficient classof.
NamedFirst = Field, NamedLast = ParmVar,
FieldFirst = Field, FieldLast = ObjCIvar,
- ScopedFirst = ObjCInterface, ScopedLast = ParmVar,
- TypeFirst = ObjCInterface, TypeLast = Class,
+ ScopedFirst = Typedef, ScopedLast = ParmVar,
+ TypeFirst = Typedef, TypeLast = Class,
TagFirst = Enum , TagLast = Class,
RecordFirst = Struct , RecordLast = Class,
ValueFirst = EnumConstant , ValueLast = ParmVar,
/// Unlike C++, ObjC is a single-rooted class model. In Cocoa, classes
/// typically inherit from NSObject (an exception is NSProxy).
///
-class ObjCInterfaceDecl : public TypeDecl {
+class ObjCInterfaceDecl : public NamedDecl {
+ /// TypeForDecl - This indicates the Type object that represents this
+ /// TypeDecl. It is a cache maintained by ASTContext::getObjCInterfaceType
+ Type *TypeForDecl;
+ friend class ASTContext;
/// Class's super class.
ObjCInterfaceDecl *SuperClass;
ObjCInterfaceDecl(SourceLocation atLoc, unsigned numRefProtos,
IdentifierInfo *Id, bool FD, bool isInternal)
- : TypeDecl(ObjCInterface, atLoc, Id, 0), SuperClass(0),
+ : NamedDecl(ObjCInterface, atLoc, Id), TypeForDecl(0), SuperClass(0),
ReferencedProtocols(0), NumReferencedProtocols(0), Ivars(0),
NumIvars(0),
InstanceMethods(0), NumInstanceMethods(0),
DISPATCH_CASE(Union,RecordDecl) // FIXME: Refine.
DISPATCH_CASE(Class,RecordDecl) // FIXME: Refine.
DISPATCH_CASE(Enum,EnumDecl)
- DISPATCH_CASE(ObjCInterface,ObjCInterfaceDecl)
default:
assert(false && "Subtype of ScopedDecl not handled.");
}
/// with @protocol keyword, so that we can emit errors on duplicates and
/// find the declarations when needed.
llvm::DenseMap<IdentifierInfo*, ObjCProtocolDecl*> ObjCProtocols;
-
+
+ /// ObjCInterfaceDecls - Keep track of all class declarations declared
+ /// with @interface, so that we can emit errors on duplicates and
+ /// find the declarations when needed.
+ typedef llvm::DenseMap<const IdentifierInfo*,
+ ObjCInterfaceDecl*> ObjCInterfaceDeclsTy;
+ ObjCInterfaceDeclsTy ObjCInterfaceDecls;
+
/// ObjCAliasDecls - Keep track of all class declarations declared
/// with @compatibility_alias, so that we can emit errors on duplicates and
/// find the declarations when needed. This construct is ancient and will
typedef llvm::DenseMap<const IdentifierInfo*,
ObjCCompatibleAliasDecl*> ObjCAliasTy;
ObjCAliasTy ObjCAliasDecls;
-
+
// Enum values used by KnownFunctionIDs (see below).
enum {
id_printf,
/// getObjCInterfaceDecl - Look up a for a class declaration in the scope.
/// return 0 if one not found.
-/// FIXME: removed this when ObjCInterfaceDecl's aren't ScopedDecl's.
ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *Id) {
- ScopedDecl *IDecl;
- // Scan up the scope chain looking for a decl that matches this identifier
- // that is in the appropriate namespace.
- for (IDecl = Id->getFETokenInfo<ScopedDecl>(); IDecl;
- IDecl = IDecl->getNext())
- if (IDecl->getIdentifierNamespace() == Decl::IDNS_Ordinary)
- break;
-
- if (ObjCCompatibleAliasDecl *ADecl =
- dyn_cast_or_null<ObjCCompatibleAliasDecl>(IDecl))
- return ADecl->getClassInterface();
+ // The third "scope" argument is 0 since we aren't enabling lazy built-in
+ // creation from this context.
+ Decl *IDecl = LookupDecl(Id, Decl::IDNS_Ordinary, 0, false);
+
return dyn_cast_or_null<ObjCInterfaceDecl>(IDecl);
}
// Unlike typedef's, they can only be introduced at file-scope (and are
// therefore not scoped decls). They can, however, be shadowed by
// other names in IDNS_Ordinary.
+ ObjCInterfaceDeclsTy::iterator IDI = ObjCInterfaceDecls.find(II);
+ if (IDI != ObjCInterfaceDecls.end())
+ return IDI->second;
ObjCAliasTy::iterator I = ObjCAliasDecls.find(II);
if (I != ObjCAliasDecls.end())
return I->second->getClassInterface();
IDecl = ObjCInterfaceDecl::Create(Context, AtInterfaceLoc, NumProtocols,
ClassName);
- // Chain & install the interface decl into the identifier.
- IDecl->setNext(ClassName->getFETokenInfo<ScopedDecl>());
- ClassName->setFETokenInfo(IDecl);
-
+ ObjCInterfaceDecls[ClassName] = IDecl;
// Remember that this needs to be removed when the scope is popped.
TUScope->AddDecl(IDecl);
}
// Build, chain & install the interface decl into the identifier.
IDecl = ObjCInterfaceDecl::Create(Context, AtClassImplLoc, 0, ClassName,
false, true);
- IDecl->setNext(ClassName->getFETokenInfo<ScopedDecl>());
- ClassName->setFETokenInfo(IDecl);
+ ObjCInterfaceDecls[ClassName] = IDecl;
IDecl->setSuperClass(SDecl);
IDecl->setLocEnd(ClassLoc);
if (!IDecl) { // Not already seen? Make a forward decl.
IDecl = ObjCInterfaceDecl::Create(Context, AtClassLoc, 0, IdentList[i],
true);
- // Chain & install the interface decl into the identifier.
- IDecl->setNext(IdentList[i]->getFETokenInfo<ScopedDecl>());
- IdentList[i]->setFETokenInfo(IDecl);
+ ObjCInterfaceDecls[IdentList[i]] = IDecl;
// Remember that this needs to be removed when the scope is popped.
TUScope->AddDecl(IDecl);
typedef int Gorf; // expected-error {{previous definition is here}}
-@interface Gorf @end // expected-error {{redefinition of 'Gorf' as different kind of symbol}} \
- // expected-error {{previous definition is here}}
+@interface Gorf @end // expected-error {{redefinition of 'Gorf' as different kind of symbol}}
void Gorf() // expected-error {{redefinition of 'Gorf' as different kind of symbol}}
{