From 1fc2d241d33272dfd4084f4cea86905cee621b76 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Thu, 6 Dec 2018 22:45:58 +0000 Subject: [PATCH] [frontend][darwin] warn_stdlibcxx_not_found: supress warning for preprocessed input Addresses second post-commit feedback for r335081 from Nico git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348540 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/CompilerInvocation.cpp | 8 +++++++- test/Frontend/warning-stdlibcxx-darwin.cpp | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 1d48863393..1eeb9732fd 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -3240,6 +3240,7 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, Res.getTargetOpts(), Res.getFrontendOpts()); ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args, Res.getFileSystemOpts().WorkingDir); + llvm::Triple T(Res.getTargetOpts().Triple); if (DashX.getFormat() == InputKind::Precompiled || DashX.getLanguage() == InputKind::LLVM_IR) { // ObjCAAutoRefCount and Sanitize LangOpts are used to setup the @@ -3260,6 +3261,12 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, Res.getPreprocessorOpts(), Diags); if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC) LangOpts.ObjCExceptions = 1; + if (T.isOSDarwin() && DashX.isPreprocessed()) { + // Supress the darwin-specific 'stdlibcxx-not-found' diagnostic for + // preprocessed input as we don't expect it to be used with -std=libc++ + // anyway. + Res.getDiagnosticOpts().Warnings.push_back("no-stdlibcxx-not-found"); + } } LangOpts.FunctionAlignment = @@ -3291,7 +3298,6 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, Res.getFrontendOpts().ProgramAction); // Turn on -Wspir-compat for SPIR target. - llvm::Triple T(Res.getTargetOpts().Triple); auto Arch = T.getArch(); if (Arch == llvm::Triple::spir || Arch == llvm::Triple::spir64) { Res.getDiagnosticOpts().Warnings.push_back("spir-compat"); diff --git a/test/Frontend/warning-stdlibcxx-darwin.cpp b/test/Frontend/warning-stdlibcxx-darwin.cpp index 9f31373be7..697fe27c73 100644 --- a/test/Frontend/warning-stdlibcxx-darwin.cpp +++ b/test/Frontend/warning-stdlibcxx-darwin.cpp @@ -1,5 +1,6 @@ // RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist %s 2>&1 | FileCheck %s // RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist -stdlib=libc++ %s -verify +// RUN: %clang -cc1 -x c++-cpp-output -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist %s -verify // CHECK: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead // expected-no-diagnostics -- 2.40.0