diff options
Diffstat (limited to 'contrib/llvm-project/clang/include/clang/Basic/Module.h')
-rw-r--r-- | contrib/llvm-project/clang/include/clang/Basic/Module.h | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/contrib/llvm-project/clang/include/clang/Basic/Module.h b/contrib/llvm-project/clang/include/clang/Basic/Module.h index 6b932a9a84d0..f5b176f8d20b 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/Module.h +++ b/contrib/llvm-project/clang/include/clang/Basic/Module.h @@ -15,6 +15,8 @@ #ifndef LLVM_CLANG_BASIC_MODULE_H #define LLVM_CLANG_BASIC_MODULE_H +#include "clang/Basic/DirectoryEntry.h" +#include "clang/Basic/FileEntry.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseSet.h" @@ -43,8 +45,6 @@ class raw_ostream; namespace clang { -class DirectoryEntry; -class FileEntry; class FileManager; class LangOptions; class TargetInfo; @@ -62,6 +62,15 @@ struct ASTFileSignature : std::array<uint8_t, 20> { explicit operator bool() const { return *this != BaseT({{0}}); } + /// Returns the value truncated to the size of an uint64_t. + uint64_t truncatedValue() const { + uint64_t Value = 0; + static_assert(sizeof(*this) >= sizeof(uint64_t), "No need to truncate."); + for (unsigned I = 0; I < sizeof(uint64_t); ++I) + Value |= static_cast<uint64_t>((*this)[I]) << (I * 8); + return Value; + } + static ASTFileSignature create(StringRef Bytes) { return create(Bytes.bytes_begin(), Bytes.bytes_end()); } @@ -124,7 +133,9 @@ public: std::string PresumedModuleMapFile; /// The umbrella header or directory. - const void *Umbrella = nullptr; + llvm::PointerUnion<const FileEntryRef::MapEntry *, + const DirectoryEntryRef::MapEntry *> + Umbrella; /// The module signature. ASTFileSignature Signature; @@ -151,7 +162,7 @@ private: /// The AST file if this is a top-level module which has a /// corresponding serialized AST file, or null otherwise. - const FileEntry *ASTFile = nullptr; + Optional<FileEntryRef> ASTFile; /// The top-level headers associated with this module. llvm::SmallSetVector<const FileEntry *, 2> TopHeaders; @@ -179,18 +190,18 @@ public: /// file. struct Header { std::string NameAsWritten; - const FileEntry *Entry; + OptionalFileEntryRefDegradesToFileEntryPtr Entry; - explicit operator bool() { return Entry; } + explicit operator bool() { return Entry != None; } }; /// Information about a directory name as found in the module map /// file. struct DirectoryName { std::string NameAsWritten; - const DirectoryEntry *Entry; + OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr Entry; - explicit operator bool() { return Entry; } + explicit operator bool() { return Entry != None; } }; /// The headers that are part of this module. @@ -293,9 +304,6 @@ public: /// to a regular (public) module map. unsigned ModuleMapIsPrivate : 1; - /// Whether Umbrella is a directory or header. - unsigned HasUmbrellaDir : 1; - /// Describes the visibility of the various names within a /// particular module. enum NameVisibilityKind { @@ -457,8 +465,12 @@ public: /// Determine whether this module is a submodule. bool isSubModule() const { return Parent != nullptr; } - /// Determine whether this module is a submodule of the given other - /// module. + /// Check if this module is a (possibly transitive) submodule of \p Other. + /// + /// The 'A is a submodule of B' relation is a partial order based on the + /// the parent-child relationship between individual modules. + /// + /// Returns \c false if \p Other is \c nullptr. bool isSubModuleOf(const Module *Other) const; /// Determine whether this module is a part of a framework, @@ -516,14 +528,14 @@ public: } /// The serialized AST file for this module, if one was created. - const FileEntry *getASTFile() const { + OptionalFileEntryRefDegradesToFileEntryPtr getASTFile() const { return getTopLevelModule()->ASTFile; } /// Set the serialized AST file for the top-level module of this module. - void setASTFile(const FileEntry *File) { - assert((File == nullptr || getASTFile() == nullptr || - getASTFile() == File) && "file path changed"); + void setASTFile(Optional<FileEntryRef> File) { + assert((!File || !getASTFile() || getASTFile() == File) && + "file path changed"); getTopLevelModule()->ASTFile = File; } @@ -534,15 +546,16 @@ public: /// Retrieve the header that serves as the umbrella header for this /// module. Header getUmbrellaHeader() const { - if (!HasUmbrellaDir) - return Header{UmbrellaAsWritten, - static_cast<const FileEntry *>(Umbrella)}; + if (auto *ME = Umbrella.dyn_cast<const FileEntryRef::MapEntry *>()) + return Header{UmbrellaAsWritten, FileEntryRef(*ME)}; return Header{}; } /// Determine whether this module has an umbrella directory that is /// not based on an umbrella header. - bool hasUmbrellaDir() const { return Umbrella && HasUmbrellaDir; } + bool hasUmbrellaDir() const { + return Umbrella && Umbrella.is<const DirectoryEntryRef::MapEntry *>(); + } /// Add a top-level header associated with this module. void addTopHeader(const FileEntry *File); |