[clang] 668ee3f - [clang] Default to -fno-sized-deallocation for AIX (#97076)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 1 12:37:56 PDT 2024
Author: Xing Xue
Date: 2024-07-01T15:37:52-04:00
New Revision: 668ee3f5478c1e1b549923667cf1b8704b1a0bd0
URL: https://github.com/llvm/llvm-project/commit/668ee3f5478c1e1b549923667cf1b8704b1a0bd0
DIFF: https://github.com/llvm/llvm-project/commit/668ee3f5478c1e1b549923667cf1b8704b1a0bd0.diff
LOG: [clang] Default to -fno-sized-deallocation for AIX (#97076)
Some `libc++` LIT test cases and user code define their own version of
`operator delete` that are not sized. With `-fno-sized-deallocation`,
destructors call the non-sized `operator delete` and it will be resolved
to the user defined version. However, with `-fsized-deallocation`,
destructors will call the sized `operator delete` which will be resolved
to the weak definition in `libc++abi` because the user code does not
define the corresponding sized version. The `libc++abi` sized `operator
delete` in turn calls the non-sized version of `operator delete` of the
same shared object inside `libc++abi` instead of the user defined
version on AIX because runtime linking is not the default for AIX and
therefore, fails the tests or user code. This patch sets
`-fno-sized-deallocation` as the default for AIX if neither
`-fsize-deallocation` nor `-fno-sized-deallocation` is explicitly set,
similar to what is done for ZOS.
Added:
Modified:
clang/lib/Driver/ToolChains/AIX.cpp
clang/unittests/StaticAnalyzer/CallEventTest.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index 381d72e045b95..b04502a57a9f7 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -551,6 +551,12 @@ void AIX::addClangTargetOptions(
if (Args.hasFlag(options::OPT_fxl_pragma_pack,
options::OPT_fno_xl_pragma_pack, true))
CC1Args.push_back("-fxl-pragma-pack");
+
+ // Pass "-fno-sized-deallocation" only when the user hasn't manually enabled
+ // or disabled sized deallocations.
+ if (!Args.getLastArgNoClaim(options::OPT_fsized_deallocation,
+ options::OPT_fno_sized_deallocation))
+ CC1Args.push_back("-fno-sized-deallocation");
}
void AIX::addProfileRTLibs(const llvm::opt::ArgList &Args,
diff --git a/clang/unittests/StaticAnalyzer/CallEventTest.cpp b/clang/unittests/StaticAnalyzer/CallEventTest.cpp
index 7c4132788ca7e..987162f9fdf34 100644
--- a/clang/unittests/StaticAnalyzer/CallEventTest.cpp
+++ b/clang/unittests/StaticAnalyzer/CallEventTest.cpp
@@ -76,7 +76,12 @@ TEST(CXXDeallocatorCall, SimpleDestructor) {
}
)",
Diags));
+#if defined(_AIX) || defined(__MVS__)
+ // AIX and ZOS default to -fno-sized-deallocation.
+ EXPECT_EQ(Diags, "test.CXXDeallocator: NumArgs: 1\n");
+#else
EXPECT_EQ(Diags, "test.CXXDeallocator: NumArgs: 2\n");
+#endif
}
} // namespace
More information about the cfe-commits
mailing list