diff options
Diffstat (limited to 'contrib/llvm-project/clang/include/clang/Serialization/ASTWriter.h')
-rw-r--r-- | contrib/llvm-project/clang/include/clang/Serialization/ASTWriter.h | 81 |
1 files changed, 53 insertions, 28 deletions
diff --git a/contrib/llvm-project/clang/include/clang/Serialization/ASTWriter.h b/contrib/llvm-project/clang/include/clang/Serialization/ASTWriter.h index ac88cb0a3177..e328dd0cd557 100644 --- a/contrib/llvm-project/clang/include/clang/Serialization/ASTWriter.h +++ b/contrib/llvm-project/clang/include/clang/Serialization/ASTWriter.h @@ -18,12 +18,14 @@ #include "clang/AST/Decl.h" #include "clang/AST/Type.h" #include "clang/Basic/LLVM.h" +#include "clang/Basic/Module.h" #include "clang/Basic/SourceLocation.h" #include "clang/Sema/Sema.h" #include "clang/Sema/SemaConsumer.h" #include "clang/Serialization/ASTBitCodes.h" #include "clang/Serialization/ASTDeserializationListener.h" #include "clang/Serialization/PCHContainerOperations.h" +#include "clang/Serialization/SourceLocationEncoding.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" @@ -43,26 +45,13 @@ #include <utility> #include <vector> -namespace llvm { - -class APFloat; -class APInt; -class APSInt; - -} // namespace llvm - namespace clang { class ASTContext; class ASTReader; -class ASTUnresolvedSet; class Attr; -class CXXBaseSpecifier; -class CXXCtorInitializer; class CXXRecordDecl; -class CXXTemporary; class FileEntry; -class FPOptions; class FPOptionsOverride; class FunctionDecl; class HeaderSearch; @@ -79,16 +68,13 @@ class NamedDecl; class ObjCInterfaceDecl; class PreprocessingRecord; class Preprocessor; -struct QualifierInfo; class RecordDecl; class Sema; class SourceManager; class Stmt; class StoredDeclsList; class SwitchCase; -class TemplateParameterList; class Token; -class TypeSourceInfo; /// Writes an AST file containing the contents of a translation unit. /// @@ -119,6 +105,8 @@ private: using TypeIdxMap = llvm::DenseMap<QualType, serialization::TypeIdx, serialization::UnsafeQualTypeDenseMapInfo>; + using LocSeq = SourceLocationSequence; + /// The bitstream writer used to emit this precompiled header. llvm::BitstreamWriter &Stream; @@ -456,6 +444,41 @@ private: std::vector<std::unique_ptr<ModuleFileExtensionWriter>> ModuleFileExtensionWriters; + /// Mapping from a source location entry to whether it is affecting or not. + llvm::BitVector IsSLocAffecting; + + /// Mapping from \c FileID to an index into the FileID adjustment table. + std::vector<FileID> NonAffectingFileIDs; + std::vector<unsigned> NonAffectingFileIDAdjustments; + + /// Mapping from an offset to an index into the offset adjustment table. + std::vector<SourceRange> NonAffectingRanges; + std::vector<SourceLocation::UIntTy> NonAffectingOffsetAdjustments; + + /// Collects input files that didn't affect compilation of the current module, + /// and initializes data structures necessary for leaving those files out + /// during \c SourceManager serialization. + void collectNonAffectingInputFiles(); + + /// Returns an adjusted \c FileID, accounting for any non-affecting input + /// files. + FileID getAdjustedFileID(FileID FID) const; + /// Returns an adjusted number of \c FileIDs created within the specified \c + /// FileID, accounting for any non-affecting input files. + unsigned getAdjustedNumCreatedFIDs(FileID FID) const; + /// Returns an adjusted \c SourceLocation, accounting for any non-affecting + /// input files. + SourceLocation getAdjustedLocation(SourceLocation Loc) const; + /// Returns an adjusted \c SourceRange, accounting for any non-affecting input + /// files. + SourceRange getAdjustedRange(SourceRange Range) const; + /// Returns an adjusted \c SourceLocation offset, accounting for any + /// non-affecting input files. + SourceLocation::UIntTy getAdjustedOffset(SourceLocation::UIntTy Offset) const; + /// Returns an adjustment for offset into SourceManager, accounting for any + /// non-affecting input files. + SourceLocation::UIntTy getAdjustment(SourceLocation::UIntTy Offset) const; + /// Retrieve or create a submodule ID for this module. unsigned getSubmoduleID(Module *Mod); @@ -464,7 +487,7 @@ private: void WriteBlockInfoBlock(); void WriteControlBlock(Preprocessor &PP, ASTContext &Context, - StringRef isysroot, const std::string &OutputFile); + StringRef isysroot); /// Write out the signature and diagnostic options, and return the signature. ASTFileSignature writeUnhashedControlBlock(Preprocessor &PP, @@ -474,8 +497,7 @@ private: static std::pair<ASTFileSignature, ASTFileSignature> createSignature(StringRef AllBytes, StringRef ASTBlockBytes); - void WriteInputFiles(SourceManager &SourceMgr, HeaderSearchOptions &HSOpts, - bool Modules); + void WriteInputFiles(SourceManager &SourceMgr, HeaderSearchOptions &HSOpts); void WriteSourceManagerBlock(SourceManager &SourceMgr, const Preprocessor &PP); void WritePreprocessor(const Preprocessor &PP, bool IsModule); @@ -488,7 +510,6 @@ private: bool isModule); unsigned TypeExtQualAbbrev = 0; - unsigned TypeFunctionProtoAbbrev = 0; void WriteTypeAbbrevs(); void WriteType(QualType T); @@ -542,7 +563,6 @@ private: void WriteDecl(ASTContext &Context, Decl *D); ASTFileSignature WriteASTCore(Sema &SemaRef, StringRef isysroot, - const std::string &OutputFile, Module *WritingModule); public: @@ -580,7 +600,7 @@ public: /// /// \return the module signature, which eventually will be a hash of /// the module but currently is merely a random 32-bit number. - ASTFileSignature WriteAST(Sema &SemaRef, const std::string &OutputFile, + ASTFileSignature WriteAST(Sema &SemaRef, StringRef OutputFile, Module *WritingModule, StringRef isysroot, bool hasErrors = false, bool ShouldCacheASTInMemory = false); @@ -592,11 +612,16 @@ public: void AddAlignPackInfo(const Sema::AlignPackInfo &Info, RecordDataImpl &Record); + /// Emit a FileID. + void AddFileID(FileID FID, RecordDataImpl &Record); + /// Emit a source location. - void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record); + void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record, + LocSeq *Seq = nullptr); /// Emit a source range. - void AddSourceRange(SourceRange Range, RecordDataImpl &Record); + void AddSourceRange(SourceRange Range, RecordDataImpl &Record, + LocSeq *Seq = nullptr); /// Emit a reference to an identifier. void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record); @@ -693,10 +718,6 @@ public: return TypeExtQualAbbrev; } - unsigned getTypeFunctionProtoAbbrev() const { - return TypeFunctionProtoAbbrev; - } - unsigned getDeclParmVarAbbrev() const { return DeclParmVarAbbrev; } unsigned getDeclRecordAbbrev() const { return DeclRecordAbbrev; } unsigned getDeclTypedefAbbrev() const { return DeclTypedefAbbrev; } @@ -714,6 +735,10 @@ public: bool hasChain() const { return Chain; } ASTReader *getChain() const { return Chain; } + bool isWritingStdCXXNamedModules() const { + return WritingModule && WritingModule->isModulePurview(); + } + private: // ASTDeserializationListener implementation void ReaderInitialized(ASTReader *Reader) override; |