Sorry for the late response, On Sat, 18 Aug 2018 at 20:10, Nico Weber <tha...@chromium.org> wrote:
> Also, the diag text should probably say "pass '-stdlib=libc++' " not "pass > '-std=libc++' "? > Good catch, thanks! I'll commit a fixup for it. > > On Sat, Aug 18, 2018 at 11:06 PM Nico Weber <tha...@chromium.org> wrote: > >> Should this maybe not be emitted when compiling e.g. .ii files >> (preprocessed output)? I just got this when I built a standalone .ii file >> with some bug repro after I deleted all -I and -isysroot flags and whatnot, >> since they aren't needed for preprocessed files. >> > That would make sense, but I'm not sure how easy it is to determine if a file is already preprocessed. I'll try to create a patch for this fixup. > >> On Tue, Jun 19, 2018 at 6:52 PM Alex Lorenz via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Author: arphaman >>> Date: Tue Jun 19 15:47:53 2018 >>> New Revision: 335081 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=335081&view=rev >>> Log: >>> Recommit r335063: [Darwin] Add a warning for missing include path for >>> libstdc++ >>> >>> The recommit ensures that the tests that failed on bots don't trigger >>> the warning. >>> >>> Xcode 10 removes support for libstdc++, but the users just get a >>> confusing >>> include not file warning when including an STL header (when building for >>> iOS6 >>> which uses libstdc++ by default for example). >>> This patch adds a new warning that lets the user know that the libstdc++ >>> include >>> path was not found to ensure that the user is more aware of why the >>> error occurs. >>> >>> rdar://40830462 >>> >>> Differential Revision: https://reviews.llvm.org/D48297 >>> >>> Added: >>> cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp >>> Modified: >>> cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td >>> cfe/trunk/include/clang/Lex/HeaderSearch.h >>> cfe/trunk/lib/Frontend/InitHeaderSearch.cpp >>> cfe/trunk/test/CodeGenCXX/apple-kext-guard-variable.cpp >>> cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp >>> >>> Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=335081&r1=335080&r2=335081&view=diff >>> >>> ============================================================================== >>> --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original) >>> +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Tue Jun 19 >>> 15:47:53 2018 >>> @@ -236,4 +236,9 @@ def err_invalid_vfs_overlay : Error< >>> >>> def warn_option_invalid_ocl_version : Warning< >>> "OpenCL version %0 does not support the option '%1'">, >>> InGroup<Deprecated>; >>> + >>> +def warn_stdlibcxx_not_found : Warning< >>> + "include path for stdlibc++ headers not found; pass '-std=libc++' on >>> the " >>> + "command line to use the libc++ standard library instead">, >>> + InGroup<DiagGroup<"stdlibcxx-not-found">>; >>> } >>> >>> Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=335081&r1=335080&r2=335081&view=diff >>> >>> ============================================================================== >>> --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original) >>> +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Tue Jun 19 15:47:53 2018 >>> @@ -272,6 +272,8 @@ public: >>> >>> FileManager &getFileMgr() const { return FileMgr; } >>> >>> + DiagnosticsEngine &getDiags() const { return Diags; } >>> + >>> /// Interface for setting the file search paths. >>> void SetSearchPaths(const std::vector<DirectoryLookup> &dirs, >>> unsigned angledDirIdx, unsigned systemDirIdx, >>> >>> Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=335081&r1=335080&r2=335081&view=diff >>> >>> ============================================================================== >>> --- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original) >>> +++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Tue Jun 19 15:47:53 2018 >>> @@ -14,6 +14,7 @@ >>> #include "clang/Basic/FileManager.h" >>> #include "clang/Basic/LangOptions.h" >>> #include "clang/Config/config.h" // C_INCLUDE_DIRS >>> +#include "clang/Frontend/FrontendDiagnostic.h" >>> #include "clang/Frontend/Utils.h" >>> #include "clang/Lex/HeaderMap.h" >>> #include "clang/Lex/HeaderSearch.h" >>> @@ -55,11 +56,13 @@ public: >>> >>> /// AddPath - Add the specified path to the specified group list, >>> prefixing >>> /// the sysroot if used. >>> - void AddPath(const Twine &Path, IncludeDirGroup Group, bool >>> isFramework); >>> + /// Returns true if the path exists, false if it was ignored. >>> + bool AddPath(const Twine &Path, IncludeDirGroup Group, bool >>> isFramework); >>> >>> /// AddUnmappedPath - Add the specified path to the specified group >>> list, >>> /// without performing any sysroot remapping. >>> - void AddUnmappedPath(const Twine &Path, IncludeDirGroup Group, >>> + /// Returns true if the path exists, false if it was ignored. >>> + bool AddUnmappedPath(const Twine &Path, IncludeDirGroup Group, >>> bool isFramework); >>> >>> /// AddSystemHeaderPrefix - Add the specified prefix to the system >>> header >>> @@ -70,10 +73,9 @@ public: >>> >>> /// AddGnuCPlusPlusIncludePaths - Add the necessary paths to support >>> a gnu >>> /// libstdc++. >>> - void AddGnuCPlusPlusIncludePaths(StringRef Base, >>> - StringRef ArchDir, >>> - StringRef Dir32, >>> - StringRef Dir64, >>> + /// Returns true if the \p Base path was found, false if it does not >>> exist. >>> + bool AddGnuCPlusPlusIncludePaths(StringRef Base, StringRef ArchDir, >>> + StringRef Dir32, StringRef Dir64, >>> const llvm::Triple &triple); >>> >>> /// AddMinGWCPlusPlusIncludePaths - Add the necessary paths to >>> support a MinGW >>> @@ -88,7 +90,8 @@ public: >>> >>> // AddDefaultCPlusPlusIncludePaths - Add paths that should be >>> searched when >>> // compiling c++. >>> - void AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, >>> + void AddDefaultCPlusPlusIncludePaths(const LangOptions &LangOpts, >>> + const llvm::Triple &triple, >>> const HeaderSearchOptions >>> &HSOpts); >>> >>> /// AddDefaultSystemIncludePaths - Adds the default system include >>> paths so >>> @@ -112,7 +115,7 @@ static bool CanPrefixSysroot(StringRef P >>> #endif >>> } >>> >>> -void InitHeaderSearch::AddPath(const Twine &Path, IncludeDirGroup Group, >>> +bool InitHeaderSearch::AddPath(const Twine &Path, IncludeDirGroup Group, >>> bool isFramework) { >>> // Add the path with sysroot prepended, if desired and this is a >>> system header >>> // group. >>> @@ -120,15 +123,14 @@ void InitHeaderSearch::AddPath(const Twi >>> SmallString<256> MappedPathStorage; >>> StringRef MappedPathStr = Path.toStringRef(MappedPathStorage); >>> if (CanPrefixSysroot(MappedPathStr)) { >>> - AddUnmappedPath(IncludeSysroot + Path, Group, isFramework); >>> - return; >>> + return AddUnmappedPath(IncludeSysroot + Path, Group, isFramework); >>> } >>> } >>> >>> - AddUnmappedPath(Path, Group, isFramework); >>> + return AddUnmappedPath(Path, Group, isFramework); >>> } >>> >>> -void InitHeaderSearch::AddUnmappedPath(const Twine &Path, >>> IncludeDirGroup Group, >>> +bool InitHeaderSearch::AddUnmappedPath(const Twine &Path, >>> IncludeDirGroup Group, >>> bool isFramework) { >>> assert(!Path.isTriviallyEmpty() && "can't handle empty path here"); >>> >>> @@ -150,7 +152,7 @@ void InitHeaderSearch::AddUnmappedPath(c >>> if (const DirectoryEntry *DE = FM.getDirectory(MappedPathStr)) { >>> IncludePath.push_back( >>> std::make_pair(Group, DirectoryLookup(DE, Type, isFramework))); >>> - return; >>> + return true; >>> } >>> >>> // Check to see if this is an apple-style headermap (which are not >>> allowed to >>> @@ -162,7 +164,7 @@ void InitHeaderSearch::AddUnmappedPath(c >>> IncludePath.push_back( >>> std::make_pair(Group, >>> DirectoryLookup(HM, Type, Group == >>> IndexHeaderMap))); >>> - return; >>> + return true; >>> } >>> } >>> } >>> @@ -170,15 +172,16 @@ void InitHeaderSearch::AddUnmappedPath(c >>> if (Verbose) >>> llvm::errs() << "ignoring nonexistent directory \"" >>> << MappedPathStr << "\"\n"; >>> + return false; >>> } >>> >>> -void InitHeaderSearch::AddGnuCPlusPlusIncludePaths(StringRef Base, >>> +bool InitHeaderSearch::AddGnuCPlusPlusIncludePaths(StringRef Base, >>> StringRef ArchDir, >>> StringRef Dir32, >>> StringRef Dir64, >>> const llvm::Triple >>> &triple) { >>> // Add the base dir >>> - AddPath(Base, CXXSystem, false); >>> + bool IsBaseFound = AddPath(Base, CXXSystem, false); >>> >>> // Add the multilib dirs >>> llvm::Triple::ArchType arch = triple.getArch(); >>> @@ -190,6 +193,7 @@ void InitHeaderSearch::AddGnuCPlusPlusIn >>> >>> // Add the backward dir >>> AddPath(Base + "/backward", CXXSystem, false); >>> + return IsBaseFound; >>> } >>> >>> void InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(StringRef Base, >>> @@ -354,46 +358,55 @@ void InitHeaderSearch::AddDefaultCInclud >>> } >>> } >>> >>> -void InitHeaderSearch:: >>> -AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, const >>> HeaderSearchOptions &HSOpts) { >>> +void InitHeaderSearch::AddDefaultCPlusPlusIncludePaths( >>> + const LangOptions &LangOpts, const llvm::Triple &triple, >>> + const HeaderSearchOptions &HSOpts) { >>> llvm::Triple::OSType os = triple.getOS(); >>> // FIXME: temporary hack: hard-coded paths. >>> >>> if (triple.isOSDarwin()) { >>> + bool IsBaseFound = true; >>> switch (triple.getArch()) { >>> default: break; >>> >>> case llvm::Triple::ppc: >>> case llvm::Triple::ppc64: >>> - AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", >>> - "powerpc-apple-darwin10", "", "ppc64", >>> - triple); >>> - AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0", >>> - "powerpc-apple-darwin10", "", "ppc64", >>> - triple); >>> + IsBaseFound = >>> AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", >>> + >>> "powerpc-apple-darwin10", "", >>> + "ppc64", triple); >>> + IsBaseFound |= >>> AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0", >>> + >>> "powerpc-apple-darwin10", "", >>> + "ppc64", triple); >>> break; >>> >>> case llvm::Triple::x86: >>> case llvm::Triple::x86_64: >>> - AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", >>> - "i686-apple-darwin10", "", "x86_64", >>> triple); >>> - AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0", >>> - "i686-apple-darwin8", "", "", triple); >>> + IsBaseFound = >>> AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", >>> + "i686-apple-darwin10", >>> "", >>> + "x86_64", triple); >>> + IsBaseFound |= AddGnuCPlusPlusIncludePaths( >>> + "/usr/include/c++/4.0.0", "i686-apple-darwin8", "", "", >>> triple); >>> break; >>> >>> case llvm::Triple::arm: >>> case llvm::Triple::thumb: >>> - AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", >>> - "arm-apple-darwin10", "v7", "", >>> triple); >>> - AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", >>> - "arm-apple-darwin10", "v6", "", >>> triple); >>> + IsBaseFound = AddGnuCPlusPlusIncludePaths( >>> + "/usr/include/c++/4.2.1", "arm-apple-darwin10", "v7", "", >>> triple); >>> + IsBaseFound |= AddGnuCPlusPlusIncludePaths( >>> + "/usr/include/c++/4.2.1", "arm-apple-darwin10", "v6", "", >>> triple); >>> break; >>> >>> case llvm::Triple::aarch64: >>> - AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1", >>> - "arm64-apple-darwin10", "", "", >>> triple); >>> + IsBaseFound = AddGnuCPlusPlusIncludePaths( >>> + "/usr/include/c++/4.2.1", "arm64-apple-darwin10", "", "", >>> triple); >>> break; >>> } >>> + // Warn when compiling pure C++ / Objective-C++ only. >>> + if (!IsBaseFound && >>> + !(LangOpts.CUDA || LangOpts.OpenCL || LangOpts.RenderScript)) { >>> + Headers.getDiags().Report(SourceLocation(), >>> + diag::warn_stdlibcxx_not_found); >>> + } >>> return; >>> } >>> >>> @@ -478,7 +491,7 @@ void InitHeaderSearch::AddDefaultInclude >>> } >>> AddPath("/usr/include/c++/v1", CXXSystem, false); >>> } else { >>> - AddDefaultCPlusPlusIncludePaths(triple, HSOpts); >>> + AddDefaultCPlusPlusIncludePaths(Lang, triple, HSOpts); >>> } >>> } >>> >>> >>> Modified: cfe/trunk/test/CodeGenCXX/apple-kext-guard-variable.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/apple-kext-guard-variable.cpp?rev=335081&r1=335080&r2=335081&view=diff >>> >>> ============================================================================== >>> --- cfe/trunk/test/CodeGenCXX/apple-kext-guard-variable.cpp (original) >>> +++ cfe/trunk/test/CodeGenCXX/apple-kext-guard-variable.cpp Tue Jun 19 >>> 15:47:53 2018 >>> @@ -1,4 +1,4 @@ >>> -// RUN: %clang -target x86_64-apple-darwin10 -S -o %t.s -mkernel >>> -Xclang -verify %s >>> +// RUN: %clang -target x86_64-apple-darwin10 -S -o %t.s >>> -Wno-stdlibcxx-not-found -mkernel -Xclang -verify %s >>> >>> // rdar://problem/9143356 >>> >>> >>> Added: cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp?rev=335081&view=auto >>> >>> ============================================================================== >>> --- cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp (added) >>> +++ cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp Tue Jun 19 >>> 15:47:53 2018 >>> @@ -0,0 +1,5 @@ >>> +// 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 >>> +// CHECK: include path for stdlibc++ headers not found; pass >>> '-std=libc++' on the command line to use the libc++ standard library instead >>> + >>> +// expected-no-diagnostics >>> >>> Modified: cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp?rev=335081&r1=335080&r2=335081&view=diff >>> >>> ============================================================================== >>> --- cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp (original) >>> +++ cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp Tue Jun 19 >>> 15:47:53 2018 >>> @@ -1,6 +1,6 @@ >>> // REQUIRES: x86-registered-target >>> -// RUN: %clang -target i386-apple-darwin -std=c++11 -fblocks >>> -Wframe-larger-than=70 -Xclang -verify -o /dev/null -c %s >>> -// RUN: %clang -target i386-apple-darwin -std=c++11 -fblocks >>> -Wframe-larger-than=70 -Xclang -verify -o /dev/null -c %s -DIS_SYSHEADER >>> +// RUN: %clang -target i386-apple-darwin -std=c++11 -fblocks >>> -Wframe-larger-than=70 -Wno-stdlibcxx-not-found -Xclang -verify -o >>> /dev/null -c %s >>> +// RUN: %clang -target i386-apple-darwin -std=c++11 -fblocks >>> -Wframe-larger-than=70 -Wno-stdlibcxx-not-found -Xclang -verify -o >>> /dev/null -c %s -DIS_SYSHEADER >>> >>> // Test that: >>> // * The driver passes the option through to the backend. >>> >>> >>> _______________________________________________ >>> cfe-commits mailing list >>> cfe-commits@lists.llvm.org >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >>> >>
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits