[PATCH] D133853: [AST] Add msvc-specific C++11 attributes

Richard Dzenis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 15 13:51:43 PDT 2022


RIscRIpt added a comment.

In D133853#3792518 <https://reviews.llvm.org/D133853#3792518>, @aaron.ballman wrote:

> I'm wondering what the goal is for these changes. ... Are you intending to add semantics for these attributes in follow-up patches?

To be honest, I wasn't planning to do any of follow-up patches. I made a patch for internal usage at my job, and decided to submit it upstream.
The main reason I (we) need this patch is that we need to be able to parse MSVC-specific code (in the current case - detect `constexpr` functions). Since Visual Studio 17.3 (MSVC 14.33.31629), Microsoft's STL library added `[[msvc::constexpr]]` attribute, which is not documented yet, but makes a function to act like a `constexpr` function: see this godbolt sample <https://godbolt.org/z/76fYq145d> (i.e. forbids non-constexpr statements inside).

To make the patch complete, I decided to browse previous Microsoft's STL versions and see which vendor specific (`msvc::`) attributes they added previously; in this patch I added all attributes I was able to find.

> We don't typically add attributes to Clang that don't have any effect unless there's a very compelling reason to do so.

Theoretically, I could re-submit (or adjust this) patch, which would add support for `[[msvc::constexpr]]` attribute with semantic meaning of `constexpr` for functions (for code parsed with `-fms-extensions` flag). Regarding other attributes - unfortunately they are either poorly documented, or not documented at all, so I can drop commits for these attributes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133853/new/

https://reviews.llvm.org/D133853



More information about the cfe-commits mailing list