[PATCH] D132810: [clang][MinGW] Add `-mguard=cf` and `-mguard=cf-nochecks`

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 1 14:56:59 PDT 2022


MaskRay added a comment.

The risk conflicting with a GCC option is probably quite low. If there is something, the GCC option will likely be `-mguard-*=` instead of `-mguard=` (IMHO confusing).



================
Comment at: clang/lib/Driver/ToolChains/MinGW.cpp:627
+    StringRef GuardArgs = A->getValue();
+    if (GuardArgs.equals_insensitive("none")) {
+      // Do nothing.
----------------
If this is Clang specific, is it necessary to use insensitive option names?


================
Comment at: clang/test/Driver/mingw-cfguard.c:1
+// RUN: %clang -v -target x86_64-w64-windows-gnu -### %s 2>&1 | FileCheck -check-prefixes=NO_CF,DEFAULT %s
+// RUN: %clang -v -target x86_64-w64-windows-gnu -### %s -mguard=none 2>&1 | FileCheck -check-prefixes=NO_CF,GUARD_NONE %s
----------------
Use `--target=` for new tests (avoid legacy `-target `).

Omit unneeded `-v`.


================
Comment at: clang/test/Driver/mingw-cfguard.c:3
+// RUN: %clang -v -target x86_64-w64-windows-gnu -### %s -mguard=none 2>&1 | FileCheck -check-prefixes=NO_CF,GUARD_NONE %s
+// NO_CF: "-cc1"
+// NO_CF-NOT: "-cfguard"
----------------
`{{$}}` is unneeded

```
// NO_CF:     "-cc1"
// NO_CF-NOT: "-cfguard"
// NO_CF-NOT: "-cfguard-no-checks"
// NO_CF-NEXT: ld"
// NO_CF-NOT: "--guard-cf"
// DEFAULT-NOT: "--no-guard-cf"
// GUARD_NONE-SAME: "--no-guard-cf"
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132810



More information about the cfe-commits mailing list