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 Enable the specified warning - -Xclang Pass to the clang compiler + -Xclang Pass to the clang cc1 frontend. For experimental use only. The /clang: 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; + +def warn_drv_xclang_option : Warning< + "-Xclang options are for experimental use only; future compatibility may not be preserved">, + InGroup, DefaultWarnNoWerror; + +def warn_drv_mllvm_option : Warning< + "-mllvm options are for experimental use only; future compatibility may not be preserved">, + InGroup, DefaultWarnNoWerror; + } + 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/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -466,7 +466,7 @@ HelpText<"Pass to the assembler">, MetaVarName<"">, Group; def Xclang : Separate<["-"], "Xclang">, - HelpText<"Pass to the clang compiler">, MetaVarName<"">, + HelpText<"Pass to the clang cc1 frontend. For experimental use only">, MetaVarName<"">, Flags<[DriverOption, CoreOption]>, Group; def Xcuda_fatbinary : Separate<["-"], "Xcuda-fatbinary">, HelpText<"Pass to fatbinary invocation">, MetaVarName<"">; @@ -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, HelpText<"Set Mac OS X deployment target">; def mmacos_version_min_EQ : Joined<["-"], "mmacos-version-min=">, 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/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 >