diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-06-04 21:29:28 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-06-04 21:29:28 +0000 |
commit | 8cfd67d72363cf8bc4ccec83bcc535853f69f7f0 (patch) | |
tree | fd979b014d1af6aaf23a9f6f59f5ad9a97a3117f /lib/Serialization/ASTReaderStmt.cpp | |
parent | 4b311772fde6bcf366683dbf7e08750b8b611ead (diff) | |
download | clang-8cfd67d72363cf8bc4ccec83bcc535853f69f7f0.tar.gz |
Convert MemberExpr creation and serialization to work the same way as
most / all other Expr subclasses.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@362551 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTReaderStmt.cpp')
-rw-r--r-- | lib/Serialization/ASTReaderStmt.cpp | 92 |
1 files changed, 41 insertions, 51 deletions
diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp index 52aa3d961d..a179207316 100644 --- a/lib/Serialization/ASTReaderStmt.cpp +++ b/lib/Serialization/ASTReaderStmt.cpp @@ -752,9 +752,42 @@ void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) { } void ASTStmtReader::VisitMemberExpr(MemberExpr *E) { - // Don't call VisitExpr, this is fully initialized at creation. - assert(E->getStmtClass() == Stmt::MemberExprClass && - "It's a subclass, we must advance Idx!"); + VisitExpr(E); + + bool HasQualifier = Record.readInt(); + bool HasFoundDecl = Record.readInt(); + bool HasTemplateInfo = Record.readInt(); + unsigned NumTemplateArgs = Record.readInt(); + + E->Base = Record.readSubExpr(); + E->MemberDecl = Record.readDeclAs<ValueDecl>(); + Record.readDeclarationNameLoc(E->MemberDNLoc, E->MemberDecl->getDeclName()); + E->MemberLoc = Record.readSourceLocation(); + E->MemberExprBits.IsArrow = Record.readInt(); + E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl; + E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo; + E->MemberExprBits.HadMultipleCandidates = Record.readInt(); + E->MemberExprBits.OperatorLoc = Record.readSourceLocation(); + + if (HasQualifier || HasFoundDecl) + *E->getTrailingObjects<MemberExprNameQualifier>() = + MemberExprNameQualifier(); + + if (HasFoundDecl) { + auto *FoundD = Record.readDeclAs<NamedDecl>(); + auto AS = (AccessSpecifier)Record.readInt(); + E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = + DeclAccessPair::make(FoundD, AS); + } + + if (HasQualifier) + E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc = + Record.readNestedNameSpecifierLoc(); + + if (HasTemplateInfo) + ReadTemplateKWAndArgsInfo( + *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(), + E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs); } void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) { @@ -2551,55 +2584,12 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty); break; - case EXPR_MEMBER: { - // We load everything here and fully initialize it at creation. - // That way we can use MemberExpr::Create and don't have to duplicate its - // logic with a MemberExpr::CreateEmpty. - - assert(Record.getIdx() == 0); - NestedNameSpecifierLoc QualifierLoc; - if (Record.readInt()) { // HasQualifier. - QualifierLoc = Record.readNestedNameSpecifierLoc(); - } - - SourceLocation TemplateKWLoc; - TemplateArgumentListInfo ArgInfo; - bool HasTemplateKWAndArgsInfo = Record.readInt(); - if (HasTemplateKWAndArgsInfo) { - TemplateKWLoc = Record.readSourceLocation(); - unsigned NumTemplateArgs = Record.readInt(); - ArgInfo.setLAngleLoc(Record.readSourceLocation()); - ArgInfo.setRAngleLoc(Record.readSourceLocation()); - for (unsigned i = 0; i != NumTemplateArgs; ++i) - ArgInfo.addArgument(Record.readTemplateArgumentLoc()); - } - - bool HadMultipleCandidates = Record.readInt(); - - auto *FoundD = Record.readDeclAs<NamedDecl>(); - auto AS = (AccessSpecifier)Record.readInt(); - DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS); - - QualType T = Record.readType(); - auto VK = static_cast<ExprValueKind>(Record.readInt()); - auto OK = static_cast<ExprObjectKind>(Record.readInt()); - Expr *Base = ReadSubExpr(); - auto *MemberD = Record.readDeclAs<ValueDecl>(); - SourceLocation MemberLoc = Record.readSourceLocation(); - DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc); - bool IsArrow = Record.readInt(); - SourceLocation OperatorLoc = Record.readSourceLocation(); - - S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc, - TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo, - HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T, - VK, OK); - Record.readDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc, - MemberD->getDeclName()); - if (HadMultipleCandidates) - cast<MemberExpr>(S)->setHadMultipleCandidates(true); + case EXPR_MEMBER: + S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields], + Record[ASTStmtReader::NumExprFields + 1], + Record[ASTStmtReader::NumExprFields + 2], + Record[ASTStmtReader::NumExprFields + 3]); break; - } case EXPR_BINARY_OPERATOR: S = new (Context) BinaryOperator(Empty); |