[cfe-commits] r116586 - in /cfe/trunk: lib/Sema/SemaLookup.cpp test/FixIt/typo.m test/SemaObjC/synth-provisional-ivars.m

Argyrios Kyrtzidis kyrtzidis at apple.com
Fri Oct 15 13:06:25 PDT 2010


test/FixIt/typo.m fails if clang is built using gcc.

-Argiris

On Oct 15, 2010, at 9:49 AM, Douglas Gregor wrote:

> Author: dgregor
> Date: Fri Oct 15 11:49:56 2010
> New Revision: 116586
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=116586&view=rev
> Log:
> When performing typo correction, keep track of whether the last lookup
> we did was an acceptable lookup. If it is, then we can re-use that
> lookup result. If it isn't, we have to perform the lookup again. This
> is almost surely the cause behind the mysterious typo.m failures on
> some builders; we were getting the wrong lookup results returned.
> 
> Modified:
>   cfe/trunk/lib/Sema/SemaLookup.cpp
>   cfe/trunk/test/FixIt/typo.m
>   cfe/trunk/test/SemaObjC/synth-provisional-ivars.m
> 
> Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=116586&r1=116585&r2=116586&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Oct 15 11:49:56 2010
> @@ -3051,6 +3051,7 @@
>    return DeclarationName();
> 
>  // Weed out any names that could not be found by name lookup.
> +  bool LastLookupWasAccepted = false;
>  for (TypoCorrectionConsumer::iterator I = Consumer.begin(), 
>                                     IEnd = Consumer.end();
>       I != IEnd; /* Increment in loop. */) {
> @@ -3103,12 +3104,14 @@
>        Consumer.erase(I);
>        I = Next;
>      }
> +      LastLookupWasAccepted = false;
>      break;      
> 
>    case LookupResult::Found:
>    case LookupResult::FoundOverloaded:
>    case LookupResult::FoundUnresolvedValue:
>      ++I;
> +      LastLookupWasAccepted = false;
>      break;
>    }
> 
> @@ -3121,8 +3124,41 @@
>  }
> 
>  // If only a single name remains, return that result.
> -  if (Consumer.size() == 1)
> +  if (Consumer.size() == 1) {
> +    IdentifierInfo *Name = &Context.Idents.get(Consumer.begin()->getKey());
> +    if (!LastLookupWasAccepted) {
> +      // Perform name lookup on this name.
> +      Res.suppressDiagnostics();
> +      Res.clear();
> +      Res.setLookupName(Name);
> +      if (MemberContext)
> +        LookupQualifiedName(Res, MemberContext);
> +      else {
> +        LookupParsedName(Res, S, SS, /*AllowBuiltinCreation=*/false, 
> +                         EnteringContext);
> +
> +        // Fake ivar lookup; this should really be part of
> +        // LookupParsedName.
> +        if (ObjCMethodDecl *Method = getCurMethodDecl()) {
> +          if (Method->isInstanceMethod() && Method->getClassInterface() &&
> +              (Res.empty() || 
> +               (Res.isSingleResult() &&
> +                Res.getFoundDecl()->isDefinedOutsideFunctionOrMethod()))) {
> +            ObjCInterfaceDecl *ClassDeclared = 0;
> +            if (ObjCIvarDecl *IV 
> +                = Method->getClassInterface()->lookupInstanceVariable(Name, 
> +                                                              ClassDeclared)) {
> +              Res.clear();
> +              Res.addDecl(IV);
> +              Res.resolveKind();
> +            }
> +          }
> +        }
> +      }
> +    }
> +
>    return &Context.Idents.get(Consumer.begin()->getKey());  
> +  }
>  else if (Consumer.size() > 1 && CTC == CTC_ObjCMessageReceiver 
>           && Consumer["super"]) {
>    // Prefix 'super' when we're completing in a message-receiver
> 
> Modified: cfe/trunk/test/FixIt/typo.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/typo.m?rev=116586&r1=116585&r2=116586&view=diff
> ==============================================================================
> --- cfe/trunk/test/FixIt/typo.m (original)
> +++ cfe/trunk/test/FixIt/typo.m Fri Oct 15 11:49:56 2010
> @@ -2,9 +2,6 @@
> // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c -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 -pedantic -Werror %t
> -//
> -// FIXME: Disabled while we investigate failure.
> -// REQUIRES: disabled
> 
> @interface NSString // expected-note{{'NSString' declared here}}
> + (int)method:(int)x;
> 
> Modified: cfe/trunk/test/SemaObjC/synth-provisional-ivars.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/synth-provisional-ivars.m?rev=116586&r1=116585&r2=116586&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaObjC/synth-provisional-ivars.m (original)
> +++ cfe/trunk/test/SemaObjC/synth-provisional-ivars.m Fri Oct 15 11:49:56 2010
> @@ -18,7 +18,7 @@
> @end
> 
> @implementation I
> -- (int) Meth { return PROP; }
> +- (int) Meth { return PROP; } // expected-note{{'PROP' declared here}}
> 
> @dynamic PROP1;
> - (int) Meth1 { return PROP1; }  // expected-error {{use of undeclared identifier 'PROP1'}}
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list