diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-05-18 16:14:23 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-05-18 16:14:23 +0000 | 
| commit | 5fd04d48329dc4dbbea7c1a5075a5e9701af06b9 (patch) | |
| tree | 70e6756e6bcb523c627847fd0baa44da0ad88a32 /clang/lib/Sema | |
| parent | dea53104339d960bc8569388a8d5eae6a4214d8c (diff) | |
| download | bcm5719-llvm-5fd04d48329dc4dbbea7c1a5075a5e9701af06b9.tar.gz bcm5719-llvm-5fd04d48329dc4dbbea7c1a5075a5e9701af06b9.zip | |
Tweak typo-correction logic a bit regarding "super", so that we
consider "super" as a candidate whenever we're parsing an expression
within an Objective-C method in an interface that has a superclass. At
some point, we'd like to give "super" a little edge over non-local
names; that will come later.
llvm-svn: 104022
Diffstat (limited to 'clang/lib/Sema')
| -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 | 
4 files changed, 12 insertions, 5 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"); | 

