diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-08-11 12:19:30 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-08-11 12:19:30 +0000 |
| commit | 1c28331b57df1b99af4ff5dcb409cafbe171795c (patch) | |
| tree | cbef2c4e46eb07858e8707ce48629bf73023ea67 /clang/lib/Sema/SemaDecl.cpp | |
| parent | 6a98131468162950c22a866d736e66e300fb2803 (diff) | |
| download | bcm5719-llvm-1c28331b57df1b99af4ff5dcb409cafbe171795c.tar.gz bcm5719-llvm-1c28331b57df1b99af4ff5dcb409cafbe171795c.zip | |
Speculatively revert r110610 " Make ObjCInterfaceDecl redeclarable,
and create separate decl nodes for forward declarations and the
definition," which appears to be causing significant Objective-C
breakage.
llvm-svn: 110803
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index d94b8dd304c..47eb3eec89f 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -606,6 +606,45 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) { } } +/// \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 +/// typo-correction fixes this name, the Id will be updated +/// to the fixed name. +/// +/// \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 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, IdLoc, LookupOrdinaryName); + + if (!IDecl && TypoCorrection) { + // Perform typo correction at the given location, but only if we + // find an Objective-C class name. + LookupResult R(*this, Id, IdLoc, LookupOrdinaryName); + if (CorrectTypo(R, TUScope, 0, 0, false, CTC_NoKeywords) && + (IDecl = R.getAsSingle<ObjCInterfaceDecl>())) { + Diag(IdLoc, diag::err_undef_interface_suggest) + << Id << IDecl->getDeclName() + << FixItHint::CreateReplacement(IdLoc, IDecl->getNameAsString()); + Diag(IDecl->getLocation(), diag::note_previous_decl) + << IDecl->getDeclName(); + + Id = IDecl->getIdentifier(); + } + } + + return dyn_cast_or_null<ObjCInterfaceDecl>(IDecl); +} + /// getNonFieldDeclScope - Retrieves the innermost scope, starting /// from S, where a non-field would be declared. This routine copes /// with the difference between C and C++ scoping rules in structs and |

