diff options
author | Krzysztof Parzyszek <kparzysz@quicinc.com> | 2022-12-18 11:19:40 -0800 |
---|---|---|
committer | Krzysztof Parzyszek <kparzysz@quicinc.com> | 2022-12-18 11:23:54 -0800 |
commit | 205c0589f918f95d2f2c586a01bea2716d73d603 (patch) | |
tree | 38b2227ab6d17d7d189f32a23e5498404d45b634 /clang/lib/Lex/HeaderSearch.cpp | |
parent | a538f7cfb1d71cd1a71b5b6d9fe8672a8b6d973e (diff) | |
download | llvm-205c0589f918f95d2f2c586a01bea2716d73d603.zip llvm-205c0589f918f95d2f2c586a01bea2716d73d603.tar.gz llvm-205c0589f918f95d2f2c586a01bea2716d73d603.tar.bz2 |
Revert "[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional"
This reverts commit 8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d.
The Optional*RefDegradesTo*EntryPtr types want to keep the same size as
the underlying type, which std::optional doesn't guarantee. For use with
llvm::Optional, they define their own storage class, and there is no way
to do that in std::optional.
On top of that, that commit broke builds with older GCCs, where
std::optional was not trivially copyable (static_assert in the clang
sources was failing).
Diffstat (limited to 'clang/lib/Lex/HeaderSearch.cpp')
-rw-r--r-- | clang/lib/Lex/HeaderSearch.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index ffb2780..1ce6df4 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -25,11 +25,11 @@ #include "clang/Lex/Preprocessor.h" #include "llvm/ADT/APInt.h" #include "llvm/ADT/Hashing.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Capacity.h" #include "llvm/Support/Errc.h" @@ -42,7 +42,6 @@ #include <cstddef> #include <cstdio> #include <cstring> -#include <optional> #include <string> #include <system_error> #include <utility> @@ -172,7 +171,7 @@ void HeaderSearch::getHeaderMapFileNames( } std::string HeaderSearch::getCachedModuleFileName(Module *Module) { - std::optional<FileEntryRef> ModuleMap = + Optional<FileEntryRef> ModuleMap = getModuleMap().getModuleMapFileForUniquing(Module); // The ModuleMap maybe a nullptr, when we load a cached C++ module without // *.modulemap file. In this case, just return an empty string. @@ -213,7 +212,7 @@ std::string HeaderSearch::getPrebuiltModuleFileName(StringRef ModuleName, } std::string HeaderSearch::getPrebuiltImplicitModuleFileName(Module *Module) { - std::optional<FileEntryRef> ModuleMap = + Optional<FileEntryRef> ModuleMap = getModuleMap().getModuleMapFileForUniquing(Module); StringRef ModuleName = Module->Name; StringRef ModuleMapPath = ModuleMap->getName(); @@ -416,7 +415,7 @@ StringRef DirectoryLookup::getName() const { return getHeaderMap()->getFileName(); } -std::optional<FileEntryRef> HeaderSearch::getFileAndSuggestModule( +Optional<FileEntryRef> HeaderSearch::getFileAndSuggestModule( StringRef FileName, SourceLocation IncludeLoc, const DirectoryEntry *Dir, bool IsSystemHeaderDir, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule, bool OpenFile /*=true*/, @@ -448,7 +447,7 @@ std::optional<FileEntryRef> HeaderSearch::getFileAndSuggestModule( /// LookupFile - Lookup the specified file in this search path, returning it /// if it exists or returning null if not. -std::optional<FileEntryRef> DirectoryLookup::LookupFile( +Optional<FileEntryRef> DirectoryLookup::LookupFile( StringRef &Filename, HeaderSearch &HS, SourceLocation IncludeLoc, SmallVectorImpl<char> *SearchPath, SmallVectorImpl<char> *RelativePath, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule, @@ -587,7 +586,7 @@ static bool needModuleLookup(Module *RequestingModule, /// DoFrameworkLookup - Do a lookup of the specified file in the current /// DirectoryLookup, which is a framework directory. -std::optional<FileEntryRef> DirectoryLookup::DoFrameworkLookup( +Optional<FileEntryRef> DirectoryLookup::DoFrameworkLookup( StringRef Filename, HeaderSearch &HS, SmallVectorImpl<char> *SearchPath, SmallVectorImpl<char> *RelativePath, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule, @@ -856,7 +855,7 @@ diagnoseFrameworkInclude(DiagnosticsEngine &Diags, SourceLocation IncludeLoc, /// for system \#include's or not (i.e. using <> instead of ""). Includers, if /// non-empty, indicates where the \#including file(s) are, in case a relative /// search is needed. Microsoft mode will pass all \#including files. -std::optional<FileEntryRef> HeaderSearch::LookupFile( +Optional<FileEntryRef> HeaderSearch::LookupFile( StringRef Filename, SourceLocation IncludeLoc, bool isAngled, ConstSearchDirIterator FromDir, ConstSearchDirIterator *CurDirArg, ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>> Includers, @@ -899,7 +898,7 @@ std::optional<FileEntryRef> HeaderSearch::LookupFile( // This is the header that MSVC's header search would have found. ModuleMap::KnownHeader MSSuggestedModule; - std::optional<FileEntryRef> MSFE; + Optional<FileEntryRef> MSFE; // Unless disabled, check to see if the file is in the #includer's // directory. This cannot be based on CurDir, because each includer could be @@ -928,7 +927,7 @@ std::optional<FileEntryRef> HeaderSearch::LookupFile( bool IncluderIsSystemHeader = Includer ? getFileInfo(Includer).DirInfo != SrcMgr::C_User : BuildSystemModule; - if (std::optional<FileEntryRef> FE = getFileAndSuggestModule( + if (Optional<FileEntryRef> FE = getFileAndSuggestModule( TmpDir, IncludeLoc, IncluderAndDir.second, IncluderIsSystemHeader, RequestingModule, SuggestedModule)) { if (!Includer) { @@ -1044,7 +1043,7 @@ std::optional<FileEntryRef> HeaderSearch::LookupFile( bool InUserSpecifiedSystemFramework = false; bool IsInHeaderMap = false; bool IsFrameworkFoundInDir = false; - std::optional<FileEntryRef> File = It->LookupFile( + Optional<FileEntryRef> File = It->LookupFile( Filename, *this, IncludeLoc, SearchPath, RelativePath, RequestingModule, SuggestedModule, InUserSpecifiedSystemFramework, IsFrameworkFoundInDir, IsInHeaderMap, MappedName, OpenFile); @@ -1139,7 +1138,7 @@ std::optional<FileEntryRef> HeaderSearch::LookupFile( ScratchFilename += '/'; ScratchFilename += Filename; - std::optional<FileEntryRef> File = LookupFile( + Optional<FileEntryRef> File = LookupFile( ScratchFilename, IncludeLoc, /*isAngled=*/true, FromDir, &CurDir, Includers.front(), SearchPath, RelativePath, RequestingModule, SuggestedModule, IsMapped, /*IsFrameworkFound=*/nullptr); @@ -1176,7 +1175,7 @@ std::optional<FileEntryRef> HeaderSearch::LookupFile( /// within ".../Carbon.framework/Headers/Carbon.h", check to see if HIToolbox /// is a subframework within Carbon.framework. If so, return the FileEntry /// for the designated file, otherwise return null. -std::optional<FileEntryRef> HeaderSearch::LookupSubframeworkHeader( +Optional<FileEntryRef> HeaderSearch::LookupSubframeworkHeader( StringRef Filename, const FileEntry *ContextFileEnt, SmallVectorImpl<char> *SearchPath, SmallVectorImpl<char> *RelativePath, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule) { |