[cfe-commits] r158231 - in /cfe/trunk: lib/Sema/SemaLookup.cpp test/SemaCXX/typo-correction.cpp

David Blaikie dblaikie at gmail.com
Fri Jun 8 14:42:39 PDT 2012


On Fri, Jun 8, 2012 at 2:35 PM, Richard Smith
<richard-llvm at metafoo.co.uk> wrote:
> Author: rsmith
> Date: Fri Jun  8 16:35:42 2012
> New Revision: 158231
>
> URL: http://llvm.org/viewvc/llvm-project?rev=158231&view=rev
> Log:
> PR13051: Only suggest the 'template' and 'operator' keywords when performing
> typo-correction after a scope specifier.
>
> Modified:
>    cfe/trunk/lib/Sema/SemaLookup.cpp
>    cfe/trunk/test/SemaCXX/typo-correction.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=158231&r1=158230&r2=158231&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Jun  8 16:35:42 2012
> @@ -3533,7 +3533,16 @@
>  /// \brief Add keywords to the consumer as possible typo corrections.
>  static void AddKeywordsToConsumer(Sema &SemaRef,
>                                   TypoCorrectionConsumer &Consumer,
> -                                  Scope *S, CorrectionCandidateCallback &CCC) {
> +                                  Scope *S, CorrectionCandidateCallback &CCC,
> +                                  bool AfterNestedNameSpecifier) {
> +  if (AfterNestedNameSpecifier) {
> +    // For 'X::', we know exactly which keywords can appear next.
> +    Consumer.addKeywordResult("template");
> +    if (CCC.WantExpressionKeywords)
> +      Consumer.addKeywordResult("operator");
> +    return;
> +  }
> +
>   if (CCC.WantObjCSuper)
>     Consumer.addKeywordResult("super");
>
> @@ -3823,7 +3832,7 @@
>     }
>   }
>
> -  AddKeywordsToConsumer(*this, Consumer, S, CCC);
> +  AddKeywordsToConsumer(*this, Consumer, S, CCC, SS && SS->isNotEmpty());
>
>   // If we haven't found anything, we're done.
>   if (Consumer.empty()) {
>
> Modified: cfe/trunk/test/SemaCXX/typo-correction.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction.cpp?rev=158231&r1=158230&r2=158231&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/typo-correction.cpp (original)
> +++ cfe/trunk/test/SemaCXX/typo-correction.cpp Fri Jun  8 16:35:42 2012
> @@ -206,3 +206,16 @@
>  namespace bazquux { struct Thing {}; }
>  void f() { Thing t; } // expected-error{{unknown type name 'Thing'}}
>  }
> +
> +namespace PR13051 {
> +  template<typename T> struct S {
> +    template<typename U> void f();
> +    operator bool() const;
> +  };
> +
> +  void f() {
> +    f(&S<int>::tempalte f<int>); // expected-error{{did you mean 'template'?}}
> +    f(&S<int>::opeartor bool); // expected-error{{did you mean 'operator'?}}

Are there any negative test cases you should include to ensure we
aren't suggesting operator/template in inappropriate situations? (as
per the patch description)

> +    f(&S<int>::foo); // expected-error-re{{no member named 'foo' in 'PR13051::S<int>'$}}
> +  }
> +}
>
>
> _______________________________________________
> 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