r205095 - Driver: implement addClangWarningOptions
Tim Northover
tnorthover at apple.com
Sat Mar 29 06:16:12 PDT 2014
Author: tnorthover
Date: Sat Mar 29 08:16:12 2014
New Revision: 205095
URL: http://llvm.org/viewvc/llvm-project?rev=205095&view=rev
Log:
Driver: implement addClangWarningOptions
This function allows certain platforms to enable or disable diagnostics
by default.
Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=205095&r1=205094&r2=205095&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Sat Mar 29 08:16:12 2014
@@ -283,6 +283,9 @@ public:
virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const;
+ /// \brief Add warning options that need to be passed to cc1 for this target.
+ virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const;
+
// GetRuntimeLibType - Determine the runtime library type to use with the
// given compilation arguments.
virtual RuntimeLibType
Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=205095&r1=205094&r2=205095&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Sat Mar 29 08:16:12 2014
@@ -250,6 +250,8 @@ void ToolChain::addClangTargetOptions(co
ArgStringList &CC1Args) const {
}
+void ToolChain::addClangWarningOptions(ArgStringList &CC1Args) const {}
+
ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType(
const ArgList &Args) const
{
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=205095&r1=205094&r2=205095&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Sat Mar 29 08:16:12 2014
@@ -242,6 +242,20 @@ DarwinClang::DarwinClang(const Driver &D
getProgramPaths().push_back(getDriver().Dir);
}
+void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const {
+ // For iOS, 64-bit, promote certain warnings to errors.
+ if (!isTargetMacOS() && getTriple().isArch64Bit()) {
+ // Always enable -Wdeprecated-objc-isa-usage and promote it
+ // to an error.
+ CC1Args.push_back("-Wdeprecated-objc-isa-usage");
+ CC1Args.push_back("-Werror=deprecated-objc-isa-usage");
+
+ // Also error about implicit function declarations, as that
+ // can impact calling conventions.
+ CC1Args.push_back("-Werror=implicit-function-declaration");
+ }
+}
+
/// \brief Determine whether Objective-C automated reference counting is
/// enabled.
static bool isObjCAutoRefCount(const ArgList &Args) {
Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=205095&r1=205094&r2=205095&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Sat Mar 29 08:16:12 2014
@@ -488,6 +488,8 @@ public:
AddCCKextLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
+ virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const;
+
void
AddLinkARCArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=205095&r1=205094&r2=205095&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sat Mar 29 08:16:12 2014
@@ -2116,6 +2116,11 @@ void Clang::ConstructJob(Compilation &C,
std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args);
CmdArgs.push_back(Args.MakeArgString(TripleStr));
+ // Push all default warning arguments that are specific to
+ // the given target. These come before user provided warning options
+ // are provided.
+ getToolChain().addClangWarningOptions(CmdArgs);
+
// Select the appropriate action.
RewriteKind rewriteKind = RK_None;
More information about the cfe-commits
mailing list