From 398c610b16728b4398214367dd0effd9d2e61340 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 4 Feb 2011 02:20:39 +0000 Subject: [PATCH] build: Add support for DISABLE_DEFAULT_STRICT_ALIASING, which does what one might expect. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124848 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/ToolChain.h | 6 +++++- lib/Driver/ToolChains.h | 7 +++++++ lib/Driver/Tools.cpp | 6 +++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h index dfd39bc594..f0012bd851 100644 --- a/include/clang/Driver/ToolChain.h +++ b/include/clang/Driver/ToolChain.h @@ -108,11 +108,15 @@ public: /// IsBlocksDefault - Does this tool chain enable -fblocks by default. virtual bool IsBlocksDefault() const { return false; } - + /// IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as /// by default. virtual bool IsIntegratedAssemblerDefault() const { return false; } + /// IsStrictAliasingDefault - Does this tool chain use -fstrict-aliasing by + /// default. + virtual bool IsStrictAliasingDefault() const { return true; } + /// IsObjCDefaultSynthPropertiesDefault - Does this tool chain enable /// -fobjc-default-synthesize-properties by default. virtual bool IsObjCDefaultSynthPropertiesDefault() const { return false; } diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index 005597dccc..870621268e 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -176,6 +176,13 @@ public: getTriple().getArch() == llvm::Triple::x86_64); #endif } + virtual bool IsStrictAliasingDefault() const { +#ifdef DISABLE_DEFAULT_STRICT_ALIASING + return false; +#else + return ToolChain::IsStrictAliasingDefault(); +#endif + } virtual bool IsObjCDefaultSynthPropertiesDefault() const { // Always allow default synthesized properties on Darwin. diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index d1d8873c3a..f3d2d4b88b 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1007,9 +1007,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (!Args.hasFlag(options::OPT_fzero_initialized_in_bss, options::OPT_fno_zero_initialized_in_bss)) CmdArgs.push_back("-mno-zero-initialized-in-bss"); - if (Args.hasFlag(options::OPT_fno_strict_aliasing, - options::OPT_fstrict_aliasing, - false)) + if (!Args.hasFlag(options::OPT_fstrict_aliasing, + options::OPT_fno_strict_aliasing, + getToolChain().IsStrictAliasingDefault())) CmdArgs.push_back("-relaxed-aliasing"); // Decide whether to use verbose asm. Verbose assembly is the default on -- 2.40.0