forked from OSchip/llvm-project
Feed proper source-location information into Sema::LookupSingleResult,
in case it ends up doing something that might trigger diagnostics (template instantiation, ambiguity reporting, access reporting). Noticed while working on PR6831. llvm-svn: 101412
This commit is contained in:
parent
f7f97b4bbd
commit
b2ccf010fb
|
@ -2798,7 +2798,8 @@ public:
|
|||
///
|
||||
/// \param ClassName the name of the class being defined.
|
||||
virtual void CodeCompleteObjCSuperclass(Scope *S,
|
||||
IdentifierInfo *ClassName) {
|
||||
IdentifierInfo *ClassName,
|
||||
SourceLocation ClassNameLoc) {
|
||||
}
|
||||
|
||||
/// \brief Code completion for an Objective-C implementation, after the
|
||||
|
@ -2811,7 +2812,8 @@ public:
|
|||
/// This code completion action is invoked after the '(' that indicates
|
||||
/// a category name within an Objective-C interface declaration.
|
||||
virtual void CodeCompleteObjCInterfaceCategory(Scope *S,
|
||||
IdentifierInfo *ClassName) {
|
||||
IdentifierInfo *ClassName,
|
||||
SourceLocation ClassNameLoc) {
|
||||
}
|
||||
|
||||
/// \brief Code completion for the category name in an Objective-C category
|
||||
|
@ -2820,7 +2822,8 @@ public:
|
|||
/// This code completion action is invoked after the '(' that indicates
|
||||
/// the category name within an Objective-C category implementation.
|
||||
virtual void CodeCompleteObjCImplementationCategory(Scope *S,
|
||||
IdentifierInfo *ClassName) {
|
||||
IdentifierInfo *ClassName,
|
||||
SourceLocation ClassNameLoc) {
|
||||
}
|
||||
|
||||
/// \brief Code completion for the property names when defining an
|
||||
|
|
|
@ -148,7 +148,7 @@ Parser::DeclPtrTy Parser::ParseObjCAtInterfaceDeclaration(
|
|||
SourceLocation categoryLoc, rparenLoc;
|
||||
IdentifierInfo *categoryId = 0;
|
||||
if (Tok.is(tok::code_completion)) {
|
||||
Actions.CodeCompleteObjCInterfaceCategory(CurScope, nameId);
|
||||
Actions.CodeCompleteObjCInterfaceCategory(CurScope, nameId, nameLoc);
|
||||
ConsumeToken();
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ Parser::DeclPtrTy Parser::ParseObjCAtInterfaceDeclaration(
|
|||
|
||||
// Code completion of superclass names.
|
||||
if (Tok.is(tok::code_completion)) {
|
||||
Actions.CodeCompleteObjCSuperclass(CurScope, nameId);
|
||||
Actions.CodeCompleteObjCSuperclass(CurScope, nameId, nameLoc);
|
||||
ConsumeToken();
|
||||
}
|
||||
|
||||
|
@ -1229,7 +1229,7 @@ Parser::DeclPtrTy Parser::ParseObjCAtImplementationDeclaration(
|
|||
IdentifierInfo *categoryId = 0;
|
||||
|
||||
if (Tok.is(tok::code_completion)) {
|
||||
Actions.CodeCompleteObjCImplementationCategory(CurScope, nameId);
|
||||
Actions.CodeCompleteObjCImplementationCategory(CurScope, nameId, nameLoc);
|
||||
ConsumeToken();
|
||||
}
|
||||
|
||||
|
|
|
@ -1406,6 +1406,7 @@ public:
|
|||
/// It is preferable to use the elaborated form and explicitly handle
|
||||
/// ambiguity and overloaded.
|
||||
NamedDecl *LookupSingleName(Scope *S, DeclarationName Name,
|
||||
SourceLocation Loc,
|
||||
LookupNameKind NameKind,
|
||||
RedeclarationKind Redecl
|
||||
= NotForRedeclaration);
|
||||
|
@ -1416,7 +1417,7 @@ public:
|
|||
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS,
|
||||
bool AllowBuiltinCreation = false,
|
||||
bool EnteringContext = false);
|
||||
ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II);
|
||||
ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc);
|
||||
|
||||
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
|
||||
QualType T1, QualType T2,
|
||||
|
@ -1468,7 +1469,8 @@ public:
|
|||
//@}
|
||||
|
||||
ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *&Id,
|
||||
SourceLocation RecoverLoc = SourceLocation());
|
||||
SourceLocation IdLoc,
|
||||
bool TypoCorrection = false);
|
||||
NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
|
||||
Scope *S, bool ForRedeclaration,
|
||||
SourceLocation Loc);
|
||||
|
@ -4338,12 +4340,15 @@ public:
|
|||
virtual void CodeCompleteObjCProtocolDecl(Scope *S);
|
||||
virtual void CodeCompleteObjCInterfaceDecl(Scope *S);
|
||||
virtual void CodeCompleteObjCSuperclass(Scope *S,
|
||||
IdentifierInfo *ClassName);
|
||||
IdentifierInfo *ClassName,
|
||||
SourceLocation ClassNameLoc);
|
||||
virtual void CodeCompleteObjCImplementationDecl(Scope *S);
|
||||
virtual void CodeCompleteObjCInterfaceCategory(Scope *S,
|
||||
IdentifierInfo *ClassName);
|
||||
IdentifierInfo *ClassName,
|
||||
SourceLocation ClassNameLoc);
|
||||
virtual void CodeCompleteObjCImplementationCategory(Scope *S,
|
||||
IdentifierInfo *ClassName);
|
||||
IdentifierInfo *ClassName,
|
||||
SourceLocation ClassNameLoc);
|
||||
virtual void CodeCompleteObjCPropertyDefinition(Scope *S,
|
||||
DeclPtrTy ObjCImpDecl);
|
||||
virtual void CodeCompleteObjCPropertySynthesizeIvar(Scope *S,
|
||||
|
|
|
@ -3181,7 +3181,8 @@ void Sema::CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
|
|||
// Tell the result set to ignore all of the protocols we have
|
||||
// already seen.
|
||||
for (unsigned I = 0; I != NumProtocols; ++I)
|
||||
if (ObjCProtocolDecl *Protocol = LookupProtocol(Protocols[I].first))
|
||||
if (ObjCProtocolDecl *Protocol = LookupProtocol(Protocols[I].first,
|
||||
Protocols[I].second))
|
||||
Results.Ignore(Protocol);
|
||||
|
||||
// Add all protocols.
|
||||
|
@ -3245,13 +3246,14 @@ void Sema::CodeCompleteObjCInterfaceDecl(Scope *S) {
|
|||
HandleCodeCompleteResults(this, CodeCompleter, Results.data(),Results.size());
|
||||
}
|
||||
|
||||
void Sema::CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName) {
|
||||
void Sema::CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName,
|
||||
SourceLocation ClassNameLoc) {
|
||||
ResultBuilder Results(*this);
|
||||
Results.EnterNewScope();
|
||||
|
||||
// Make sure that we ignore the class we're currently defining.
|
||||
NamedDecl *CurClass
|
||||
= LookupSingleName(TUScope, ClassName, LookupOrdinaryName);
|
||||
= LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
|
||||
if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
|
||||
Results.Ignore(CurClass);
|
||||
|
||||
|
@ -3276,7 +3278,8 @@ void Sema::CodeCompleteObjCImplementationDecl(Scope *S) {
|
|||
}
|
||||
|
||||
void Sema::CodeCompleteObjCInterfaceCategory(Scope *S,
|
||||
IdentifierInfo *ClassName) {
|
||||
IdentifierInfo *ClassName,
|
||||
SourceLocation ClassNameLoc) {
|
||||
typedef CodeCompleteConsumer::Result Result;
|
||||
|
||||
ResultBuilder Results(*this);
|
||||
|
@ -3285,7 +3288,7 @@ void Sema::CodeCompleteObjCInterfaceCategory(Scope *S,
|
|||
// interface.
|
||||
llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
|
||||
NamedDecl *CurClass
|
||||
= LookupSingleName(TUScope, ClassName, LookupOrdinaryName);
|
||||
= LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
|
||||
if (ObjCInterfaceDecl *Class = dyn_cast_or_null<ObjCInterfaceDecl>(CurClass))
|
||||
for (ObjCCategoryDecl *Category = Class->getCategoryList(); Category;
|
||||
Category = Category->getNextClassCategory())
|
||||
|
@ -3306,17 +3309,18 @@ void Sema::CodeCompleteObjCInterfaceCategory(Scope *S,
|
|||
}
|
||||
|
||||
void Sema::CodeCompleteObjCImplementationCategory(Scope *S,
|
||||
IdentifierInfo *ClassName) {
|
||||
IdentifierInfo *ClassName,
|
||||
SourceLocation ClassNameLoc) {
|
||||
typedef CodeCompleteConsumer::Result Result;
|
||||
|
||||
// Find the corresponding interface. If we couldn't find the interface, the
|
||||
// program itself is ill-formed. However, we'll try to be helpful still by
|
||||
// providing the list of all of the categories we know about.
|
||||
NamedDecl *CurClass
|
||||
= LookupSingleName(TUScope, ClassName, LookupOrdinaryName);
|
||||
= LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
|
||||
ObjCInterfaceDecl *Class = dyn_cast_or_null<ObjCInterfaceDecl>(CurClass);
|
||||
if (!Class)
|
||||
return CodeCompleteObjCInterfaceCategory(S, ClassName);
|
||||
return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
|
||||
|
||||
ResultBuilder Results(*this);
|
||||
|
||||
|
|
|
@ -588,32 +588,35 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) {
|
|||
}
|
||||
}
|
||||
|
||||
/// getObjCInterfaceDecl - Look up a for a class declaration in the scope.
|
||||
/// return 0 if one not found.
|
||||
/// \brief Look for an Objective-C class in the translation unit.
|
||||
///
|
||||
/// \param Id the name of the Objective-C class we're looking for. If
|
||||
/// \param Id The name of the Objective-C class we're looking for. If
|
||||
/// typo-correction fixes this name, the Id will be updated
|
||||
/// to the fixed name.
|
||||
///
|
||||
/// \param RecoverLoc if provided, this routine will attempt to
|
||||
/// recover from a typo in the name of an existing Objective-C class
|
||||
/// and, if successful, will return the lookup that results from
|
||||
/// typo-correction.
|
||||
/// \param IdLoc The location of the name in the translation unit.
|
||||
///
|
||||
/// \param TypoCorrection If true, this routine will attempt typo correction
|
||||
/// if there is no class with the given name.
|
||||
///
|
||||
/// \returns The declaration of the named Objective-C class, or NULL if the
|
||||
/// class could not be found.
|
||||
ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *&Id,
|
||||
SourceLocation RecoverLoc) {
|
||||
SourceLocation IdLoc,
|
||||
bool TypoCorrection) {
|
||||
// The third "scope" argument is 0 since we aren't enabling lazy built-in
|
||||
// creation from this context.
|
||||
NamedDecl *IDecl = LookupSingleName(TUScope, Id, LookupOrdinaryName);
|
||||
NamedDecl *IDecl = LookupSingleName(TUScope, Id, IdLoc, LookupOrdinaryName);
|
||||
|
||||
if (!IDecl && !RecoverLoc.isInvalid()) {
|
||||
if (!IDecl && TypoCorrection) {
|
||||
// Perform typo correction at the given location, but only if we
|
||||
// find an Objective-C class name.
|
||||
LookupResult R(*this, Id, RecoverLoc, LookupOrdinaryName);
|
||||
LookupResult R(*this, Id, IdLoc, LookupOrdinaryName);
|
||||
if (CorrectTypo(R, TUScope, 0, 0, false, CTC_NoKeywords) &&
|
||||
(IDecl = R.getAsSingle<ObjCInterfaceDecl>())) {
|
||||
Diag(RecoverLoc, diag::err_undef_interface_suggest)
|
||||
Diag(IdLoc, diag::err_undef_interface_suggest)
|
||||
<< Id << IDecl->getDeclName()
|
||||
<< FixItHint::CreateReplacement(RecoverLoc, IDecl->getNameAsString());
|
||||
<< FixItHint::CreateReplacement(IdLoc, IDecl->getNameAsString());
|
||||
Diag(IDecl->getLocation(), diag::note_previous_decl)
|
||||
<< IDecl->getDeclName();
|
||||
|
||||
|
@ -661,7 +664,8 @@ void Sema::InitBuiltinVaListType() {
|
|||
return;
|
||||
|
||||
IdentifierInfo *VaIdent = &Context.Idents.get("__builtin_va_list");
|
||||
NamedDecl *VaDecl = LookupSingleName(TUScope, VaIdent, LookupOrdinaryName);
|
||||
NamedDecl *VaDecl = LookupSingleName(TUScope, VaIdent, SourceLocation(),
|
||||
LookupOrdinaryName, ForRedeclaration);
|
||||
TypedefDecl *VaTypedef = cast<TypedefDecl>(VaDecl);
|
||||
Context.setBuiltinVaListType(Context.getTypedefType(VaTypedef));
|
||||
}
|
||||
|
@ -5413,7 +5417,7 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record,
|
|||
if (D.getDeclSpec().isThreadSpecified())
|
||||
Diag(D.getDeclSpec().getThreadSpecLoc(), diag::err_invalid_thread);
|
||||
|
||||
NamedDecl *PrevDecl = LookupSingleName(S, II, LookupMemberName,
|
||||
NamedDecl *PrevDecl = LookupSingleName(S, II, Loc, LookupMemberName,
|
||||
ForRedeclaration);
|
||||
|
||||
if (PrevDecl && PrevDecl->isTemplateParameter()) {
|
||||
|
@ -5814,7 +5818,7 @@ Sema::DeclPtrTy Sema::ActOnIvar(Scope *S,
|
|||
TInfo, ac, (Expr *)BitfieldWidth);
|
||||
|
||||
if (II) {
|
||||
NamedDecl *PrevDecl = LookupSingleName(S, II, LookupMemberName,
|
||||
NamedDecl *PrevDecl = LookupSingleName(S, II, Loc, LookupMemberName,
|
||||
ForRedeclaration);
|
||||
if (PrevDecl && isDeclInScope(PrevDecl, EnclosingContext, S)
|
||||
&& !isa<TagDecl>(PrevDecl)) {
|
||||
|
@ -6187,7 +6191,7 @@ Sema::DeclPtrTy Sema::ActOnEnumConstant(Scope *S, DeclPtrTy theEnumDecl,
|
|||
|
||||
// Verify that there isn't already something declared with this name in this
|
||||
// scope.
|
||||
NamedDecl *PrevDecl = LookupSingleName(S, Id, LookupOrdinaryName,
|
||||
NamedDecl *PrevDecl = LookupSingleName(S, Id, IdLoc, LookupOrdinaryName,
|
||||
ForRedeclaration);
|
||||
if (PrevDecl && PrevDecl->isTemplateParameter()) {
|
||||
// Maybe we will complain about the shadowed template parameter.
|
||||
|
@ -6439,7 +6443,7 @@ Sema::DeclPtrTy Sema::ActOnFileScopeAsmDecl(SourceLocation Loc,
|
|||
void Sema::ActOnPragmaWeakID(IdentifierInfo* Name,
|
||||
SourceLocation PragmaLoc,
|
||||
SourceLocation NameLoc) {
|
||||
Decl *PrevDecl = LookupSingleName(TUScope, Name, LookupOrdinaryName);
|
||||
Decl *PrevDecl = LookupSingleName(TUScope, Name, NameLoc, LookupOrdinaryName);
|
||||
|
||||
if (PrevDecl) {
|
||||
PrevDecl->addAttr(::new (Context) WeakAttr());
|
||||
|
@ -6455,7 +6459,8 @@ void Sema::ActOnPragmaWeakAlias(IdentifierInfo* Name,
|
|||
SourceLocation PragmaLoc,
|
||||
SourceLocation NameLoc,
|
||||
SourceLocation AliasNameLoc) {
|
||||
Decl *PrevDecl = LookupSingleName(TUScope, AliasName, LookupOrdinaryName);
|
||||
Decl *PrevDecl = LookupSingleName(TUScope, AliasName, AliasNameLoc,
|
||||
LookupOrdinaryName);
|
||||
WeakInfo W = WeakInfo(Name, NameLoc);
|
||||
|
||||
if (PrevDecl) {
|
||||
|
|
|
@ -1025,8 +1025,11 @@ static void HandleCleanupAttr(Decl *d, const AttributeList &Attr, Sema &S) {
|
|||
}
|
||||
|
||||
// Look up the function
|
||||
// FIXME: Lookup probably isn't looking in the right place
|
||||
// FIXME: The lookup source location should be in the attribute, not the
|
||||
// start of the attribute.
|
||||
NamedDecl *CleanupDecl
|
||||
= S.LookupSingleName(S.TUScope, Attr.getParameterName(),
|
||||
= S.LookupSingleName(S.TUScope, Attr.getParameterName(), Attr.getLoc(),
|
||||
Sema::LookupOrdinaryName);
|
||||
if (!CleanupDecl) {
|
||||
S.Diag(Attr.getLoc(), diag::err_attribute_cleanup_arg_not_found) <<
|
||||
|
|
|
@ -3018,7 +3018,7 @@ Sema::DeclPtrTy Sema::ActOnStartNamespaceDef(Scope *NamespcScope,
|
|||
// in that declarative region, it is treated as an original-namespace-name.
|
||||
|
||||
NamedDecl *PrevDecl
|
||||
= LookupSingleName(DeclRegionScope, II, LookupOrdinaryName,
|
||||
= LookupSingleName(DeclRegionScope, II, IdentLoc, LookupOrdinaryName,
|
||||
ForRedeclaration);
|
||||
|
||||
if (NamespaceDecl *OrigNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl)) {
|
||||
|
@ -3842,7 +3842,8 @@ Sema::DeclPtrTy Sema::ActOnNamespaceAliasDef(Scope *S,
|
|||
|
||||
// Check if we have a previous declaration with the same name.
|
||||
if (NamedDecl *PrevDecl
|
||||
= LookupSingleName(S, Alias, LookupOrdinaryName, ForRedeclaration)) {
|
||||
= LookupSingleName(S, Alias, AliasLoc, LookupOrdinaryName,
|
||||
ForRedeclaration)) {
|
||||
if (NamespaceAliasDecl *AD = dyn_cast<NamespaceAliasDecl>(PrevDecl)) {
|
||||
// We already have an alias with the same name that points to the same
|
||||
// namespace, so don't create a new one.
|
||||
|
@ -4935,7 +4936,8 @@ Sema::DeclPtrTy Sema::ActOnExceptionDeclarator(Scope *S, Declarator &D) {
|
|||
|
||||
bool Invalid = D.isInvalidType();
|
||||
IdentifierInfo *II = D.getIdentifier();
|
||||
if (NamedDecl *PrevDecl = LookupSingleName(S, II, LookupOrdinaryName)) {
|
||||
if (NamedDecl *PrevDecl = LookupSingleName(S, II, D.getIdentifierLoc(),
|
||||
LookupOrdinaryName)) {
|
||||
// The scope should be freshly made just for us. There is just no way
|
||||
// it contains any previous declaration.
|
||||
assert(!S->isDeclScope(DeclPtrTy::make(PrevDecl)));
|
||||
|
|
|
@ -66,7 +66,8 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
|
|||
assert(ClassName && "Missing class identifier");
|
||||
|
||||
// Check for another declaration kind with the same name.
|
||||
NamedDecl *PrevDecl = LookupSingleName(TUScope, ClassName, LookupOrdinaryName);
|
||||
NamedDecl *PrevDecl = LookupSingleName(TUScope, ClassName, ClassLoc,
|
||||
LookupOrdinaryName);
|
||||
if (PrevDecl && PrevDecl->isTemplateParameter()) {
|
||||
// Maybe we will complain about the shadowed template parameter.
|
||||
DiagnoseTemplateParameterShadow(ClassLoc, PrevDecl);
|
||||
|
@ -115,7 +116,8 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
|
|||
|
||||
if (SuperName) {
|
||||
// Check if a different kind of symbol declared in this scope.
|
||||
PrevDecl = LookupSingleName(TUScope, SuperName, LookupOrdinaryName);
|
||||
PrevDecl = LookupSingleName(TUScope, SuperName, SuperLoc,
|
||||
LookupOrdinaryName);
|
||||
|
||||
if (!PrevDecl) {
|
||||
// Try to correct for a typo in the superclass name.
|
||||
|
@ -199,7 +201,8 @@ Sema::DeclPtrTy Sema::ActOnCompatiblityAlias(SourceLocation AtLoc,
|
|||
IdentifierInfo *ClassName,
|
||||
SourceLocation ClassLocation) {
|
||||
// Look for previous declaration of alias name
|
||||
NamedDecl *ADecl = LookupSingleName(TUScope, AliasName, LookupOrdinaryName);
|
||||
NamedDecl *ADecl = LookupSingleName(TUScope, AliasName, AliasLocation,
|
||||
LookupOrdinaryName);
|
||||
if (ADecl) {
|
||||
if (isa<ObjCCompatibleAliasDecl>(ADecl))
|
||||
Diag(AliasLocation, diag::warn_previous_alias_decl);
|
||||
|
@ -209,13 +212,15 @@ Sema::DeclPtrTy Sema::ActOnCompatiblityAlias(SourceLocation AtLoc,
|
|||
return DeclPtrTy();
|
||||
}
|
||||
// Check for class declaration
|
||||
NamedDecl *CDeclU = LookupSingleName(TUScope, ClassName, LookupOrdinaryName);
|
||||
NamedDecl *CDeclU = LookupSingleName(TUScope, ClassName, ClassLocation,
|
||||
LookupOrdinaryName);
|
||||
if (const TypedefDecl *TDecl = dyn_cast_or_null<TypedefDecl>(CDeclU)) {
|
||||
QualType T = TDecl->getUnderlyingType();
|
||||
if (T->isObjCInterfaceType()) {
|
||||
if (NamedDecl *IDecl = T->getAs<ObjCInterfaceType>()->getDecl()) {
|
||||
ClassName = IDecl->getIdentifier();
|
||||
CDeclU = LookupSingleName(TUScope, ClassName, LookupOrdinaryName);
|
||||
CDeclU = LookupSingleName(TUScope, ClassName, ClassLocation,
|
||||
LookupOrdinaryName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -244,7 +249,8 @@ void Sema::CheckForwardProtocolDeclarationForCircularDependency(
|
|||
for (ObjCList<ObjCProtocolDecl>::iterator I = PList.begin(),
|
||||
E = PList.end(); I != E; ++I) {
|
||||
|
||||
if (ObjCProtocolDecl *PDecl = LookupProtocol((*I)->getIdentifier())) {
|
||||
if (ObjCProtocolDecl *PDecl = LookupProtocol((*I)->getIdentifier(),
|
||||
Ploc)) {
|
||||
if (PDecl->getIdentifier() == PName) {
|
||||
Diag(Ploc, diag::err_protocol_has_circular_dependency);
|
||||
Diag(PrevLoc, diag::note_previous_definition);
|
||||
|
@ -266,7 +272,7 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc,
|
|||
AttributeList *AttrList) {
|
||||
// FIXME: Deal with AttrList.
|
||||
assert(ProtocolName && "Missing protocol identifier");
|
||||
ObjCProtocolDecl *PDecl = LookupProtocol(ProtocolName);
|
||||
ObjCProtocolDecl *PDecl = LookupProtocol(ProtocolName, ProtocolLoc);
|
||||
if (PDecl) {
|
||||
// Protocol already seen. Better be a forward protocol declaration
|
||||
if (!PDecl->isForwardDecl()) {
|
||||
|
@ -313,7 +319,8 @@ Sema::FindProtocolDeclaration(bool WarnOnDeclarations,
|
|||
unsigned NumProtocols,
|
||||
llvm::SmallVectorImpl<DeclPtrTy> &Protocols) {
|
||||
for (unsigned i = 0; i != NumProtocols; ++i) {
|
||||
ObjCProtocolDecl *PDecl = LookupProtocol(ProtocolId[i].first);
|
||||
ObjCProtocolDecl *PDecl = LookupProtocol(ProtocolId[i].first,
|
||||
ProtocolId[i].second);
|
||||
if (!PDecl) {
|
||||
LookupResult R(*this, ProtocolId[i].first, ProtocolId[i].second,
|
||||
LookupObjCProtocolName);
|
||||
|
@ -383,7 +390,7 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
|
|||
|
||||
for (unsigned i = 0; i != NumElts; ++i) {
|
||||
IdentifierInfo *Ident = IdentList[i].first;
|
||||
ObjCProtocolDecl *PDecl = LookupProtocol(Ident);
|
||||
ObjCProtocolDecl *PDecl = LookupProtocol(Ident, IdentList[i].second);
|
||||
if (PDecl == 0) { // Not already seen?
|
||||
PDecl = ObjCProtocolDecl::Create(Context, CurContext,
|
||||
IdentList[i].second, Ident);
|
||||
|
@ -414,7 +421,7 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
|
|||
const SourceLocation *ProtoLocs,
|
||||
SourceLocation EndProtoLoc) {
|
||||
ObjCCategoryDecl *CDecl = 0;
|
||||
ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName, ClassLoc);
|
||||
ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName, ClassLoc, true);
|
||||
|
||||
/// Check that class of this category is already completely declared.
|
||||
if (!IDecl || IDecl->isForwardDecl()) {
|
||||
|
@ -492,7 +499,7 @@ Sema::DeclPtrTy Sema::ActOnStartCategoryImplementation(
|
|||
SourceLocation AtCatImplLoc,
|
||||
IdentifierInfo *ClassName, SourceLocation ClassLoc,
|
||||
IdentifierInfo *CatName, SourceLocation CatLoc) {
|
||||
ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName, ClassLoc);
|
||||
ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName, ClassLoc, true);
|
||||
ObjCCategoryDecl *CatIDecl = 0;
|
||||
if (IDecl) {
|
||||
CatIDecl = IDecl->FindCategoryDeclaration(CatName);
|
||||
|
@ -540,7 +547,7 @@ Sema::DeclPtrTy Sema::ActOnStartClassImplementation(
|
|||
ObjCInterfaceDecl* IDecl = 0;
|
||||
// Check for another declaration kind with the same name.
|
||||
NamedDecl *PrevDecl
|
||||
= LookupSingleName(TUScope, ClassName, LookupOrdinaryName);
|
||||
= LookupSingleName(TUScope, ClassName, ClassLoc, LookupOrdinaryName);
|
||||
if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
|
||||
Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
|
||||
Diag(PrevDecl->getLocation(), diag::note_previous_definition);
|
||||
|
@ -577,7 +584,8 @@ Sema::DeclPtrTy Sema::ActOnStartClassImplementation(
|
|||
ObjCInterfaceDecl* SDecl = 0;
|
||||
if (SuperClassname) {
|
||||
// Check if a different kind of symbol declared in this scope.
|
||||
PrevDecl = LookupSingleName(TUScope, SuperClassname, LookupOrdinaryName);
|
||||
PrevDecl = LookupSingleName(TUScope, SuperClassname, SuperClassLoc,
|
||||
LookupOrdinaryName);
|
||||
if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
|
||||
Diag(SuperClassLoc, diag::err_redefinition_different_kind)
|
||||
<< SuperClassname;
|
||||
|
@ -1004,7 +1012,8 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
|
|||
for (unsigned i = 0; i != NumElts; ++i) {
|
||||
// Check for another declaration kind with the same name.
|
||||
NamedDecl *PrevDecl
|
||||
= LookupSingleName(TUScope, IdentList[i], LookupOrdinaryName);
|
||||
= LookupSingleName(TUScope, IdentList[i], IdentLocs[i],
|
||||
LookupOrdinaryName);
|
||||
if (PrevDecl && PrevDecl->isTemplateParameter()) {
|
||||
// Maybe we will complain about the shadowed template parameter.
|
||||
DiagnoseTemplateParameterShadow(AtClassLoc, PrevDecl);
|
||||
|
@ -1659,7 +1668,7 @@ void Sema::ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
|
|||
IdentifierInfo *ClassName,
|
||||
llvm::SmallVectorImpl<DeclPtrTy> &Decls) {
|
||||
// Check that ClassName is a valid class
|
||||
ObjCInterfaceDecl *Class = getObjCInterfaceDecl(ClassName);
|
||||
ObjCInterfaceDecl *Class = getObjCInterfaceDecl(ClassName, DeclStart);
|
||||
if (!Class) {
|
||||
Diag(DeclStart, diag::err_undef_interface) << ClassName;
|
||||
return;
|
||||
|
|
|
@ -78,7 +78,8 @@ Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,
|
|||
Ty = Context.getObjCObjectPointerType(Ty);
|
||||
} else {
|
||||
IdentifierInfo *NSIdent = &Context.Idents.get("NSString");
|
||||
NamedDecl *IF = LookupSingleName(TUScope, NSIdent, LookupOrdinaryName);
|
||||
NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLocs[0],
|
||||
LookupOrdinaryName);
|
||||
if (ObjCInterfaceDecl *StrIF = dyn_cast_or_null<ObjCInterfaceDecl>(IF)) {
|
||||
Context.setObjCConstantStringInterface(StrIF);
|
||||
Ty = Context.getObjCConstantStringInterface();
|
||||
|
@ -149,7 +150,7 @@ Sema::ExprResult Sema::ParseObjCProtocolExpression(IdentifierInfo *ProtocolId,
|
|||
SourceLocation ProtoLoc,
|
||||
SourceLocation LParenLoc,
|
||||
SourceLocation RParenLoc) {
|
||||
ObjCProtocolDecl* PDecl = LookupProtocol(ProtocolId);
|
||||
ObjCProtocolDecl* PDecl = LookupProtocol(ProtocolId, ProtoLoc);
|
||||
if (!PDecl) {
|
||||
Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId;
|
||||
return true;
|
||||
|
@ -401,7 +402,8 @@ ActOnClassPropertyRefExpr(IdentifierInfo &receiverName,
|
|||
SourceLocation propertyNameLoc) {
|
||||
|
||||
IdentifierInfo *receiverNamePtr = &receiverName;
|
||||
ObjCInterfaceDecl *IFace = getObjCInterfaceDecl(receiverNamePtr);
|
||||
ObjCInterfaceDecl *IFace = getObjCInterfaceDecl(receiverNamePtr,
|
||||
receiverNameLoc);
|
||||
if (IFace == 0) {
|
||||
// If the "receiver" is 'super' in a method, handle it as an expression-like
|
||||
// property reference.
|
||||
|
@ -603,7 +605,7 @@ ActOnClassMessage(Scope *S, IdentifierInfo *receiverName, Selector Sel,
|
|||
}
|
||||
|
||||
if (ClassDecl == 0)
|
||||
ClassDecl = getObjCInterfaceDecl(receiverName, receiverLoc);
|
||||
ClassDecl = getObjCInterfaceDecl(receiverName, receiverLoc, true);
|
||||
|
||||
// The following code allows for the following GCC-ism:
|
||||
//
|
||||
|
@ -617,7 +619,8 @@ ActOnClassMessage(Scope *S, IdentifierInfo *receiverName, Selector Sel,
|
|||
// If necessary, the following lookup could move to getObjCInterfaceDecl().
|
||||
if (!ClassDecl) {
|
||||
NamedDecl *IDecl
|
||||
= LookupSingleName(TUScope, receiverName, LookupOrdinaryName);
|
||||
= LookupSingleName(TUScope, receiverName, receiverLoc,
|
||||
LookupOrdinaryName);
|
||||
if (TypedefDecl *OCTD = dyn_cast_or_null<TypedefDecl>(IDecl))
|
||||
if (const ObjCInterfaceType *OCIT
|
||||
= OCTD->getUnderlyingType()->getAs<ObjCInterfaceType>())
|
||||
|
|
|
@ -1825,16 +1825,19 @@ IsAcceptableNonMemberOperatorCandidate(FunctionDecl *Fn,
|
|||
}
|
||||
|
||||
NamedDecl *Sema::LookupSingleName(Scope *S, DeclarationName Name,
|
||||
SourceLocation Loc,
|
||||
LookupNameKind NameKind,
|
||||
RedeclarationKind Redecl) {
|
||||
LookupResult R(*this, Name, SourceLocation(), NameKind, Redecl);
|
||||
LookupResult R(*this, Name, Loc, NameKind, Redecl);
|
||||
LookupName(R, S);
|
||||
return R.getAsSingle<NamedDecl>();
|
||||
}
|
||||
|
||||
/// \brief Find the protocol with the given name, if any.
|
||||
ObjCProtocolDecl *Sema::LookupProtocol(IdentifierInfo *II) {
|
||||
Decl *D = LookupSingleName(TUScope, II, LookupObjCProtocolName);
|
||||
ObjCProtocolDecl *Sema::LookupProtocol(IdentifierInfo *II,
|
||||
SourceLocation IdLoc) {
|
||||
Decl *D = LookupSingleName(TUScope, II, IdLoc,
|
||||
LookupObjCProtocolName);
|
||||
return cast_or_null<ObjCProtocolDecl>(D);
|
||||
}
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ ObjCPropertyDecl *Sema::CreatePropertyDecl(Scope *S,
|
|||
ObjCInterfaceDecl *IDecl = OIT->getDecl();
|
||||
if (IDecl)
|
||||
if (ObjCProtocolDecl* PNSCopying =
|
||||
LookupProtocol(&Context.Idents.get("NSCopying")))
|
||||
LookupProtocol(&Context.Idents.get("NSCopying"), AtLoc))
|
||||
if (IDecl->ClassImplementsProtocol(PNSCopying, true))
|
||||
Diag(AtLoc, diag::warn_implements_nscopying) << PropertyId;
|
||||
}
|
||||
|
|
|
@ -455,7 +455,8 @@ Sema::DeclPtrTy Sema::ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis,
|
|||
bool Invalid = false;
|
||||
|
||||
if (ParamName) {
|
||||
NamedDecl *PrevDecl = LookupSingleName(S, ParamName, LookupTagName);
|
||||
NamedDecl *PrevDecl = LookupSingleName(S, ParamName, ParamNameLoc,
|
||||
LookupTagName);
|
||||
if (PrevDecl && PrevDecl->isTemplateParameter())
|
||||
Invalid = Invalid || DiagnoseTemplateParameterShadow(ParamNameLoc,
|
||||
PrevDecl);
|
||||
|
@ -576,7 +577,8 @@ Sema::DeclPtrTy Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
|
|||
|
||||
IdentifierInfo *ParamName = D.getIdentifier();
|
||||
if (ParamName) {
|
||||
NamedDecl *PrevDecl = LookupSingleName(S, ParamName, LookupTagName);
|
||||
NamedDecl *PrevDecl = LookupSingleName(S, ParamName, D.getIdentifierLoc(),
|
||||
LookupTagName);
|
||||
if (PrevDecl && PrevDecl->isTemplateParameter())
|
||||
Invalid = Invalid || DiagnoseTemplateParameterShadow(D.getIdentifierLoc(),
|
||||
PrevDecl);
|
||||
|
|
Loading…
Reference in New Issue