[cfe-commits] [PATCH] [PATCH] Add #pragma region for MSVC mode

Eli Friedman eli.friedman at gmail.com
Tue Oct 16 14:00:39 PDT 2012


On Tue, Oct 16, 2012 at 11:18 AM, pravic <ehysta at gmail.com> wrote:
> +/// \bried PragmaRegionHandler - "\#pragma region [...]"

Your comment syntax is completely wrong.  (trunk clang has a warning
-Wdocumentation which can check this.)

> +/// The syntax is
> +/// \code
> +///   \#pragma region [optional name]
> +///   \#pragma endregion [optional comment]
> +/// \endcode
> +struct PragmaRegionHandler : public PragmaHandler {
> +  PragmaRegionHandler(const char* pragma)
> +    :PragmaHandler(pragma)
> +  {}

Put this on a single line (assuming it fits).

> +  virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
> +    Token &NameTok) {
> +    // #pragma region: just skip it
> +    // __pragma(region): no sense, but ignored by msvc too
> +    // _Pragma is not valid for MSVC
> +    if (Introducer == PIK__Pragma) {
> +      PP.Diag(NameTok.getLocation(), diag::warn_pragma_ignored);

There isn't any point to handling _Pragma differently; even if MSVC
doesn't support it, it makes just as much sense as __pragma.

MSVC docs say "A #region block must be terminated with #pragma
endregion."  We should check this.

-Eli



More information about the cfe-commits mailing list