[cfe-commits] [PATCH] Add #pragma region for MSVC mode
Eli Friedman
eli.friedman at gmail.com
Mon Nov 5 12:07:12 PST 2012
Resending my previous comments, which you apparently didn't see.
On Mon, Nov 5, 2012 at 11:54 AM, pravic <ehysta at gmail.com> wrote:
> Updated patch with much more context.
>
> Hi triton, chapuni, rsmith,
>
> http://llvm-reviews.chandlerc.com/D65
>
> CHANGE SINCE LAST DIFF
> http://llvm-reviews.chandlerc.com/D65?vs=177&id=257#toc
>
> Files:
> lib/Lex/Pragma.cpp
> test/Lexer/pragma-region.c
>
> Index: lib/Lex/Pragma.cpp
> ===================================================================
> --- lib/Lex/Pragma.cpp
> +++ lib/Lex/Pragma.cpp
> @@ -1277,6 +1277,33 @@
> }
> };
>
> +/// \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);
> + }
> + }
> +
> +
> +};
> +
> +
> +
> } // end anonymous namespace
>
>
> @@ -1310,5 +1337,7 @@
> if (LangOpts.MicrosoftExt) {
> AddPragmaHandler(new PragmaCommentHandler());
> AddPragmaHandler(new PragmaIncludeAliasHandler());
> + AddPragmaHandler(new PragmaRegionHandler("region"));
> + AddPragmaHandler(new PragmaRegionHandler("endregion"));
> }
> }
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