r186971 - Add new diagnostic messages when too many arguments are presented to a

Matt Beaumont-Gay matthewbg at google.com
Tue Jul 23 11:54:11 PDT 2013


On Tue, Jul 23, 2013 at 11:01 AM, Richard Trieu <rtrieu at google.com> wrote:
> Author: rtrieu
> Date: Tue Jul 23 13:01:49 2013
> New Revision: 186971
>
> URL: http://llvm.org/viewvc/llvm-project?rev=186971&view=rev
> Log:
> Add new diagnostic messages when too many arguments are presented to a
> function-like macro.  Clang will attempt to correct the arguments by detecting
> braced initializer lists:
>
> 1) If possible, suggest parentheses around arguments
> containing braced lists which will give the proper number of arguments.
> 2) If a braced list is detected at the start of a macro argument, it cannot be
> corrected by parentheses.  Instead, just point out the location of these
> braced lists.
>
> Added:
>     cfe/trunk/test/Preprocessor/macro_with_initializer_list.cpp
> Modified:
>     cfe/trunk/include/clang/Basic/Diagnostic.h
>     cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>     cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>     cfe/trunk/test/Preprocessor/macro_fn.c
>
> Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=186971&r1=186970&r2=186971&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
> +++ cfe/trunk/include/clang/Basic/Diagnostic.h Tue Jul 23 13:01:49 2013
> @@ -990,6 +990,10 @@ public:
>    bool hasMaxRanges() const {
>      return NumRanges == DiagnosticsEngine::MaxRanges;
>    }
> +
> +  bool hasMaxFixItHints() const {
> +    return NumFixits == DiagnosticsEngine::MaxFixItHints;
> +  }
>  };
>
>  inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=186971&r1=186970&r2=186971&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Jul 23 13:01:49 2013
> @@ -460,6 +460,11 @@ def err_unterm_macro_invoc : Error<
>    "unterminated function-like macro invocation">;
>  def err_too_many_args_in_macro_invoc : Error<
>    "too many arguments provided to function-like macro invocation">;
> +def note_suggest_parens_for_macro : Note<
> +  "parentheses are required around macro argument containing braced "
> +  "initializer list">;
> +def note_init_list_at_beginning_of_macro_argument : Note<
> +  "cannot use initializer list at the beginning of an macro argument">;

Nit: s/an/a/



More information about the cfe-commits mailing list