[PATCH] D124613: In MSVC compatibility mode, friend function declarations behave as function declarations

Fred Tingaud via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 12 07:02:18 PDT 2022


frederic-tingaud-sonarsource added a comment.

Regarding the "why":
Our tools (SonarQube / SonarCloud / SonarLint) use the clang front-end to parse our customer's code and find bugs/bad patterns in it. Said customer code can target various compilers including MSVC and we need to handle it as gracefully as possible.
When we find gaps between MSVC and clang-cl, we try to fix them and if we think the fix will have negligible memory/performance/complexity impact on clang and be useful to the community, we try to upstream them. It's true that this fix purpose is not to fix handling of MSVC standard headers, but there are more and more tools that also target existing MSVC code (clang-tidy, Clang Power Tools, etc.) thanks to this compatibility feature and we felt that it could be valuable.
We also try to always have a warning attached to MSVC extensions, but this one has two particularities: it builds on top of an already existing MSVC compatibility feature (PerformFriendInjection in Decl::setObjectOfFriendDecl) and there is no way (without a big refactoring), that would allow to warn correctly when the extension is actually used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124613



More information about the cfe-commits mailing list