jyknight created this revision. jyknight added reviewers: rsmith, chandlerc. Herald added a subscriber: arphaman.
This warning, Wexperimental-driver-option, is on by default, exempt from -Werror, and may be disabled. Additionally, change the documentation to note that these options are not intended for common usage. https://reviews.llvm.org/D55150 Files: clang/docs/UsersManual.rst clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/tools/libclang/CIndex.cpp
Index: clang/tools/libclang/CIndex.cpp =================================================================== --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -3419,6 +3419,11 @@ if (options & CXTranslationUnit_KeepGoing) Diags->setSuppressAfterFatalError(false); + // Suppress driver warning for use of -Xclang, since we add it ourselves. + Diags->setSeverityForGroup(diag::Flavor::WarningOrError, + "experimental-driver-option", + diag::Severity::Ignored, SourceLocation()); + // Recover resources if we crash before exiting this function. llvm::CrashRecoveryContextCleanupRegistrar<DiagnosticsEngine, llvm::CrashRecoveryContextReleaseRefCleanup<DiagnosticsEngine> > Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -4994,6 +4994,11 @@ // Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option // parser. + if (Args.hasArg(options::OPT_Xclang)) + D.Diag(diag::warn_drv_xclang_option); + if (Args.hasArg(options::OPT_mllvm)) + D.Diag(diag::warn_drv_mllvm_option); + // -finclude-default-header flag is for preprocessor, // do not pass it to other cc1 commands when save-temps is enabled if (C.getDriver().isSaveTempsEnabled() && @@ -5926,6 +5931,8 @@ CollectArgsForIntegratedAssembler(C, Args, CmdArgs, getToolChain().getDriver()); + if (Args.hasArg(options::OPT_mllvm)) + D.Diag(diag::warn_drv_mllvm_option); Args.AddAllArgs(CmdArgs, options::OPT_mllvm); assert(Output.isFilename() && "Unexpected lipo output."); Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -466,7 +466,7 @@ HelpText<"Pass <arg> to the assembler">, MetaVarName<"<arg>">, Group<CompileOnly_Group>; def Xclang : Separate<["-"], "Xclang">, - HelpText<"Pass <arg> to the clang compiler">, MetaVarName<"<arg>">, + HelpText<"Pass <arg> to the clang cc1 frontend. For experimental use only">, MetaVarName<"<arg>">, Flags<[DriverOption, CoreOption]>, Group<CompileOnly_Group>; def Xcuda_fatbinary : Separate<["-"], "Xcuda-fatbinary">, HelpText<"Pass <arg> to fatbinary invocation">, MetaVarName<"<arg>">; @@ -2002,7 +2002,7 @@ def mlinker_version_EQ : Joined<["-"], "mlinker-version=">, Flags<[DriverOption]>; def mllvm : Separate<["-"], "mllvm">, Flags<[CC1Option,CC1AsOption,CoreOption]>, - HelpText<"Additional arguments to forward to LLVM's option processing">; + HelpText<"Additional arguments to forward to LLVM's option processing. For experimental use only">; def mmacosx_version_min_EQ : Joined<["-"], "mmacosx-version-min=">, Group<m_Group>, HelpText<"Set Mac OS X deployment target">; def mmacos_version_min_EQ : Joined<["-"], "mmacos-version-min=">, Index: clang/include/clang/Basic/DiagnosticGroups.td =================================================================== --- clang/include/clang/Basic/DiagnosticGroups.td +++ clang/include/clang/Basic/DiagnosticGroups.td @@ -1039,3 +1039,7 @@ // A warning group specifically for warnings related to function // multiversioning. def FunctionMultiVersioning : DiagGroup<"function-multiversion">; + +// Warning for command-line options that are not a supported part of the clang command-line interface. +// Warnings in this group should be on by default, and exempt from -Werror. +def ExperimentalDriverOption : DiagGroup<"experimental-driver-option">; Index: clang/include/clang/Basic/DiagnosticDriverKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticDriverKinds.td +++ clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -405,4 +405,14 @@ def warn_drv_moutline_unsupported_opt : Warning< "The '%0' architecture does not support -moutline; flag ignored">, InGroup<OptionIgnored>; + +def warn_drv_xclang_option : Warning< + "-Xclang options are for experimental use only; future compatibility may not be preserved">, + InGroup<ExperimentalDriverOption>, DefaultWarnNoWerror; + +def warn_drv_mllvm_option : Warning< + "-mllvm options are for experimental use only; future compatibility may not be preserved">, + InGroup<ExperimentalDriverOption>, DefaultWarnNoWerror; + } + Index: clang/docs/UsersManual.rst =================================================================== --- clang/docs/UsersManual.rst +++ clang/docs/UsersManual.rst @@ -3134,7 +3134,7 @@ --version Print version information -v Show commands to run and use verbose output -W<warning> Enable the specified warning - -Xclang <arg> Pass <arg> to the clang compiler + -Xclang <arg> Pass <arg> to the clang cc1 frontend. For experimental use only. The /clang: Option ^^^^^^^^^^^^^^^^^^
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits