From a27c26e7d87488c80221158dbe321fbd2df508a8 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sun, 27 Jul 2014 04:19:32 +0000 Subject: [PATCH] [modules] Add abbreviation for ImplicitCastExpr. This is the most common record type in LLVM's IR module. llvm-svn: 214048 --- clang/include/clang/Serialization/ASTWriter.h | 16 ++++++++++------ clang/lib/Serialization/ASTWriter.cpp | 7 ++++--- clang/lib/Serialization/ASTWriterDecl.cpp | 18 ++++++++++++++++++ clang/lib/Serialization/ASTWriterStmt.cpp | 4 ++++ 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h index 8ecdda4..cb7c9e5 100644 --- a/clang/include/clang/Serialization/ASTWriter.h +++ b/clang/include/clang/Serialization/ASTWriter.h @@ -499,10 +499,7 @@ private: unsigned DeclContextLexicalAbbrev; unsigned DeclContextVisibleLookupAbbrev; unsigned UpdateVisibleAbbrev; - unsigned DeclRefExprAbbrev; - unsigned CharacterLiteralAbbrev; unsigned DeclRecordAbbrev; - unsigned IntegerLiteralAbbrev; unsigned DeclTypedefAbbrev; unsigned DeclVarAbbrev; unsigned DeclFieldAbbrev; @@ -510,6 +507,11 @@ private: unsigned DeclObjCIvarAbbrev; unsigned DeclCXXMethodAbbrev; + unsigned DeclRefExprAbbrev; + unsigned CharacterLiteralAbbrev; + unsigned IntegerLiteralAbbrev; + unsigned ExprImplicitCastAbbrev; + void WriteDeclAbbrevs(); void WriteDecl(ASTContext &Context, Decl *D); void AddFunctionDefinition(const FunctionDecl *FD, RecordData &Record); @@ -745,10 +747,7 @@ public: } unsigned getDeclParmVarAbbrev() const { return DeclParmVarAbbrev; } - unsigned getDeclRefExprAbbrev() const { return DeclRefExprAbbrev; } - unsigned getCharacterLiteralAbbrev() const { return CharacterLiteralAbbrev; } unsigned getDeclRecordAbbrev() const { return DeclRecordAbbrev; } - unsigned getIntegerLiteralAbbrev() const { return IntegerLiteralAbbrev; } unsigned getDeclTypedefAbbrev() const { return DeclTypedefAbbrev; } unsigned getDeclVarAbbrev() const { return DeclVarAbbrev; } unsigned getDeclFieldAbbrev() const { return DeclFieldAbbrev; } @@ -756,6 +755,11 @@ public: unsigned getDeclObjCIvarAbbrev() const { return DeclObjCIvarAbbrev; } unsigned getDeclCXXMethodAbbrev() const { return DeclCXXMethodAbbrev; } + unsigned getDeclRefExprAbbrev() const { return DeclRefExprAbbrev; } + unsigned getCharacterLiteralAbbrev() const { return CharacterLiteralAbbrev; } + unsigned getIntegerLiteralAbbrev() const { return IntegerLiteralAbbrev; } + unsigned getExprImplicitCastAbbrev() const { return ExprImplicitCastAbbrev; } + bool hasChain() const { return Chain; } // ASTDeserializationListener implementation diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 2b096fc..de270f3 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -4055,10 +4055,11 @@ ASTWriter::ASTWriter(llvm::BitstreamWriter &Stream) NextCXXBaseSpecifiersID(1), TypeExtQualAbbrev(0), TypeFunctionProtoAbbrev(0), DeclParmVarAbbrev(0), DeclContextLexicalAbbrev(0), DeclContextVisibleLookupAbbrev(0), - UpdateVisibleAbbrev(0), DeclRefExprAbbrev(0), CharacterLiteralAbbrev(0), - DeclRecordAbbrev(0), IntegerLiteralAbbrev(0), DeclTypedefAbbrev(0), + UpdateVisibleAbbrev(0), DeclRecordAbbrev(0), DeclTypedefAbbrev(0), DeclVarAbbrev(0), DeclFieldAbbrev(0), DeclEnumAbbrev(0), - DeclObjCIvarAbbrev(0), DeclCXXMethodAbbrev(0) {} + DeclObjCIvarAbbrev(0), DeclCXXMethodAbbrev(0), DeclRefExprAbbrev(0), + CharacterLiteralAbbrev(0), IntegerLiteralAbbrev(0), + ExprImplicitCastAbbrev(0) {} ASTWriter::~ASTWriter() { llvm::DeleteContainerSeconds(FileDeclIDs); diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index 1c69834..dca7796 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -1860,6 +1860,24 @@ void ASTWriter::WriteDeclAbbrevs() { Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // getKind CharacterLiteralAbbrev = Stream.EmitAbbrev(Abv); + // Abbreviation for EXPR_IMPLICIT_CAST + Abv = new BitCodeAbbrev(); + Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST)); + // Stmt + // Expr + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind + // CastExpr + Abv->Add(BitCodeAbbrevOp(0)); // PathSize + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 6)); // CastKind + // ImplicitCastExpr + ExprImplicitCastAbbrev = Stream.EmitAbbrev(Abv); + Abv = new BitCodeAbbrev(); Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL)); Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp index cee94c4..462271a 100644 --- a/clang/lib/Serialization/ASTWriterStmt.cpp +++ b/clang/lib/Serialization/ASTWriterStmt.cpp @@ -635,6 +635,10 @@ ASTStmtWriter::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) { void ASTStmtWriter::VisitImplicitCastExpr(ImplicitCastExpr *E) { VisitCastExpr(E); + + if (E->path_size() == 0) + AbbrevToUse = Writer.getExprImplicitCastAbbrev(); + Code = serialization::EXPR_IMPLICIT_CAST; } -- 2.7.4