[cfe-commits] r145930 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp test/Misc/warning-flags.c test/Sema/builtins.c test/Sema/c89.c test/Sema/implicit-decl.c

Peter Cooper peter_cooper at apple.com
Wed Dec 7 14:13:52 PST 2011


Hi Hans

We're getting a performance regression (about 16%) when compiling this test with your change.  Can you please investigate it or revert this change until it can be fixed.

The test is MultiSource/Benchmarks/mediabench/g721/g721encode

My command line to reproduce was (in the above test folder)

make TEST=simple DISABLE_JIT=1 DISABLE_CBE=1 USE_REFERENCE_OUTPUT=1 SMALL_PROBLEM_SIZE=1

Thanks,
Pete

On Dec 6, 2011, at 1:46 AM, Hans Wennborg wrote:

> Author: hans
> Date: Tue Dec  6 03:46:12 2011
> New Revision: 145930
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=145930&view=rev
> Log:
> Suggest typo corrections for implicit function declarations.
> 
> A mistyped function call becomes an inmplicit function declaration in C.
> Suggest typo correction when one can be found.
> 
> Modified:
>    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>    cfe/trunk/lib/Sema/SemaDecl.cpp
>    cfe/trunk/test/Misc/warning-flags.c
>    cfe/trunk/test/Sema/builtins.c
>    cfe/trunk/test/Sema/c89.c
>    cfe/trunk/test/Sema/implicit-decl.c
> 
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=145930&r1=145929&r2=145930&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Dec  6 03:46:12 2011
> @@ -141,6 +141,7 @@
> def ext_implicit_function_decl : ExtWarn<
>   "implicit declaration of function %0 is invalid in C99">,
>   InGroup<ImplicitFunctionDeclare>;
> +def note_function_suggestion : Note<"did you mean %0?">;
> 
> def err_ellipsis_first_arg : Error<
>   "ISO C requires a named argument before '...'">;
> @@ -272,7 +273,7 @@
> def err_builtin_definition : Error<"definition of builtin function %0">;
> def err_types_compatible_p_in_cplusplus : Error<
>   "__builtin_types_compatible_p is not valid in C++">;
> -def warn_builtin_unknown : Warning<"use of unknown builtin %0">, DefaultError;
> +def err_builtin_unknown : Error<"use of unknown builtin %0">;
> def warn_dyn_class_memaccess : Warning<
>   "%select{destination for|source of|first operand of|second operand of}0 this "
>   "%1 call is a pointer to dynamic class %2; vtable pointer will be "
> 
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=145930&r1=145929&r2=145930&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Dec  6 03:46:12 2011
> @@ -7262,14 +7262,38 @@
>     return Pos->second;
>   }
> 
> +  // See if we can find a typo correction.
> +  TypoCorrection Corrected;
> +  FunctionDecl *Func = 0;
> +  std::string CorrectedStr;
> +  std::string CorrectedQuotedStr;
> +  if (S && (Corrected = CorrectTypo(DeclarationNameInfo(&II, Loc),
> +                                    LookupOrdinaryName, S, 0))) {
> +    // Since this is an implicit function declaration, we are only
> +    // interested in a potential typo for a function name.
> +    if ((Func = dyn_cast_or_null<FunctionDecl>(
> +            Corrected.getCorrectionDecl()))) {
> +      CorrectedStr = Corrected.getAsString(getLangOptions());
> +      CorrectedQuotedStr = Corrected.getQuoted(getLangOptions());
> +    }
> +  }
> +
>   // Extension in C99.  Legal in C90, but warn about it.
>   if (II.getName().startswith("__builtin_"))
> -    Diag(Loc, diag::warn_builtin_unknown) << &II;
> +    Diag(Loc, diag::err_builtin_unknown) << &II;
>   else if (getLangOptions().C99)
>     Diag(Loc, diag::ext_implicit_function_decl) << &II;
>   else
>     Diag(Loc, diag::warn_implicit_function_decl) << &II;
> 
> +  if (Func) {
> +    // If we found a typo correction, then suggest that.
> +    Diag(Loc, diag::note_function_suggestion) << CorrectedQuotedStr
> +        << FixItHint::CreateReplacement(Loc, CorrectedStr);
> +    if (Func->getLocation().isValid() && !II.getName().startswith("__builtin_"))
> +      Diag(Func->getLocation(), diag::note_previous_decl) << CorrectedQuotedStr;
> +  }
> +
>   // Set a Declarator for the implicit definition: int foo();
>   const char *Dummy;
>   AttributeFactory attrFactory;
> 
> Modified: cfe/trunk/test/Misc/warning-flags.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags.c?rev=145930&r1=145929&r2=145930&view=diff
> ==============================================================================
> --- cfe/trunk/test/Misc/warning-flags.c (original)
> +++ cfe/trunk/test/Misc/warning-flags.c Tue Dec  6 03:46:12 2011
> @@ -17,7 +17,7 @@
> 
> The list of warnings below should NEVER grow.  It should gradually shrink to 0.
> 
> -CHECK: Warnings without flags (272):
> +CHECK: Warnings without flags (271):
> CHECK-NEXT:   ext_anon_param_requires_type_specifier
> CHECK-NEXT:   ext_anonymous_struct_union_qualified
> CHECK-NEXT:   ext_array_init_copy
> @@ -128,7 +128,6 @@
> CHECK-NEXT:   warn_bitfield_width_exceeds_type_size
> CHECK-NEXT:   warn_bool_switch_condition
> CHECK-NEXT:   warn_braces_around_scalar_init
> -CHECK-NEXT:   warn_builtin_unknown
> CHECK-NEXT:   warn_c_kext
> CHECK-NEXT:   warn_call_to_pure_virtual_member_function_from_ctor_dtor
> CHECK-NEXT:   warn_call_wrong_number_of_arguments
> 
> Modified: cfe/trunk/test/Sema/builtins.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtins.c?rev=145930&r1=145929&r2=145930&view=diff
> ==============================================================================
> --- cfe/trunk/test/Sema/builtins.c (original)
> +++ cfe/trunk/test/Sema/builtins.c Tue Dec  6 03:46:12 2011
> @@ -78,7 +78,8 @@
> }
> 
> void test_unknown_builtin(int a, int b) {
> -  __builtin_foo(a, b); // expected-error{{use of unknown builtin}}
> +  __builtin_isles(a, b); // expected-error{{use of unknown builtin}} \
> +                         // expected-note{{did you mean '__builtin_isless'?}}
> }
> 
> int test13() {
> @@ -101,4 +102,3 @@
>   return __builtin_constant_p() + // expected-error{{too few arguments}}
>          __builtin_constant_p(1, 2); // expected-error {{too many arguments}}
> }
> -
> 
> Modified: cfe/trunk/test/Sema/c89.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/c89.c?rev=145930&r1=145929&r2=145930&view=diff
> ==============================================================================
> --- cfe/trunk/test/Sema/c89.c (original)
> +++ cfe/trunk/test/Sema/c89.c Tue Dec  6 03:46:12 2011
> @@ -1,4 +1,4 @@
> -/* RUN: %clang_cc1 %s -std=c89 -pedantic -fsyntax-only -verify
> +/* RUN: %clang_cc1 %s -std=c89 -pedantic -fsyntax-only -verify -Wimplicit-function-declaration
>  */
> void test1() {
>   {
> @@ -82,3 +82,10 @@
> int test14() { return (&*test14)(); }
> 
> int test15[5] = { [2] = 1 }; /* expected-warning {{designated initializers are a C99 feature}} */
> +
> +extern int printf(__const char *__restrict __format, ...); /* expected-note{{'printf' declared here}} */
> +
> +void test16() {
> +  printg("Hello, world!\n"); /* expected-warning {{implicit declaration of function 'printg'}}
> +                                expected-note {{did you mean 'printf'?}} */
> +}
> 
> Modified: cfe/trunk/test/Sema/implicit-decl.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/implicit-decl.c?rev=145930&r1=145929&r2=145930&view=diff
> ==============================================================================
> --- cfe/trunk/test/Sema/implicit-decl.c (original)
> +++ cfe/trunk/test/Sema/implicit-decl.c Tue Dec  6 03:46:12 2011
> @@ -3,6 +3,8 @@
> typedef int int32_t;
> typedef unsigned char Boolean;
> 
> +extern int printf(__const char *__restrict __format, ...); // expected-note{{'printf' declared here}}
> +
> void func() {
>    int32_t *vector[16];
>    const char compDesc[16 + 1];
> @@ -10,8 +12,13 @@
>    if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-note {{previous implicit declaration is here}} \
>          expected-warning {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}}
>    }
> +
> +   printg("Hello, World!\n"); // expected-warning{{implicit declaration of function 'printg' is invalid in C99}} \
> +                              // expected-note{{did you mean 'printf'?}}
> +
> +  __builtin_is_les(1, 3); // expected-error{{use of unknown builtin '__builtin_is_les'}} \
> +                          // expected-note{did you mean '__builtin_is_less'?}}
> }
> Boolean _CFCalendarDecomposeAbsoluteTimeV(const char *componentDesc, int32_t **vector, int32_t count) { // expected-error{{conflicting types for '_CFCalendarDecomposeAbsoluteTimeV'}}
>  return 0;
> }
> -
> 
> 
> _______________________________________________
> 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