|
clang
5.0.0
|
Writes an AST file containing the contents of a translation unit. More...
#include "clang/Serialization/ASTWriter.h"
Public Types | |
| typedef SmallVector< uint64_t, 64 > | RecordData |
| typedef SmallVectorImpl< uint64_t > | RecordDataImpl |
| typedef ArrayRef< uint64_t > | RecordDataRef |
Public Member Functions | |
| ASTWriter (llvm::BitstreamWriter &Stream, SmallVectorImpl< char > &Buffer, MemoryBufferCache &PCMCache, ArrayRef< std::shared_ptr< ModuleFileExtension >> Extensions, bool IncludeTimestamps=true) | |
| Create a new precompiled header writer that outputs to the given bitstream. More... | |
| ~ASTWriter () override | |
| const LangOptions & | getLangOpts () const |
| time_t | getTimestampForOutput (const FileEntry *E) const |
| Get a timestamp for output into the AST file. More... | |
| ASTFileSignature | WriteAST (Sema &SemaRef, const std::string &OutputFile, Module *WritingModule, StringRef isysroot, bool hasErrors=false) |
| Write a precompiled header for the given semantic analysis. More... | |
| void | AddToken (const Token &Tok, RecordDataImpl &Record) |
| Emit a token. More... | |
| void | AddSourceLocation (SourceLocation Loc, RecordDataImpl &Record) |
| Emit a source location. More... | |
| void | AddSourceRange (SourceRange Range, RecordDataImpl &Record) |
| Emit a source range. More... | |
| void | AddIdentifierRef (const IdentifierInfo *II, RecordDataImpl &Record) |
| Emit a reference to an identifier. More... | |
| serialization::SelectorID | getSelectorRef (Selector Sel) |
| Get the unique number used to refer to the given selector. More... | |
| serialization::IdentID | getIdentifierRef (const IdentifierInfo *II) |
| Get the unique number used to refer to the given identifier. More... | |
| serialization::MacroID | getMacroRef (MacroInfo *MI, const IdentifierInfo *Name) |
| Get the unique number used to refer to the given macro. More... | |
| serialization::MacroID | getMacroID (MacroInfo *MI) |
| Determine the ID of an already-emitted macro. More... | |
| uint64_t | getMacroDirectivesOffset (const IdentifierInfo *Name) |
| void | AddTypeRef (QualType T, RecordDataImpl &Record) |
| Emit a reference to a type. More... | |
| serialization::TypeID | GetOrCreateTypeID (QualType T) |
| Force a type to be emitted and get its ID. More... | |
| serialization::TypeID | getTypeID (QualType T) const |
| Determine the type ID of an already-emitted type. More... | |
| const Decl * | getFirstLocalDecl (const Decl *D) |
| Find the first local declaration of a given local redeclarable decl. More... | |
| bool | IsLocalDecl (const Decl *D) |
| Is this a local declaration (that is, one that will be written to our AST file)? This is the case for declarations that are neither imported from another AST file nor predefined. More... | |
| void | AddDeclRef (const Decl *D, RecordDataImpl &Record) |
| Emit a reference to a declaration. More... | |
| serialization::DeclID | GetDeclRef (const Decl *D) |
| Force a declaration to be emitted and get its ID. More... | |
| serialization::DeclID | getDeclID (const Decl *D) |
| Determine the declaration ID of an already-emitted declaration. More... | |
| unsigned | getAnonymousDeclarationNumber (const NamedDecl *D) |
| void | AddString (StringRef Str, RecordDataImpl &Record) |
| Add a string to the given record. More... | |
| bool | PreparePathForOutput (SmallVectorImpl< char > &Path) |
| Convert a path from this build process into one that is appropriate for emission in the module file. More... | |
| void | AddPath (StringRef Path, RecordDataImpl &Record) |
| Add a path to the given record. More... | |
| void | EmitRecordWithPath (unsigned Abbrev, RecordDataRef Record, StringRef Path) |
| Emit the current record with the given path as a blob. More... | |
| void | AddVersionTuple (const VersionTuple &Version, RecordDataImpl &Record) |
| Add a version tuple to the given record. More... | |
| unsigned | getLocalOrImportedSubmoduleID (Module *Mod) |
| Retrieve or create a submodule ID for this module, or return 0 if the submodule is neither local (a submodle of the currently-written module) nor from an imported module. More... | |
| void | SetIdentifierOffset (const IdentifierInfo *II, uint32_t Offset) |
| Note that the identifier II occurs at the given offset within the identifier table. More... | |
| void | SetSelectorOffset (Selector Sel, uint32_t Offset) |
| Note that the selector Sel occurs at the given offset within the method pool/selector table. More... | |
| unsigned | RecordSwitchCaseID (SwitchCase *S) |
| Record an ID for the given switch-case statement. More... | |
| unsigned | getSwitchCaseID (SwitchCase *S) |
| Retrieve the ID for the given switch-case statement. More... | |
| void | ClearSwitchCaseIDs () |
| unsigned | getTypeExtQualAbbrev () const |
| unsigned | getTypeFunctionProtoAbbrev () const |
| unsigned | getDeclParmVarAbbrev () const |
| unsigned | getDeclRecordAbbrev () const |
| unsigned | getDeclTypedefAbbrev () const |
| unsigned | getDeclVarAbbrev () const |
| unsigned | getDeclFieldAbbrev () const |
| unsigned | getDeclEnumAbbrev () const |
| unsigned | getDeclObjCIvarAbbrev () const |
| unsigned | getDeclCXXMethodAbbrev () const |
| unsigned | getDeclRefExprAbbrev () const |
| unsigned | getCharacterLiteralAbbrev () const |
| unsigned | getIntegerLiteralAbbrev () const |
| unsigned | getExprImplicitCastAbbrev () const |
| bool | hasChain () const |
| ASTReader * | getChain () const |
Public Member Functions inherited from clang::ASTDeserializationListener | |
| virtual | ~ASTDeserializationListener () |
| virtual void | DeclRead (serialization::DeclID ID, const Decl *D) |
| A decl was deserialized from the AST file. More... | |
| virtual void | ModuleImportRead (serialization::SubmoduleID ID, SourceLocation ImportLoc) |
| A module import was read from the AST file. More... | |
Public Member Functions inherited from clang::ASTMutationListener | |
| virtual | ~ASTMutationListener () |
Friends | |
| class | ASTDeclWriter |
| class | ASTStmtWriter |
| class | ASTTypeWriter |
| class | ASTRecordWriter |
Writes an AST file containing the contents of a translation unit.
The ASTWriter class produces a bitstream containing the serialized representation of a given abstract syntax tree and its supporting data structures. This bitstream can be de-serialized via an instance of the ASTReader class.
Definition at line 82 of file ASTWriter.h.
| typedef SmallVector<uint64_t, 64> clang::ASTWriter::RecordData |
Definition at line 85 of file ASTWriter.h.
| typedef SmallVectorImpl<uint64_t> clang::ASTWriter::RecordDataImpl |
Definition at line 86 of file ASTWriter.h.
| typedef ArrayRef<uint64_t> clang::ASTWriter::RecordDataRef |
Definition at line 87 of file ASTWriter.h.
| ASTWriter::ASTWriter | ( | llvm::BitstreamWriter & | Stream, |
| SmallVectorImpl< char > & | Buffer, | ||
| MemoryBufferCache & | PCMCache, | ||
| ArrayRef< std::shared_ptr< ModuleFileExtension >> | Extensions, | ||
| bool | IncludeTimestamps = true |
||
| ) |
Create a new precompiled header writer that outputs to the given bitstream.
Definition at line 4439 of file ASTWriter.cpp.
|
override |
Definition at line 4451 of file ASTWriter.cpp.
| void ASTWriter::AddDeclRef | ( | const Decl * | D, |
| RecordDataImpl & | Record | ||
| ) |
Emit a reference to a declaration.
Definition at line 5357 of file ASTWriter.cpp.
References GetDeclRef().
Referenced by clang::ASTRecordWriter::AddCXXDefinitionData(), clang::ASTRecordWriter::AddCXXTemporary(), clang::ASTRecordWriter::AddDeclarationName(), clang::ASTRecordWriter::AddDeclRef(), AddLazyVectorDecls(), clang::ASTRecordWriter::AddNestedNameSpecifier(), clang::ASTRecordWriter::AddNestedNameSpecifierLoc(), clang::ASTRecordWriter::AddTemplateArgument(), clang::ASTRecordWriter::AddTemplateName(), clang::ASTRecordWriter::AddTemplateParameterList(), and clang::ASTRecordWriter::AddUnresolvedSet().
| void ASTWriter::AddIdentifierRef | ( | const IdentifierInfo * | II, |
| RecordDataImpl & | Record | ||
| ) |
Emit a reference to an identifier.
Definition at line 5190 of file ASTWriter.cpp.
References getIdentifierRef().
Referenced by clang::ASTRecordWriter::AddDeclarationName(), clang::ASTRecordWriter::AddIdentifierRef(), clang::ASTRecordWriter::AddNestedNameSpecifier(), clang::ASTRecordWriter::AddNestedNameSpecifierLoc(), and clang::ASTRecordWriter::AddTemplateName().
| void ASTWriter::AddPath | ( | StringRef | Path, |
| RecordDataImpl & | Record | ||
| ) |
Add a path to the given record.
Definition at line 4391 of file ASTWriter.cpp.
References FilePath.
Referenced by clang::ASTRecordWriter::AddPath().
| void ASTWriter::AddSourceLocation | ( | SourceLocation | Loc, |
| RecordDataImpl & | Record | ||
| ) |
Emit a source location.
Definition at line 5165 of file ASTWriter.cpp.
References clang::SourceLocation::getRawEncoding().
Referenced by clang::ASTRecordWriter::AddASTTemplateArgumentListInfo(), clang::ASTRecordWriter::AddCXXBaseSpecifier(), clang::ASTRecordWriter::AddCXXDefinitionData(), clang::ASTRecordWriter::AddDeclarationNameInfo(), clang::ASTRecordWriter::AddDeclarationNameLoc(), clang::ASTRecordWriter::AddNestedNameSpecifierLoc(), clang::ASTRecordWriter::AddSourceLocation(), AddSourceRange(), clang::ASTRecordWriter::AddTemplateArgumentLocInfo(), and clang::ASTRecordWriter::AddTemplateParameterList().
| void ASTWriter::AddSourceRange | ( | SourceRange | Range, |
| RecordDataImpl & | Record | ||
| ) |
Emit a source range.
Definition at line 5170 of file ASTWriter.cpp.
References AddSourceLocation(), clang::SourceRange::getBegin(), and clang::SourceRange::getEnd().
Referenced by clang::ASTRecordWriter::AddCXXBaseSpecifier(), clang::ASTRecordWriter::AddNestedNameSpecifierLoc(), and clang::ASTRecordWriter::AddSourceRange().
| void ASTWriter::AddString | ( | StringRef | Str, |
| RecordDataImpl & | Record | ||
| ) |
Add a string to the given record.
Definition at line 4368 of file ASTWriter.cpp.
Referenced by clang::ASTRecordWriter::AddString().
| void ASTWriter::AddToken | ( | const Token & | Tok, |
| RecordDataImpl & | Record | ||
| ) |
Emit a token.
Definition at line 4355 of file ASTWriter.cpp.
References clang::Token::getFlags(), clang::Token::getIdentifierInfo(), clang::Token::getKind(), clang::Token::getLength(), and clang::Token::getLocation().
| void ASTWriter::AddTypeRef | ( | QualType | T, |
| RecordDataImpl & | Record | ||
| ) |
Emit a reference to a type.
Definition at line 5317 of file ASTWriter.cpp.
References GetOrCreateTypeID().
Referenced by clang::ASTRecordWriter::AddDeclarationName(), clang::ASTRecordWriter::AddNestedNameSpecifier(), clang::ASTRecordWriter::AddTemplateArgument(), clang::ASTRecordWriter::AddTypeLoc(), clang::ASTRecordWriter::AddTypeRef(), and clang::ASTRecordWriter::AddTypeSourceInfo().
| void ASTWriter::AddVersionTuple | ( | const VersionTuple & | Version, |
| RecordDataImpl & | Record | ||
| ) |
Add a version tuple to the given record.
Definition at line 4404 of file ASTWriter.cpp.
References clang::VersionTuple::getMajor(), clang::VersionTuple::getMinor(), and clang::VersionTuple::getSubminor().
Referenced by clang::ASTRecordWriter::AddVersionTuple().
| void ASTWriter::ClearSwitchCaseIDs | ( | ) |
Definition at line 2648 of file ASTWriterStmt.cpp.
| void ASTWriter::EmitRecordWithPath | ( | unsigned | Abbrev, |
| RecordDataRef | Record, | ||
| StringRef | Path | ||
| ) |
Emit the current record with the given path as a blob.
Definition at line 4397 of file ASTWriter.cpp.
References FilePath.
Definition at line 5485 of file ASTWriter.cpp.
References clang::Decl::getLexicalDeclContext(), clang::serialization::needsAnonymousDeclarationNumber(), and clang::serialization::numberAnonymousDeclsWithin().
|
inline |
Definition at line 673 of file ASTWriter.h.
|
inline |
Definition at line 668 of file ASTWriter.h.
|
inline |
Definition at line 665 of file ASTWriter.h.
|
inline |
Definition at line 663 of file ASTWriter.h.
|
inline |
Definition at line 662 of file ASTWriter.h.
| DeclID ASTWriter::getDeclID | ( | const Decl * | D | ) |
Determine the declaration ID of an already-emitted declaration.
Definition at line 5390 of file ASTWriter.cpp.
References clang::Decl::getGlobalID(), and clang::Decl::isFromASTFile().
|
inline |
Definition at line 664 of file ASTWriter.h.
|
inline |
Definition at line 658 of file ASTWriter.h.
|
inline |
Definition at line 659 of file ASTWriter.h.
| DeclID ASTWriter::GetDeclRef | ( | const Decl * | D | ) |
Force a declaration to be emitted and get its ID.
Definition at line 5361 of file ASTWriter.cpp.
References clang::Decl::getGlobalID(), ID, and clang::Decl::isFromASTFile().
Referenced by AddDeclRef().
|
inline |
Definition at line 667 of file ASTWriter.h.
|
inline |
Definition at line 660 of file ASTWriter.h.
|
inline |
Definition at line 661 of file ASTWriter.h.
|
inline |
Definition at line 670 of file ASTWriter.h.
Find the first local declaration of a given local redeclarable decl.
Definition at line 1611 of file ASTWriterDecl.cpp.
References clang::Decl::getCanonicalDecl(), and clang::Decl::getPreviousDecl().
| IdentID ASTWriter::getIdentifierRef | ( | const IdentifierInfo * | II | ) |
Get the unique number used to refer to the given identifier.
Definition at line 5194 of file ASTWriter.cpp.
References ID.
Referenced by AddIdentifierRef().
|
inline |
Definition at line 669 of file ASTWriter.h.
| const LangOptions & ASTWriter::getLangOpts | ( | ) | const |
Definition at line 4455 of file ASTWriter.cpp.
References clang::ASTContext::getLangOpts().
Retrieve or create a submodule ID for this module, or return 0 if the submodule is neither local (a submodle of the currently-written module) nor from an imported module.
Definition at line 2669 of file ASTWriter.cpp.
References clang::Module::getTopLevelModule().
| uint64_t ASTWriter::getMacroDirectivesOffset | ( | const IdentifierInfo * | Name | ) |
Definition at line 5228 of file ASTWriter.cpp.
Determine the ID of an already-emitted macro.
Definition at line 5220 of file ASTWriter.cpp.
References clang::MacroInfo::isBuiltinMacro().
| MacroID ASTWriter::getMacroRef | ( | MacroInfo * | MI, |
| const IdentifierInfo * | Name | ||
| ) |
Get the unique number used to refer to the given macro.
Definition at line 5204 of file ASTWriter.cpp.
References ID, clang::MacroInfo::isBuiltinMacro(), and Name.
Force a type to be emitted and get its ID.
Definition at line 5321 of file ASTWriter.cpp.
References clang::QualType::getLocalFastQualifiers(), clang::QualType::isNull(), and clang::serialization::MakeTypeID().
Referenced by AddTypeRef().
| SelectorID ASTWriter::getSelectorRef | ( | Selector | Sel | ) |
Get the unique number used to refer to the given selector.
Definition at line 5236 of file ASTWriter.cpp.
References clang::Selector::getAsOpaquePtr().
| unsigned ASTWriter::getSwitchCaseID | ( | SwitchCase * | S | ) |
Retrieve the ID for the given switch-case statement.
Definition at line 2642 of file ASTWriterStmt.cpp.
References S.
| time_t ASTWriter::getTimestampForOutput | ( | const FileEntry * | E | ) | const |
Get a timestamp for output into the AST file.
The actual timestamp of the specified file may be ignored if we have been instructed to not include timestamps in the output file.
Definition at line 4460 of file ASTWriter.cpp.
References clang::FileEntry::getModificationTime().
|
inline |
Definition at line 651 of file ASTWriter.h.
|
inline |
Definition at line 654 of file ASTWriter.h.
Determine the type ID of an already-emitted type.
Definition at line 5344 of file ASTWriter.cpp.
References clang::QualType::getLocalFastQualifiers(), I, clang::QualType::isNull(), and clang::serialization::MakeTypeID().
|
inline |
Definition at line 672 of file ASTWriter.h.
Is this a local declaration (that is, one that will be written to our AST file)? This is the case for declarations that are neither imported from another AST file nor predefined.
Definition at line 592 of file ASTWriter.h.
References I, clang::Decl::isFromASTFile(), and clang::serialization::NUM_PREDEF_DECL_IDS.
| bool ASTWriter::PreparePathForOutput | ( | SmallVectorImpl< char > & | Path | ) |
Convert a path from this build process into one that is appropriate for emission in the module file.
Definition at line 4373 of file ASTWriter.cpp.
References adjustFilenameForRelocatableAST(), cleanPathForOutput(), clang::SourceManager::getFileManager(), and clang::ASTContext::getSourceManager().
| unsigned ASTWriter::RecordSwitchCaseID | ( | SwitchCase * | S | ) |
Record an ID for the given switch-case statement.
Definition at line 2634 of file ASTWriterStmt.cpp.
References S.
| void ASTWriter::SetIdentifierOffset | ( | const IdentifierInfo * | II, |
| uint32_t | Offset | ||
| ) |
Note that the identifier II occurs at the given offset within the identifier table.
Definition at line 4419 of file ASTWriter.cpp.
| void ASTWriter::SetSelectorOffset | ( | Selector | Sel, |
| uint32_t | Offset | ||
| ) |
Note that the selector Sel occurs at the given offset within the method pool/selector table.
Definition at line 4429 of file ASTWriter.cpp.
| ASTFileSignature ASTWriter::WriteAST | ( | Sema & | SemaRef, |
| const std::string & | OutputFile, | ||
| Module * | WritingModule, | ||
| StringRef | isysroot, | ||
| bool | hasErrors = false |
||
| ) |
Write a precompiled header for the given semantic analysis.
| SemaRef | a reference to the semantic analysis object that processed the AST to be written into the precompiled header. |
| WritingModule | The module that we are writing. If null, we are writing a precompiled header. |
| isysroot | if non-empty, write a relocatable file whose headers are relative to the given system root. If we're writing a module, its build directory will be used in preference to this if both are available. |
Definition at line 4464 of file ASTWriter.cpp.
References clang::MemoryBufferCache::addBuffer(), clang::Sema::Context, clang::ASTContext::getLangOpts(), and clang::Sema::PP.
Referenced by clang::PCHGenerator::HandleTranslationUnit(), and serializeUnit().
|
friend |
Definition at line 89 of file ASTWriter.h.
|
friend |
Definition at line 92 of file ASTWriter.h.
|
friend |
Definition at line 90 of file ASTWriter.h.
|
friend |
Definition at line 91 of file ASTWriter.h.
1.8.6