Skip to content

Add support in LLVM BitstreamWriter to automatically choose abbrevs. #147191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions clang/include/clang/Serialization/ASTRecordWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,19 @@ class ASTRecordWriter

/// Emit the record to the stream, followed by its substatements, and
/// return its offset.
// FIXME: Allow record producers to suggest Abbrevs.
uint64_t Emit(unsigned Code, unsigned Abbrev = 0) {
uint64_t Emit(unsigned Code) {
uint64_t Offset = Writer->Stream.GetCurrentBitNo();
PrepareToEmit(Offset);
Writer->Stream.EmitRecord(Code, *Record, Abbrev);
Writer->Stream.EmitRecordAutoAbbrev(Code, *Record);
FlushStmts();
return Offset;
}

/// Emit the record to the stream, preceded by its substatements.
uint64_t EmitStmt(unsigned Code, unsigned Abbrev = 0) {
uint64_t EmitStmt(unsigned Code) {
FlushSubStmts();
PrepareToEmit(Writer->Stream.GetCurrentBitNo());
Writer->Stream.EmitRecord(Code, *Record, Abbrev);
Writer->Stream.EmitRecordAutoAbbrev(Code, *Record);
return Writer->Stream.GetCurrentBitNo();
}

Expand Down
85 changes: 0 additions & 85 deletions clang/include/clang/Serialization/ASTWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,44 +638,6 @@ class ASTWriter : public ASTDeserializationListener,
void WriteModuleFileExtension(Sema &SemaRef,
ModuleFileExtensionWriter &Writer);

unsigned DeclParmVarAbbrev = 0;
unsigned DeclContextLexicalAbbrev = 0;
unsigned DeclContextVisibleLookupAbbrev = 0;
unsigned DeclModuleLocalVisibleLookupAbbrev = 0;
unsigned DeclTULocalLookupAbbrev = 0;
unsigned UpdateVisibleAbbrev = 0;
unsigned ModuleLocalUpdateVisibleAbbrev = 0;
unsigned TULocalUpdateVisibleAbbrev = 0;
unsigned DeclRecordAbbrev = 0;
unsigned DeclTypedefAbbrev = 0;
unsigned DeclVarAbbrev = 0;
unsigned DeclFieldAbbrev = 0;
unsigned DeclEnumAbbrev = 0;
unsigned DeclObjCIvarAbbrev = 0;
unsigned DeclCXXMethodAbbrev = 0;
unsigned DeclSpecializationsAbbrev = 0;
unsigned DeclPartialSpecializationsAbbrev = 0;

unsigned DeclDependentNonTemplateCXXMethodAbbrev = 0;
unsigned DeclTemplateCXXMethodAbbrev = 0;
unsigned DeclMemberSpecializedCXXMethodAbbrev = 0;
unsigned DeclTemplateSpecializedCXXMethodAbbrev = 0;
unsigned DeclDependentSpecializationCXXMethodAbbrev = 0;
unsigned DeclTemplateTypeParmAbbrev = 0;
unsigned DeclUsingShadowAbbrev = 0;

unsigned DeclRefExprAbbrev = 0;
unsigned CharacterLiteralAbbrev = 0;
unsigned IntegerLiteralAbbrev = 0;
unsigned ExprImplicitCastAbbrev = 0;
unsigned BinaryOperatorAbbrev = 0;
unsigned CompoundAssignOperatorAbbrev = 0;
unsigned CallExprAbbrev = 0;
unsigned CXXOperatorCallExprAbbrev = 0;
unsigned CXXMemberCallExprAbbrev = 0;

unsigned CompoundStmtAbbrev = 0;

void WriteDeclAbbrevs();
void WriteDecl(ASTContext &Context, Decl *D);

Expand Down Expand Up @@ -844,53 +806,6 @@ class ASTWriter : public ASTDeserializationListener,

void ClearSwitchCaseIDs();

unsigned getTypeExtQualAbbrev() const {
return TypeExtQualAbbrev;
}

unsigned getDeclParmVarAbbrev() const { return DeclParmVarAbbrev; }
unsigned getDeclRecordAbbrev() const { return DeclRecordAbbrev; }
unsigned getDeclTypedefAbbrev() const { return DeclTypedefAbbrev; }
unsigned getDeclVarAbbrev() const { return DeclVarAbbrev; }
unsigned getDeclFieldAbbrev() const { return DeclFieldAbbrev; }
unsigned getDeclEnumAbbrev() const { return DeclEnumAbbrev; }
unsigned getDeclObjCIvarAbbrev() const { return DeclObjCIvarAbbrev; }
unsigned getDeclCXXMethodAbbrev(FunctionDecl::TemplatedKind Kind) const {
switch (Kind) {
case FunctionDecl::TK_NonTemplate:
return DeclCXXMethodAbbrev;
case FunctionDecl::TK_FunctionTemplate:
return DeclTemplateCXXMethodAbbrev;
case FunctionDecl::TK_MemberSpecialization:
return DeclMemberSpecializedCXXMethodAbbrev;
case FunctionDecl::TK_FunctionTemplateSpecialization:
return DeclTemplateSpecializedCXXMethodAbbrev;
case FunctionDecl::TK_DependentNonTemplate:
return DeclDependentNonTemplateCXXMethodAbbrev;
case FunctionDecl::TK_DependentFunctionTemplateSpecialization:
return DeclDependentSpecializationCXXMethodAbbrev;
}
llvm_unreachable("Unknwon Template Kind!");
}
unsigned getDeclTemplateTypeParmAbbrev() const {
return DeclTemplateTypeParmAbbrev;
}
unsigned getDeclUsingShadowAbbrev() const { return DeclUsingShadowAbbrev; }

unsigned getDeclRefExprAbbrev() const { return DeclRefExprAbbrev; }
unsigned getCharacterLiteralAbbrev() const { return CharacterLiteralAbbrev; }
unsigned getIntegerLiteralAbbrev() const { return IntegerLiteralAbbrev; }
unsigned getExprImplicitCastAbbrev() const { return ExprImplicitCastAbbrev; }
unsigned getBinaryOperatorAbbrev() const { return BinaryOperatorAbbrev; }
unsigned getCompoundAssignOperatorAbbrev() const {
return CompoundAssignOperatorAbbrev;
}
unsigned getCallExprAbbrev() const { return CallExprAbbrev; }
unsigned getCXXOperatorCallExprAbbrev() { return CXXOperatorCallExprAbbrev; }
unsigned getCXXMemberCallExprAbbrev() { return CXXMemberCallExprAbbrev; }

unsigned getCompoundStmtAbbrev() const { return CompoundStmtAbbrev; }

bool hasChain() const { return Chain; }
ASTReader *getChain() const { return Chain; }

Expand Down
Loading
Loading