Re: [PATCH] D28007: Switch TableGen to emit calls to ASTRecordReader for AttrPCHRead.
This review thread is missing on-list approval. I assume it happened on Phab & just wasn't reflected here (if the Phab approval has no text it doesn't send an email, which is unfortunate - not sure if anyone's planning to fix that/change the settings, but until then it's helpful to include "LGTM" or something in the comment field when approving) On Mon, Jan 23, 2017 at 5:16 PM David L. Jones via Phabricator via cfe-commitswrote: > This revision was automatically updated to reflect the committed changes. > Closed by commit rL292868: Switch TableGen to emit calls to > ASTRecordReader for AttrPCHRead. (authored by dlj). > > Changed prior to commit: > https://reviews.llvm.org/D28007?vs=85493=85498#toc > > Repository: > rL LLVM > > https://reviews.llvm.org/D28007 > > Files: > cfe/trunk/include/clang/Serialization/ASTReader.h > cfe/trunk/lib/Serialization/ASTReaderDecl.cpp > cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28007: Switch TableGen to emit calls to ASTRecordReader for AttrPCHRead.
This revision was automatically updated to reflect the committed changes. Closed by commit rL292868: Switch TableGen to emit calls to ASTRecordReader for AttrPCHRead. (authored by dlj). Changed prior to commit: https://reviews.llvm.org/D28007?vs=85493=85498#toc Repository: rL LLVM https://reviews.llvm.org/D28007 Files: cfe/trunk/include/clang/Serialization/ASTReader.h cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Index: cfe/trunk/include/clang/Serialization/ASTReader.h === --- cfe/trunk/include/clang/Serialization/ASTReader.h +++ cfe/trunk/include/clang/Serialization/ASTReader.h @@ -2098,8 +2098,7 @@ unsigned ); /// \brief Reads attributes from the current stream position. - void ReadAttributes(ModuleFile , AttrVec , - const RecordData , unsigned ); + void ReadAttributes(ASTRecordReader , AttrVec ); /// \brief Reads a statement. Stmt *ReadStmt(ModuleFile ); @@ -2284,6 +2283,14 @@ /// \brief Reads a sub-expression operand during statement reading. Expr *readSubExpr() { return Reader->ReadSubExpr(); } + /// \brief Reads a declaration with the given local ID in the given module. + /// + /// \returns The requested declaration, casted to the given return type. + template + T *GetLocalDeclAs(uint32_t LocalID) { +return cast_or_null(Reader->GetLocalDecl(*F, LocalID)); + } + /// \brief Reads a TemplateArgumentLocInfo appropriate for the /// given TemplateArgument kind, advancing Idx. TemplateArgumentLocInfo @@ -2455,7 +2462,7 @@ /// \brief Reads attributes from the current stream position, advancing Idx. void readAttributes(AttrVec ) { -return Reader->ReadAttributes(*F, Attrs, Record, Idx); +return Reader->ReadAttributes(*this, Attrs); } /// \brief Reads a token out of a record, advancing Idx. Index: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp === --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp @@ -1831,7 +1831,7 @@ SourceLocation *StoredLocs = D->getTrailingObjects(); for (unsigned I = 0, N = Record.back(); I != N; ++I) StoredLocs[I] = ReadSourceLocation(); - (void)Record.readInt(); // The number of stored source locations. + Record.skipInts(1); // The number of stored source locations. } void ASTDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) { @@ -2471,12 +2471,11 @@ //===--===// /// \brief Reads attributes from the current stream position. -void ASTReader::ReadAttributes(ModuleFile , AttrVec , - const RecordData , unsigned ) { - for (unsigned i = 0, e = Record[Idx++]; i != e; ++i) { +void ASTReader::ReadAttributes(ASTRecordReader , AttrVec ) { + for (unsigned i = 0, e = Record.readInt(); i != e; ++i) { Attr *New = nullptr; -attr::Kind Kind = (attr::Kind)Record[Idx++]; -SourceRange Range = ReadSourceRange(F, Record, Idx); +attr::Kind Kind = (attr::Kind)Record.readInt(); +SourceRange Range = Record.readSourceRange(); #include "clang/Serialization/AttrPCHRead.inc" Index: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp === --- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp +++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp @@ -90,13 +90,13 @@ static std::string ReadPCHRecord(StringRef type) { return StringSwitch(type) -.EndsWith("Decl *", "GetLocalDeclAs<" - + std::string(type, 0, type.size()-1) + ">(F, Record[Idx++])") -.Case("TypeSourceInfo *", "GetTypeSourceInfo(F, Record, Idx)") -.Case("Expr *", "ReadExpr(F)") -.Case("IdentifierInfo *", "GetIdentifierInfo(F, Record, Idx)") -.Case("StringRef", "ReadString(Record, Idx)") -.Default("Record[Idx++]"); +.EndsWith("Decl *", "Record.GetLocalDeclAs<" + + std::string(type, 0, type.size()-1) + ">(Record.readInt())") +.Case("TypeSourceInfo *", "Record.getTypeSourceInfo()") +.Case("Expr *", "Record.readExpr()") +.Case("IdentifierInfo *", "Record.getIdentifierInfo()") +.Case("StringRef", "Record.readString()") +.Default("Record.readInt()"); } // Get a type that is suitable for storing an object of the specified type. @@ -413,7 +413,7 @@ void writePCHReadDecls(raw_ostream ) const override { OS << "std::string " << getLowerName() - << "= ReadString(Record, Idx);\n"; + << "= Record.readString();\n"; } void writePCHReadArgs(raw_ostream ) const override { @@ -539,13 +539,13 @@ } void writePCHReadDecls(raw_ostream ) const override { - OS << "bool is" << getLowerName() << "Expr = Record[Idx++];\n"; + OS << "bool is" << getLowerName() << "Expr =
[PATCH] D28007: Switch TableGen to emit calls to ASTRecordReader for AttrPCHRead.
dlj updated this revision to Diff 85493. dlj added a comment. - Pull, merge, etc. https://reviews.llvm.org/D28007 Files: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReaderDecl.cpp utils/TableGen/ClangAttrEmitter.cpp Index: utils/TableGen/ClangAttrEmitter.cpp === --- utils/TableGen/ClangAttrEmitter.cpp +++ utils/TableGen/ClangAttrEmitter.cpp @@ -90,13 +90,13 @@ static std::string ReadPCHRecord(StringRef type) { return StringSwitch(type) -.EndsWith("Decl *", "GetLocalDeclAs<" - + std::string(type, 0, type.size()-1) + ">(F, Record[Idx++])") -.Case("TypeSourceInfo *", "GetTypeSourceInfo(F, Record, Idx)") -.Case("Expr *", "ReadExpr(F)") -.Case("IdentifierInfo *", "GetIdentifierInfo(F, Record, Idx)") -.Case("StringRef", "ReadString(Record, Idx)") -.Default("Record[Idx++]"); +.EndsWith("Decl *", "Record.GetLocalDeclAs<" + + std::string(type, 0, type.size()-1) + ">(Record.readInt())") +.Case("TypeSourceInfo *", "Record.getTypeSourceInfo()") +.Case("Expr *", "Record.readExpr()") +.Case("IdentifierInfo *", "Record.getIdentifierInfo()") +.Case("StringRef", "Record.readString()") +.Default("Record.readInt()"); } // Get a type that is suitable for storing an object of the specified type. @@ -413,7 +413,7 @@ void writePCHReadDecls(raw_ostream ) const override { OS << "std::string " << getLowerName() - << "= ReadString(Record, Idx);\n"; + << "= Record.readString();\n"; } void writePCHReadArgs(raw_ostream ) const override { @@ -539,13 +539,13 @@ } void writePCHReadDecls(raw_ostream ) const override { - OS << "bool is" << getLowerName() << "Expr = Record[Idx++];\n"; + OS << "bool is" << getLowerName() << "Expr = Record.readInt();\n"; OS << "void *" << getLowerName() << "Ptr;\n"; OS << "if (is" << getLowerName() << "Expr)\n"; - OS << " " << getLowerName() << "Ptr = ReadExpr(F);\n"; + OS << " " << getLowerName() << "Ptr = Record.readExpr();\n"; OS << "else\n"; OS << " " << getLowerName() - << "Ptr = GetTypeSourceInfo(F, Record, Idx);\n"; + << "Ptr = Record.getTypeSourceInfo();\n"; } void writePCHWrite(raw_ostream ) const override { @@ -658,7 +658,7 @@ } void writePCHReadDecls(raw_ostream ) const override { - OS << "unsigned " << getLowerName() << "Size = Record[Idx++];\n"; + OS << "unsigned " << getLowerName() << "Size = Record.readInt();\n"; OS << "SmallVector<" << getType() << ", 4> " << getLowerName() << ";\n"; OS << "" << getLowerName() << ".reserve(" << getLowerName() @@ -783,7 +783,7 @@ void writePCHReadDecls(raw_ostream ) const override { OS << "" << getAttrName() << "Attr::" << type << " " << getLowerName() << "(static_cast<" << getAttrName() << "Attr::" << type - << ">(Record[Idx++]));\n"; + << ">(Record.readInt()));\n"; } void writePCHReadArgs(raw_ostream ) const override { @@ -906,14 +906,14 @@ } void writePCHReadDecls(raw_ostream ) const override { - OS << "unsigned " << getLowerName() << "Size = Record[Idx++];\n"; + OS << "unsigned " << getLowerName() << "Size = Record.readInt();\n"; OS << "SmallVector<" << QualifiedTypeName << ", 4> " << getLowerName() << ";\n"; OS << "" << getLowerName() << ".reserve(" << getLowerName() << "Size);\n"; OS << "for (unsigned i = " << getLowerName() << "Size; i; --i)\n"; OS << " " << getLowerName() << ".push_back(" << "static_cast<" - << QualifiedTypeName << ">(Record[Idx++]));\n"; + << QualifiedTypeName << ">(Record.readInt()));\n"; } void writePCHWrite(raw_ostream ) const override { @@ -996,7 +996,7 @@ void writePCHReadDecls(raw_ostream ) const override { OS << "VersionTuple " << getLowerName() - << "= ReadVersionTuple(Record, Idx);\n"; + << "= Record.readVersionTuple();\n"; } void writePCHReadArgs(raw_ostream ) const override { @@ -2126,9 +2126,9 @@ OS << " case attr::" << R.getName() << ": {\n"; if (R.isSubClassOf(InhClass)) - OS << "bool isInherited = Record[Idx++];\n"; -OS << "bool isImplicit = Record[Idx++];\n"; -OS << "unsigned Spelling = Record[Idx++];\n"; + OS << "bool isInherited = Record.readInt();\n"; +OS << "bool isImplicit = Record.readInt();\n"; +OS << "unsigned Spelling = Record.readInt();\n"; ArgRecords = R.getValueAsListOfDefs("Args"); Args.clear(); for (const auto *Arg : ArgRecords) { Index: lib/Serialization/ASTReaderDecl.cpp === --- lib/Serialization/ASTReaderDecl.cpp +++
[PATCH] D28007: Switch TableGen to emit calls to ASTRecordReader for AttrPCHRead.
dlj added a comment. Ping? https://reviews.llvm.org/D28007 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28007: Switch TableGen to emit calls to ASTRecordReader for AttrPCHRead.
dlj created this revision. dlj added a reviewer: rsmith. dlj added a subscriber: cfe-commits. This patch changes TableGen-generated code in AttrPCHRead to call functions on ASTRecordReader, instead of passing separate parameters to ASTReader. This is a follow-up to r290217. https://reviews.llvm.org/D28007 Files: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReaderDecl.cpp utils/TableGen/ClangAttrEmitter.cpp Index: utils/TableGen/ClangAttrEmitter.cpp === --- utils/TableGen/ClangAttrEmitter.cpp +++ utils/TableGen/ClangAttrEmitter.cpp @@ -90,13 +90,13 @@ static std::string ReadPCHRecord(StringRef type) { return StringSwitch(type) -.EndsWith("Decl *", "GetLocalDeclAs<" - + std::string(type, 0, type.size()-1) + ">(F, Record[Idx++])") -.Case("TypeSourceInfo *", "GetTypeSourceInfo(F, Record, Idx)") -.Case("Expr *", "ReadExpr(F)") -.Case("IdentifierInfo *", "GetIdentifierInfo(F, Record, Idx)") -.Case("StringRef", "ReadString(Record, Idx)") -.Default("Record[Idx++]"); +.EndsWith("Decl *", "Record.GetLocalDeclAs<" + + std::string(type, 0, type.size()-1) + ">(Record.readInt())") +.Case("TypeSourceInfo *", "Record.GetTypeSourceInfo()") +.Case("Expr *", "Record.ReadExpr()") +.Case("IdentifierInfo *", "Record.GetIdentifierInfo()") +.Case("StringRef", "Record.ReadString()") +.Default("Record.readInt()"); } // Get a type that is suitable for storing an object of the specified type. @@ -414,7 +414,7 @@ void writePCHReadDecls(raw_ostream ) const override { OS << "std::string " << getLowerName() - << "= ReadString(Record, Idx);\n"; + << "= Record.ReadString();\n"; } void writePCHReadArgs(raw_ostream ) const override { @@ -540,13 +540,13 @@ } void writePCHReadDecls(raw_ostream ) const override { - OS << "bool is" << getLowerName() << "Expr = Record[Idx++];\n"; + OS << "bool is" << getLowerName() << "Expr = Record.readInt();\n"; OS << "void *" << getLowerName() << "Ptr;\n"; OS << "if (is" << getLowerName() << "Expr)\n"; - OS << " " << getLowerName() << "Ptr = ReadExpr(F);\n"; + OS << " " << getLowerName() << "Ptr = Record.ReadExpr();\n"; OS << "else\n"; OS << " " << getLowerName() - << "Ptr = GetTypeSourceInfo(F, Record, Idx);\n"; + << "Ptr = Record.GetTypeSourceInfo();\n"; } void writePCHWrite(raw_ostream ) const override { @@ -659,7 +659,7 @@ } void writePCHReadDecls(raw_ostream ) const override { - OS << "unsigned " << getLowerName() << "Size = Record[Idx++];\n"; + OS << "unsigned " << getLowerName() << "Size = Record.readInt();\n"; OS << "SmallVector<" << getType() << ", 4> " << getLowerName() << ";\n"; OS << "" << getLowerName() << ".reserve(" << getLowerName() @@ -784,7 +784,7 @@ void writePCHReadDecls(raw_ostream ) const override { OS << "" << getAttrName() << "Attr::" << type << " " << getLowerName() << "(static_cast<" << getAttrName() << "Attr::" << type - << ">(Record[Idx++]));\n"; + << ">(Record.readInt()));\n"; } void writePCHReadArgs(raw_ostream ) const override { @@ -907,14 +907,14 @@ } void writePCHReadDecls(raw_ostream ) const override { - OS << "unsigned " << getLowerName() << "Size = Record[Idx++];\n"; + OS << "unsigned " << getLowerName() << "Size = Record.readInt();\n"; OS << "SmallVector<" << QualifiedTypeName << ", 4> " << getLowerName() << ";\n"; OS << "" << getLowerName() << ".reserve(" << getLowerName() << "Size);\n"; OS << "for (unsigned i = " << getLowerName() << "Size; i; --i)\n"; OS << " " << getLowerName() << ".push_back(" << "static_cast<" - << QualifiedTypeName << ">(Record[Idx++]));\n"; + << QualifiedTypeName << ">(Record.readInt()));\n"; } void writePCHWrite(raw_ostream ) const override { @@ -997,7 +997,7 @@ void writePCHReadDecls(raw_ostream ) const override { OS << "VersionTuple " << getLowerName() - << "= ReadVersionTuple(Record, Idx);\n"; + << "= Record.ReadVersionTuple();\n"; } void writePCHReadArgs(raw_ostream ) const override { @@ -2127,9 +2127,9 @@ OS << " case attr::" << R.getName() << ": {\n"; if (R.isSubClassOf(InhClass)) - OS << "bool isInherited = Record[Idx++];\n"; -OS << "bool isImplicit = Record[Idx++];\n"; -OS << "unsigned Spelling = Record[Idx++];\n"; + OS << "bool isInherited = Record.readInt();\n"; +OS << "bool isImplicit = Record.readInt();\n"; +OS << "unsigned Spelling = Record.readInt();\n"; ArgRecords = R.getValueAsListOfDefs("Args"); Args.clear(); for (const auto *Arg :