r200132 - Enforce safe usage of DiagnosticsEngine::getCustomDiagID()

Rafael EspĂ­ndola rafael.espindola at gmail.com
Sat Jan 25 22:41:33 PST 2014


> -  /// \brief Return an ID for a diagnostic with the specified message and level.
> +  /// \brief Return an ID for a diagnostic with the specified format string and
> +  /// level.
>    ///
>    /// If this is the first request for this diagnostic, it is registered and
>    /// created, otherwise the existing ID is returned.
>    ///
>    /// \param Message A fixed diagnostic format string that will be hashed and
>    /// mapped to a unique DiagID.
> -  unsigned getCustomDiagID(Level L, StringRef Message) {
> -    return Diags->getCustomDiagID((DiagnosticIDs::Level)L, Message);
> +  template <unsigned N>
> +  unsigned getCustomDiagID(Level L, const char (&FormatString)[N]) {
> +    return Diags->getCustomDiagID((DiagnosticIDs::Level)L,
> +                                  StringRef(FormatString, N));
>    }

This now warns:

/home/espindola/llvm/llvm/tools/clang/include/clang/Basic/Diagnostic.h:596:14:
warning: parameter 'Message' not found in the function declaration
[-Wdocumentation]
  /// \param Message A fixed diagnostic format string that will be hashed and
             ^~~~~~~
1 warning generated.


Cheers,
Rafael



More information about the cfe-commits mailing list