diff options
| -rw-r--r-- | clang/lib/Sema/Sema.h | 3 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 2 | ||||
| -rw-r--r-- | clang/test/FixIt/typo.m | 17 | 
5 files changed, 28 insertions, 6 deletions
| diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index a7d242c559b..975516ff9a3 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -1811,7 +1811,8 @@ public:                                               bool HasTrailingLParen,                                               bool IsAddressOfOperand); -  bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R); +  bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, +                           CorrectTypoContext CTC = CTC_Unknown);    OwningExprResult LookupInObjCMethod(LookupResult &R,                                        Scope *S, diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 5af5585f7f8..8bc3d063b1d 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -917,7 +917,7 @@ static void DiagnoseInstanceReference(Sema &SemaRef,  ///  /// \return false if new lookup candidates were found  bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, -                               LookupResult &R) { +                               LookupResult &R, CorrectTypoContext CTC) {    DeclarationName Name = R.getLookupName();    unsigned diagnostic = diag::err_undeclared_var_use; @@ -968,7 +968,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS,    // We didn't find anything, so try to correct for a typo.    DeclarationName Corrected; -  if (S && (Corrected = CorrectTypo(R, S, &SS))) { +  if (S && (Corrected = CorrectTypo(R, S, &SS, false, CTC))) {      if (!R.empty()) {        if (isa<ValueDecl>(*R.begin()) || isa<FunctionTemplateDecl>(*R.begin())) {          if (SS.isEmpty()) @@ -1122,7 +1122,7 @@ Sema::OwningExprResult Sema::ActOnIdExpression(Scope *S,      // If this name wasn't predeclared and if this is not a function      // call, diagnose the problem.      if (R.empty()) { -      if (DiagnoseEmptyLookup(S, SS, R)) +      if (DiagnoseEmptyLookup(S, SS, R, CTC_Unknown))          return ExprError();        assert(!R.empty() && diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 31c33e963ca..62b0ea149b7 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -2612,6 +2612,12 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS,        WantExpressionKeywords = true;        WantCXXNamedCasts = true;        WantRemainingKeywords = true; +       +      if (ObjCMethodDecl *Method = getCurMethodDecl()) +        if (Method->getClassInterface() && +            Method->getClassInterface()->getSuperClass()) +          Consumer.addKeywordResult(Context, "super"); +              break;      case CTC_NoKeywords: diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 15f19723f89..4c48e6159c4 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -6002,7 +6002,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,    LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),                   Sema::LookupOrdinaryName); -  if (SemaRef.DiagnoseEmptyLookup(S, SS, R)) +  if (SemaRef.DiagnoseEmptyLookup(S, SS, R, Sema::CTC_Expression))      return Destroy(SemaRef, Fn, Args, NumArgs);    assert(!R.empty() && "lookup results empty despite recovery"); diff --git a/clang/test/FixIt/typo.m b/clang/test/FixIt/typo.m index 2ee6831da6f..3b73a2a33b6 100644 --- a/clang/test/FixIt/typo.m +++ b/clang/test/FixIt/typo.m @@ -1,6 +1,6 @@  // RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -DNON_FIXITS -verify %s  // RUN: %clang -E -P %s -o %t -// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fixit %t || true +// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fixit %t  || true  // RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -pedantic -Werror %t  @interface NSString // expected-note{{'NSString' declared here}} @@ -97,6 +97,7 @@ void test2(Collide *a) {  @interface Super  - (int)method; // expected-note{{using}} +- (int)method2;  @end  @interface Sub : Super @@ -110,6 +111,20 @@ void test2(Collide *a) {  @end +#ifdef NON_FIXITS +double *isupper(int); + +@interface Sub2 : Super +- (int)method2; +@end + +@implementation Sub2 +- (int)method2 { +  return [supper method2]; // expected-error{{use of undeclared identifier 'supper'}} +} +@end +#endif +  @interface Ivar  @end | 

