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,
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,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits