[PATCH] D114579: [clang-tidy] Exempt _MSVC_EXECUTION_CHARACTER_SET from cppcoreguidelines-macro-usage

Markus Böck via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 25 04:09:13 PST 2021


zero9178 created this revision.
zero9178 added reviewers: MaskRay, aaron.ballman, lebedev.ri, JonasToth, hokein.
Herald added subscribers: carlosgalvezp, shchenz, kbarton, xazax.hun, nemanjai.
zero9178 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

In https://reviews.llvm.org/D114576 I am trying to add an unconditional define to the MSVC cc1 driver which sadly then leads to a test failure in `cppcoreguidelines-macro-usage-command-line-macros.cpp` with MSVC builds.

The solution is a bit hacky IMO, but there seems to already be a similar workaround for `__GCC_HAVE_DWARF2_CFI_ASM`. I don't know of any way to differentiate between defines passed on the CLI by users, and ones set by the driver, so this will have to do for now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114579

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp


Index: clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
@@ -47,7 +47,8 @@
       return;
 
     StringRef MacroName = MacroNameTok.getIdentifierInfo()->getName();
-    if (MacroName == "__GCC_HAVE_DWARF2_CFI_ASM")
+    if (MacroName == "__GCC_HAVE_DWARF2_CFI_ASM" ||
+        MacroName == "_MSVC_EXECUTION_CHARACTER_SET")
       return;
     if (!CheckCapsOnly && !RegExp.match(MacroName))
       Check->warnMacro(MD, MacroName);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114579.389718.patch
Type: text/x-patch
Size: 658 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211125/13434cfb/attachment.bin>


More information about the cfe-commits mailing list