diff --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h --- a/clang/include/clang/Frontend/CompilerInvocation.h +++ b/clang/include/clang/Frontend/CompilerInvocation.h @@ -249,7 +249,8 @@ /// Generate command line options from DiagnosticOptions. static void GenerateDiagnosticArgs(const DiagnosticOptions &Opts, SmallVectorImpl &Args, - StringAllocator SA, bool DefaultDiagColor); + StringAllocator SA, bool DefaultDiagColor, + const llvm::Triple &T, InputKind DashX); /// Parse command line options that map to LangOptions. static bool ParseLangArgsImpl(LangOptions &Opts, llvm::opt::ArgList &Args, diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2295,7 +2295,8 @@ void CompilerInvocation::GenerateDiagnosticArgs( const DiagnosticOptions &Opts, SmallVectorImpl &Args, - StringAllocator SA, bool DefaultDiagColor) { + StringAllocator SA, bool DefaultDiagColor, const llvm::Triple &T, + InputKind DashX) { const DiagnosticOptions *DiagnosticOpts = &Opts; #define DIAG_OPTION_WITH_MARSHALLING( \ PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ @@ -2343,6 +2344,13 @@ // This option is automatically generated from UndefPrefixes. if (Warning == "undef-prefix") continue; + // This warning was manufactured, don't put it on the command line. + if (Warning == "no-stdlibcxx-not-found" && T.isOSDarwin() && + DashX.isPreprocessed()) + continue; + // This warning was manufactured, don't put it on the command line. + if (Warning == "spir-compat" && T.isSPIR()) + continue; Args.push_back(SA(StringRef("-W") + Warning)); } @@ -4831,11 +4839,12 @@ void CompilerInvocation::generateCC1CommandLine( SmallVectorImpl &Args, StringAllocator SA) const { llvm::Triple T(TargetOpts->Triple); + InputKind DashX = FrontendOpts.DashX; GenerateFileSystemArgs(FileSystemOpts, Args, SA); GenerateMigratorArgs(MigratorOpts, Args, SA); GenerateAnalyzerArgs(*AnalyzerOpts, Args, SA); - GenerateDiagnosticArgs(*DiagnosticOpts, Args, SA, false); + GenerateDiagnosticArgs(*DiagnosticOpts, Args, SA, false, T, DashX); GenerateFrontendArgs(FrontendOpts, Args, SA, LangOpts->IsHeaderFile); GenerateTargetArgs(*TargetOpts, Args, SA); GenerateHeaderSearchArgs(*HeaderSearchOpts, Args, SA);