[PATCH] D127641: [clang-cl][MSVC] Add default /Zc conformance arguments
Stephen Long via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 14 11:08:07 PDT 2022
steplong updated this revision to Diff 436860.
steplong added a comment.
Herald added a subscriber: MaskRay.
- Only enable /Zc:alignedNew and /Zc:sizedDealloc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127641/new/
https://reviews.llvm.org/D127641
Files:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/cl-zc.cpp
Index: clang/test/Driver/cl-zc.cpp
===================================================================
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -1,6 +1,12 @@
// Note: %s must be preceded by --, otherwise it may be interpreted as a
// command-line option, e.g. on Mac where %s is commonly under /Users.
+// RUN: %clang_cl /c /std:c++17 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-CPP17-DEFAULT %s
+// ALIGNED-NEW-CPP17-DEFAULT: "-faligned-allocation"
+
+// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC-DEFAULT %s
+// SIZED-DEALLOC-DEFAULT: "-fsized-deallocation"
+
// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=TRIGRAPHS-DEFAULT %s
// cc1 will disable trigraphs for -fms-compatibility as long as -ftrigraphs
// isn't explicitly passed.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6490,6 +6490,12 @@
}
CmdArgs.push_back(LanguageStandard.data());
+
+ // MSVC enables /Zc:alignedNew by default for C++17
+ if (!Args.getLastArg(options::OPT_faligned_allocation,
+ options::OPT_fno_aligned_allocation) &&
+ LanguageStandard == "-std=c++17")
+ CmdArgs.push_back("-faligned-allocation");
}
Args.addOptInFlag(CmdArgs, options::OPT_fborland_extensions,
@@ -6618,6 +6624,13 @@
Args.addOptInFlag(CmdArgs, options::OPT_frelaxed_template_template_args,
options::OPT_fno_relaxed_template_template_args);
+ // MSVC turns on /Zc:sizedDealloc by default. Honor whatever is passed
+ // on the cmdline.
+ if (IsWindowsMSVC &&
+ !Args.getLastArg(options::OPT_fsized_deallocation,
+ options::OPT_fno_sized_deallocation))
+ CmdArgs.push_back("-fsized-deallocation");
+
// -fsized-deallocation is off by default, as it is an ABI-breaking change for
// most platforms.
Args.addOptInFlag(CmdArgs, options::OPT_fsized_deallocation,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127641.436860.patch
Type: text/x-patch
Size: 2081 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220614/29b33bdd/attachment.bin>
More information about the cfe-commits
mailing list