steplong updated this revision to Diff 449303. steplong added a comment. - Add necessary includes to use EXPECT_THAT and MatchesRegex
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D127641/new/ https://reviews.llvm.org/D127641 Files: clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/cl-zc.cpp clang/unittests/StaticAnalyzer/CallEventTest.cpp
Index: clang/unittests/StaticAnalyzer/CallEventTest.cpp =================================================================== --- clang/unittests/StaticAnalyzer/CallEventTest.cpp +++ clang/unittests/StaticAnalyzer/CallEventTest.cpp @@ -8,6 +8,7 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" #include "CheckerRegistration.h" +#include "gmock/gmock.h" #include "clang/Basic/LLVM.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" @@ -22,6 +23,8 @@ #include "clang/Tooling/Tooling.h" #include "gtest/gtest.h" +using testing::MatchesRegex; + namespace clang { namespace ento { namespace { @@ -81,7 +84,7 @@ } )", Diags)); - EXPECT_EQ(Diags, "test.CXXDeallocator: NumArgs: 1\n"); + EXPECT_THAT(Diags, MatchesRegex("test.CXXDeallocator: NumArgs: (1|2)\n")); } } // namespace Index: clang/test/Driver/cl-zc.cpp =================================================================== --- clang/test/Driver/cl-zc.cpp +++ clang/test/Driver/cl-zc.cpp @@ -1,6 +1,19 @@ // 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 -### -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC %s +// RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC-OFF %s +// SIZED-DEALLOC: "-fsized-deallocation" +// SIZED-DEALLOC-OFF-NOT: "-fsized-deallocation" + +// RUN: %clang_cl /c /std:c++11 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-BEFORE-CPP17 %s +// RUN: %clang_cl /c /std:c++14 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-BEFORE-CPP17 %s +// RUN: %clang_cl /c /std:c++17 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-CPP17ONWARDS %s +// RUN: %clang_cl /c /std:c++20 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-CPP17ONWARDS %s +// RUN: %clang_cl /c /std:c++latest -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-CPP17ONWARDS %s +// ALIGNED-NEW-BEFORE-CPP17-NOT: "-faligned-allocation" +// ALIGNED-NEW-CPP17ONWARDS: "-faligned-allocation" + // 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 @@ -6470,6 +6470,7 @@ } CmdArgs.push_back(LanguageStandard.data()); } + bool IsCPP17Onwards = false; if (ImplyVCPPCXXVer) { StringRef LanguageStandard; if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) { @@ -6493,6 +6494,9 @@ } CmdArgs.push_back(LanguageStandard.data()); + + IsCPP17Onwards = + LanguageStandard != "-std=c++11" && LanguageStandard != "-std=c++14"; } Args.addOptInFlag(CmdArgs, options::OPT_fborland_extensions, @@ -6622,9 +6626,15 @@ options::OPT_fno_relaxed_template_template_args); // -fsized-deallocation is off by default, as it is an ABI-breaking change for - // most platforms. - Args.addOptInFlag(CmdArgs, options::OPT_fsized_deallocation, - options::OPT_fno_sized_deallocation); + // most platforms. MSVC turns on /Zc:sizedDealloc by default, starting in + // MSVC 2015. + if (IsWindowsMSVC && IsMSVC2015Compatible && + !Args.getLastArg(options::OPT_fsized_deallocation, + options::OPT_fno_sized_deallocation)) + CmdArgs.push_back("-fsized-deallocation"); + else + Args.addOptInFlag(CmdArgs, options::OPT_fsized_deallocation, + options::OPT_fno_sized_deallocation); // -faligned-allocation is on by default in C++17 onwards and otherwise off // by default. @@ -6635,6 +6645,8 @@ CmdArgs.push_back("-fno-aligned-allocation"); else CmdArgs.push_back("-faligned-allocation"); + } else if (IsCPP17Onwards) { + CmdArgs.push_back("-faligned-allocation"); } // The default new alignment can be specified using a dedicated option or via Index: clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp +++ clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp @@ -1,5 +1,10 @@ // RUN: %check_clang_tidy %s misc-new-delete-overloads %t +// MSVC turns on sized deallocations by default, so we unsupport this test +// for windows. + +// UNSUPPORTED: system-windows + typedef decltype(sizeof(int)) size_t; struct S {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits