<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 5 Jun 2019, 04:44 Benjamin Kramer via cfe-commits, <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">It also crashes during clang selfhost with modules and libc++. Let me know if you need a precise reproducer command.</div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Yes, please.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>I reverted this change and the dependent r362563 in r362597.</div></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Thanks!</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 5, 2019 at 9:37 AM Martin Storsjö via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" rel="noreferrer">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This broke building of Qt when using PCH. Selfcontained repro is a bit <br>
hard to make though...<br>
<br>
// Martin<br>
<br>
On Tue, 4 Jun 2019, Richard Smith via cfe-commits wrote:<br>
<br>
> Author: rsmith<br>
> Date: Tue Jun  4 14:29:28 2019<br>
> New Revision: 362551<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=362551&view=rev" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=362551&view=rev</a><br>
> Log:<br>
> Convert MemberExpr creation and serialization to work the same way as<br>
> most / all other Expr subclasses.<br>
><br>
> Modified:<br>
>    cfe/trunk/include/clang/AST/Expr.h<br>
>    cfe/trunk/include/clang/AST/Stmt.h<br>
>    cfe/trunk/lib/AST/DeclBase.cpp<br>
>    cfe/trunk/lib/AST/Expr.cpp<br>
>    cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp<br>
>    cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp<br>
>    cfe/trunk/lib/Sema/SemaExprCXX.cpp<br>
>    cfe/trunk/lib/Serialization/ASTReaderStmt.cpp<br>
>    cfe/trunk/lib/Serialization/ASTWriterStmt.cpp<br>
><br>
> Modified: cfe/trunk/include/clang/AST/Expr.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=362551&r1=362550&r2=362551&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=362551&r1=362550&r2=362551&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/include/clang/AST/Expr.h (original)<br>
> +++ cfe/trunk/include/clang/AST/Expr.h Tue Jun  4 14:29:28 2019<br>
> @@ -2735,6 +2735,7 @@ class MemberExpr final<br>
>                                     ASTTemplateKWAndArgsInfo,<br>
>                                     TemplateArgumentLoc> {<br>
>   friend class ASTReader;<br>
> +  friend class ASTStmtReader;<br>
>   friend class ASTStmtWriter;<br>
>   friend TrailingObjects;<br>
> <br>
> @@ -2769,49 +2770,38 @@ class MemberExpr final<br>
>     return MemberExprBits.HasTemplateKWAndArgsInfo;<br>
>   }<br>
> <br>
> -public:<br>
> -  MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc,<br>
> -             ValueDecl *memberdecl, const DeclarationNameInfo &NameInfo,<br>
> -             QualType ty, ExprValueKind VK, ExprObjectKind OK)<br>
> -      : Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(),<br>
> -             base->isValueDependent(), base->isInstantiationDependent(),<br>
> -             base->containsUnexpandedParameterPack()),<br>
> -        Base(base), MemberDecl(memberdecl), MemberDNLoc(NameInfo.getInfo()),<br>
> -        MemberLoc(NameInfo.getLoc()) {<br>
> -    assert(memberdecl->getDeclName() == NameInfo.getName());<br>
> -    MemberExprBits.IsArrow = isarrow;<br>
> -    MemberExprBits.HasQualifierOrFoundDecl = false;<br>
> -    MemberExprBits.HasTemplateKWAndArgsInfo = false;<br>
> -    MemberExprBits.HadMultipleCandidates = false;<br>
> -    MemberExprBits.OperatorLoc = operatorloc;<br>
> -  }<br>
> -<br>
> -  // NOTE: this constructor should be used only when it is known that<br>
> -  // the member name can not provide additional syntactic info<br>
> -  // (i.e., source locations for C++ operator names or type source info<br>
> -  // for constructors, destructors and conversion operators).<br>
> -  MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc,<br>
> -             ValueDecl *memberdecl, SourceLocation l, QualType ty,<br>
> -             ExprValueKind VK, ExprObjectKind OK)<br>
> -      : Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(),<br>
> -             base->isValueDependent(), base->isInstantiationDependent(),<br>
> -             base->containsUnexpandedParameterPack()),<br>
> -        Base(base), MemberDecl(memberdecl), MemberDNLoc(), MemberLoc(l) {<br>
> -    MemberExprBits.IsArrow = isarrow;<br>
> -    MemberExprBits.HasQualifierOrFoundDecl = false;<br>
> -    MemberExprBits.HasTemplateKWAndArgsInfo = false;<br>
> -    MemberExprBits.HadMultipleCandidates = false;<br>
> -    MemberExprBits.OperatorLoc = operatorloc;<br>
> -  }<br>
> +  MemberExpr(Expr *Base, bool IsArrow, SourceLocation OperatorLoc,<br>
> +             ValueDecl *MemberDecl, const DeclarationNameInfo &NameInfo,<br>
> +             QualType T, ExprValueKind VK, ExprObjectKind OK);<br>
> +  MemberExpr(EmptyShell Empty)<br>
> +      : Expr(MemberExprClass, Empty), Base(), MemberDecl() {}<br>
> <br>
> -  static MemberExpr *Create(const ASTContext &C, Expr *base, bool isarrow,<br>
> +public:<br>
> +  static MemberExpr *Create(const ASTContext &C, Expr *Base, bool IsArrow,<br>
>                             SourceLocation OperatorLoc,<br>
>                             NestedNameSpecifierLoc QualifierLoc,<br>
> -                            SourceLocation TemplateKWLoc, ValueDecl *memberdecl,<br>
> -                            DeclAccessPair founddecl,<br>
> +                            SourceLocation TemplateKWLoc, ValueDecl *MemberDecl,<br>
> +                            DeclAccessPair FoundDecl,<br>
>                             DeclarationNameInfo MemberNameInfo,<br>
> -                            const TemplateArgumentListInfo *targs, QualType ty,<br>
> -                            ExprValueKind VK, ExprObjectKind OK);<br>
> +                            const TemplateArgumentListInfo *TemplateArgs,<br>
> +                            QualType T, ExprValueKind VK, ExprObjectKind OK);<br>
> +<br>
> +  /// Create an implicit MemberExpr, with no location, qualifier, template<br>
> +  /// arguments, and so on.<br>
> +  static MemberExpr *CreateImplicit(const ASTContext &C, Expr *Base,<br>
> +                                    bool IsArrow, ValueDecl *MemberDecl,<br>
> +                                    QualType T, ExprValueKind VK,<br>
> +                                    ExprObjectKind OK) {<br>
> +    return Create(C, Base, IsArrow, SourceLocation(), NestedNameSpecifierLoc(),<br>
> +                  SourceLocation(), MemberDecl,<br>
> +                  DeclAccessPair::make(MemberDecl, MemberDecl->getAccess()),<br>
> +                  DeclarationNameInfo(), nullptr, T, VK, OK);<br>
> +  }<br>
> +<br>
> +  static MemberExpr *CreateEmpty(const ASTContext &Context, bool HasQualifier,<br>
> +                                 bool HasFoundDecl,<br>
> +                                 bool HasTemplateKWAndArgsInfo,<br>
> +                                 unsigned NumTemplateArgs);<br>
><br>
>   void setBase(Expr *E) { Base = E; }<br>
>   Expr *getBase() const { return cast<Expr>(Base); }<br>
><br>
> Modified: cfe/trunk/include/clang/AST/Stmt.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=362551&r1=362550&r2=362551&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=362551&r1=362550&r2=362551&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/include/clang/AST/Stmt.h (original)<br>
> +++ cfe/trunk/include/clang/AST/Stmt.h Tue Jun  4 14:29:28 2019<br>
> @@ -453,6 +453,7 @@ protected:<br>
>   enum { NumCallExprBits = 32 };<br>
><br>
>   class MemberExprBitfields {<br>
> +    friend class ASTStmtReader;<br>
>     friend class MemberExpr;<br>
><br>
>     unsigned : NumExprBits;<br>
><br>
> Modified: cfe/trunk/lib/AST/DeclBase.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=362551&r1=362550&r2=362551&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=362551&r1=362550&r2=362551&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/AST/DeclBase.cpp (original)<br>
> +++ cfe/trunk/lib/AST/DeclBase.cpp Tue Jun  4 14:29:28 2019<br>
> @@ -920,6 +920,7 @@ bool Decl::AccessDeclContextSanity() con<br>
>   if (isa<TranslationUnitDecl>(this) ||<br>
>       isa<TemplateTypeParmDecl>(this) ||<br>
>       isa<NonTypeTemplateParmDecl>(this) ||<br>
> +      !getDeclContext() ||<br>
>       !isa<CXXRecordDecl>(getDeclContext()) ||<br>
>       isInvalidDecl() ||<br>
>       isa<StaticAssertDecl>(this) ||<br>
><br>
> Modified: cfe/trunk/lib/AST/Expr.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=362551&r1=362550&r2=362551&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=362551&r1=362550&r2=362551&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/AST/Expr.cpp (original)<br>
> +++ cfe/trunk/lib/AST/Expr.cpp Tue Jun  4 14:29:28 2019<br>
> @@ -1538,29 +1538,44 @@ UnaryExprOrTypeTraitExpr::UnaryExprOrTyp<br>
>   }<br>
> }<br>
> <br>
> +MemberExpr::MemberExpr(Expr *Base, bool IsArrow, SourceLocation OperatorLoc,<br>
> +                       ValueDecl *MemberDecl,<br>
> +                       const DeclarationNameInfo &NameInfo, QualType T,<br>
> +                       ExprValueKind VK, ExprObjectKind OK)<br>
> +    : Expr(MemberExprClass, T, VK, OK, Base->isTypeDependent(),<br>
> +           Base->isValueDependent(), Base->isInstantiationDependent(),<br>
> +           Base->containsUnexpandedParameterPack()),<br>
> +      Base(Base), MemberDecl(MemberDecl), MemberDNLoc(NameInfo.getInfo()),<br>
> +      MemberLoc(NameInfo.getLoc()) {<br>
> +  assert(!NameInfo.getName() ||<br>
> +         MemberDecl->getDeclName() == NameInfo.getName());<br>
> +  MemberExprBits.IsArrow = IsArrow;<br>
> +  MemberExprBits.HasQualifierOrFoundDecl = false;<br>
> +  MemberExprBits.HasTemplateKWAndArgsInfo = false;<br>
> +  MemberExprBits.HadMultipleCandidates = false;<br>
> +  MemberExprBits.OperatorLoc = OperatorLoc;<br>
> +}<br>
> +<br>
> MemberExpr *MemberExpr::Create(<br>
> -    const ASTContext &C, Expr *base, bool isarrow, SourceLocation OperatorLoc,<br>
> +    const ASTContext &C, Expr *Base, bool IsArrow, SourceLocation OperatorLoc,<br>
>     NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,<br>
> -    ValueDecl *memberdecl, DeclAccessPair founddecl,<br>
> -    DeclarationNameInfo nameinfo, const TemplateArgumentListInfo *targs,<br>
> -    QualType ty, ExprValueKind vk, ExprObjectKind ok) {<br>
> -<br>
> -  bool hasQualOrFound = (QualifierLoc ||<br>
> -                         founddecl.getDecl() != memberdecl ||<br>
> -                         founddecl.getAccess() != memberdecl->getAccess());<br>
> -<br>
> -  bool HasTemplateKWAndArgsInfo = targs || TemplateKWLoc.isValid();<br>
> +    ValueDecl *MemberDecl, DeclAccessPair FoundDecl,<br>
> +    DeclarationNameInfo NameInfo, const TemplateArgumentListInfo *TemplateArgs,<br>
> +    QualType T, ExprValueKind VK, ExprObjectKind OK) {<br>
> +  bool HasQualOrFound = QualifierLoc || FoundDecl.getDecl() != MemberDecl ||<br>
> +                        FoundDecl.getAccess() != MemberDecl->getAccess();<br>
> +  bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.isValid();<br>
>   std::size_t Size =<br>
>       totalSizeToAlloc<MemberExprNameQualifier, ASTTemplateKWAndArgsInfo,<br>
> -                       TemplateArgumentLoc>(hasQualOrFound ? 1 : 0,<br>
> -                                            HasTemplateKWAndArgsInfo ? 1 : 0,<br>
> -                                            targs ? targs->size() : 0);<br>
> +                       TemplateArgumentLoc>(<br>
> +          HasQualOrFound ? 1 : 0, HasTemplateKWAndArgsInfo ? 1 : 0,<br>
> +          TemplateArgs ? TemplateArgs->size() : 0);<br>
><br>
>   void *Mem = C.Allocate(Size, alignof(MemberExpr));<br>
>   MemberExpr *E = new (Mem)<br>
> -      MemberExpr(base, isarrow, OperatorLoc, memberdecl, nameinfo, ty, vk, ok);<br>
> +      MemberExpr(Base, IsArrow, OperatorLoc, MemberDecl, NameInfo, T, VK, OK);<br>
> <br>
> -  if (hasQualOrFound) {<br>
> +  if (HasQualOrFound) {<br>
>     // FIXME: Wrong. We should be looking at the member declaration we found.<br>
>     if (QualifierLoc && QualifierLoc.getNestedNameSpecifier()->isDependent()) {<br>
>       E->setValueDependent(true);<br>
> @@ -1576,19 +1591,20 @@ MemberExpr *MemberExpr::Create(<br>
>     MemberExprNameQualifier *NQ =<br>
>         E->getTrailingObjects<MemberExprNameQualifier>();<br>
>     NQ->QualifierLoc = QualifierLoc;<br>
> -    NQ->FoundDecl = founddecl;<br>
> +    NQ->FoundDecl = FoundDecl;<br>
>   }<br>
><br>
>   E->MemberExprBits.HasTemplateKWAndArgsInfo =<br>
> -      (targs || TemplateKWLoc.isValid());<br>
> +      TemplateArgs || TemplateKWLoc.isValid();<br>
> <br>
> -  if (targs) {<br>
> +  if (TemplateArgs) {<br>
>     bool Dependent = false;<br>
>     bool InstantiationDependent = false;<br>
>     bool ContainsUnexpandedParameterPack = false;<br>
>     E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(<br>
> -        TemplateKWLoc, *targs, E->getTrailingObjects<TemplateArgumentLoc>(),<br>
> -        Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);<br>
> +        TemplateKWLoc, *TemplateArgs,<br>
> +        E->getTrailingObjects<TemplateArgumentLoc>(), Dependent,<br>
> +        InstantiationDependent, ContainsUnexpandedParameterPack);<br>
>     if (InstantiationDependent)<br>
>       E->setInstantiationDependent(true);<br>
>   } else if (TemplateKWLoc.isValid()) {<br>
> @@ -1599,6 +1615,22 @@ MemberExpr *MemberExpr::Create(<br>
>   return E;<br>
> }<br>
> <br>
> +MemberExpr *MemberExpr::CreateEmpty(const ASTContext &Context,<br>
> +                                    bool HasQualifier, bool HasFoundDecl,<br>
> +                                    bool HasTemplateKWAndArgsInfo,<br>
> +                                    unsigned NumTemplateArgs) {<br>
> +  assert((!NumTemplateArgs || HasTemplateKWAndArgsInfo) &&<br>
> +         "template args but no template arg info?");<br>
> +  bool HasQualOrFound = HasQualifier || HasFoundDecl;<br>
> +  std::size_t Size =<br>
> +      totalSizeToAlloc<MemberExprNameQualifier, ASTTemplateKWAndArgsInfo,<br>
> +                       TemplateArgumentLoc>(HasQualOrFound ? 1 : 0,<br>
> +                                            HasTemplateKWAndArgsInfo ? 1 : 0,<br>
> +                                            NumTemplateArgs);<br>
> +  void *Mem = Context.Allocate(Size, alignof(MemberExpr));<br>
> +  return new (Mem) MemberExpr(EmptyShell());<br>
> +}<br>
> +<br>
> SourceLocation MemberExpr::getBeginLoc() const {<br>
>   if (isImplicitAccess()) {<br>
>     if (hasQualifier())<br>
><br>
> Modified: cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp?rev=362551&r1=362550&r2=362551&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp?rev=362551&r1=362550&r2=362551&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp (original)<br>
> +++ cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp Tue Jun  4 14:29:28 2019<br>
> @@ -881,9 +881,8 @@ RewriteModernObjC::getIvarAccessString(O<br>
>                                         IvarT, nullptr,<br>
>                                         /*BitWidth=*/nullptr, /*Mutable=*/true,<br>
>                                         ICIS_NoInit);<br>
> -      MemberExpr *ME = new (Context)<br>
> -          MemberExpr(PE, true, SourceLocation(), FD, SourceLocation(),<br>
> -                     FD->getType(), VK_LValue, OK_Ordinary);<br>
> +      MemberExpr *ME = MemberExpr::CreateImplicit(<br>
> +          *Context, PE, true, FD, FD->getType(), VK_LValue, OK_Ordinary);<br>
>       IvarT = Context->getDecltypeType(ME, ME->getType());<br>
>     }<br>
>   }<br>
> @@ -2736,9 +2735,9 @@ Stmt *RewriteModernObjC::RewriteObjCArra<br>
>                                     Context->getPointerType(Context->VoidPtrTy),<br>
>                                     nullptr, /*BitWidth=*/nullptr,<br>
>                                     /*Mutable=*/true, ICIS_NoInit);<br>
> -  MemberExpr *ArrayLiteralME = new (Context)<br>
> -      MemberExpr(NSArrayCallExpr, false, SourceLocation(), ARRFD,<br>
> -                 SourceLocation(), ARRFD->getType(), VK_LValue, OK_Ordinary);<br>
> +  MemberExpr *ArrayLiteralME =<br>
> +      MemberExpr::CreateImplicit(*Context, NSArrayCallExpr, false, ARRFD,<br>
> +                                 ARRFD->getType(), VK_LValue, OK_Ordinary);<br>
>   QualType ConstIdT = Context->getObjCIdType().withConst();<br>
>   CStyleCastExpr * ArrayLiteralObjects =<br>
>     NoTypeInfoCStyleCastExpr(Context,<br>
> @@ -2865,9 +2864,9 @@ Stmt *RewriteModernObjC::RewriteObjCDict<br>
>                                        Context->getPointerType(Context->VoidPtrTy),<br>
>                                        nullptr, /*BitWidth=*/nullptr,<br>
>                                        /*Mutable=*/true, ICIS_NoInit);<br>
> -  MemberExpr *DictLiteralValueME = new (Context)<br>
> -      MemberExpr(NSValueCallExpr, false, SourceLocation(), ARRFD,<br>
> -                 SourceLocation(), ARRFD->getType(), VK_LValue, OK_Ordinary);<br>
> +  MemberExpr *DictLiteralValueME =<br>
> +      MemberExpr::CreateImplicit(*Context, NSValueCallExpr, false, ARRFD,<br>
> +                                 ARRFD->getType(), VK_LValue, OK_Ordinary);<br>
>   QualType ConstIdT = Context->getObjCIdType().withConst();<br>
>   CStyleCastExpr * DictValueObjects =<br>
>     NoTypeInfoCStyleCastExpr(Context,<br>
> @@ -2878,9 +2877,9 @@ Stmt *RewriteModernObjC::RewriteObjCDict<br>
>   Expr *NSKeyCallExpr = CallExpr::Create(<br>
>       *Context, NSDictDRE, KeyExprs, NSDictFType, VK_LValue, SourceLocation());<br>
> <br>
> -  MemberExpr *DictLiteralKeyME = new (Context)<br>
> -      MemberExpr(NSKeyCallExpr, false, SourceLocation(), ARRFD,<br>
> -                 SourceLocation(), ARRFD->getType(), VK_LValue, OK_Ordinary);<br>
> +  MemberExpr *DictLiteralKeyME =<br>
> +      MemberExpr::CreateImplicit(*Context, NSKeyCallExpr, false, ARRFD,<br>
> +                                 ARRFD->getType(), VK_LValue, OK_Ordinary);<br>
><br>
>   CStyleCastExpr * DictKeyObjects =<br>
>     NoTypeInfoCStyleCastExpr(Context,<br>
> @@ -3180,9 +3179,8 @@ Expr *RewriteModernObjC::SynthMsgSendStr<br>
>                                     returnType, nullptr,<br>
>                                     /*BitWidth=*/nullptr,<br>
>                                     /*Mutable=*/true, ICIS_NoInit);<br>
> -  MemberExpr *ME = new (Context)<br>
> -      MemberExpr(STCE, false, SourceLocation(), FieldD, SourceLocation(),<br>
> -                 FieldD->getType(), VK_LValue, OK_Ordinary);<br>
> +  MemberExpr *ME = MemberExpr::CreateImplicit(<br>
> +      *Context, STCE, false, FieldD, FieldD->getType(), VK_LValue, OK_Ordinary);<br>
><br>
>   return ME;<br>
> }<br>
> @@ -4629,9 +4627,8 @@ Stmt *RewriteModernObjC::SynthesizeBlock<br>
>                                     Context->VoidPtrTy, nullptr,<br>
>                                     /*BitWidth=*/nullptr, /*Mutable=*/true,<br>
>                                     ICIS_NoInit);<br>
> -  MemberExpr *ME =<br>
> -      new (Context) MemberExpr(PE, true, SourceLocation(), FD, SourceLocation(),<br>
> -                               FD->getType(), VK_LValue, OK_Ordinary);<br>
> +  MemberExpr *ME = MemberExpr::CreateImplicit(<br>
> +      *Context, PE, true, FD, FD->getType(), VK_LValue, OK_Ordinary);<br>
><br>
>   CastExpr *FunkCast = NoTypeInfoCStyleCastExpr(Context, PtrToFuncCastType,<br>
>                                                 CK_BitCast, ME);<br>
> @@ -4676,9 +4673,8 @@ Stmt *RewriteModernObjC::RewriteBlockDec<br>
>                                     Context->VoidPtrTy, nullptr,<br>
>                                     /*BitWidth=*/nullptr, /*Mutable=*/true,<br>
>                                     ICIS_NoInit);<br>
> -  MemberExpr *ME = new (Context)<br>
> -      MemberExpr(DeclRefExp, isArrow, SourceLocation(), FD, SourceLocation(),<br>
> -                 FD->getType(), VK_LValue, OK_Ordinary);<br>
> +  MemberExpr *ME = MemberExpr::CreateImplicit(<br>
> +      *Context, DeclRefExp, isArrow, FD, FD->getType(), VK_LValue, OK_Ordinary);<br>
><br>
>   StringRef Name = VD->getName();<br>
>   FD = FieldDecl::Create(*Context, nullptr, SourceLocation(), SourceLocation(),<br>
> @@ -4686,9 +4682,8 @@ Stmt *RewriteModernObjC::RewriteBlockDec<br>
>                          Context->VoidPtrTy, nullptr,<br>
>                          /*BitWidth=*/nullptr, /*Mutable=*/true,<br>
>                          ICIS_NoInit);<br>
> -  ME =<br>
> -      new (Context) MemberExpr(ME, true, SourceLocation(), FD, SourceLocation(),<br>
> -                               DeclRefExp->getType(), VK_LValue, OK_Ordinary);<br>
> +  ME = MemberExpr::CreateImplicit(*Context, ME, true, FD, DeclRefExp->getType(),<br>
> +                                  VK_LValue, OK_Ordinary);<br>
><br>
>   // Need parens to enforce precedence.<br>
>   ParenExpr *PE = new (Context) ParenExpr(DeclRefExp->getExprLoc(),<br>
> @@ -7528,9 +7523,8 @@ Stmt *RewriteModernObjC::RewriteObjCIvar<br>
>                                             IvarT, nullptr,<br>
>                                             /*BitWidth=*/nullptr,<br>
>                                             /*Mutable=*/true, ICIS_NoInit);<br>
> -          MemberExpr *ME = new (Context)<br>
> -              MemberExpr(PE, true, SourceLocation(), FD, SourceLocation(),<br>
> -                         FD->getType(), VK_LValue, OK_Ordinary);<br>
> +          MemberExpr *ME = MemberExpr::CreateImplicit(<br>
> +              *Context, PE, true, FD, FD->getType(), VK_LValue, OK_Ordinary);<br>
>           IvarT = Context->getDecltypeType(ME, ME->getType());<br>
>         }<br>
>       }<br>
> @@ -7557,9 +7551,9 @@ Stmt *RewriteModernObjC::RewriteObjCIvar<br>
>                                           D->getType(), nullptr,<br>
>                                           /*BitWidth=*/D->getBitWidth(),<br>
>                                           /*Mutable=*/true, ICIS_NoInit);<br>
> -        MemberExpr *ME = new (Context)<br>
> -            MemberExpr(PE, /*isArrow*/ false, SourceLocation(), FD,<br>
> -                       SourceLocation(), FD->getType(), VK_LValue, OK_Ordinary);<br>
> +        MemberExpr *ME =<br>
> +            MemberExpr::CreateImplicit(*Context, PE, /*isArrow*/ false, FD,<br>
> +                                       FD->getType(), VK_LValue, OK_Ordinary);<br>
>         Replacement = ME;<br>
><br>
>       }<br>
><br>
> Modified: cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp?rev=362551&r1=362550&r2=362551&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp?rev=362551&r1=362550&r2=362551&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp (original)<br>
> +++ cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp Tue Jun  4 14:29:28 2019<br>
> @@ -3793,9 +3793,8 @@ Stmt *RewriteObjC::SynthesizeBlockCall(C<br>
>                                     Context->VoidPtrTy, nullptr,<br>
>                                     /*BitWidth=*/nullptr, /*Mutable=*/true,<br>
>                                     ICIS_NoInit);<br>
> -  MemberExpr *ME =<br>
> -      new (Context) MemberExpr(PE, true, SourceLocation(), FD, SourceLocation(),<br>
> -                               FD->getType(), VK_LValue, OK_Ordinary);<br>
> +  MemberExpr *ME = MemberExpr::CreateImplicit(<br>
> +      *Context, PE, true, FD, FD->getType(), VK_LValue, OK_Ordinary);<br>
><br>
>   CastExpr *FunkCast = NoTypeInfoCStyleCastExpr(Context, PtrToFuncCastType,<br>
>                                                 CK_BitCast, ME);<br>
> @@ -3840,9 +3839,9 @@ Stmt *RewriteObjC::RewriteBlockDeclRefEx<br>
>                                     Context->VoidPtrTy, nullptr,<br>
>                                     /*BitWidth=*/nullptr, /*Mutable=*/true,<br>
>                                     ICIS_NoInit);<br>
> -  MemberExpr *ME = new (Context)<br>
> -      MemberExpr(DeclRefExp, isArrow, SourceLocation(), FD, SourceLocation(),<br>
> -                 FD->getType(), VK_LValue, OK_Ordinary);<br>
> +  MemberExpr *ME =<br>
> +      MemberExpr::CreateImplicit(*Context, DeclRefExp, isArrow, FD,<br>
> +                                 FD->getType(), VK_LValue, OK_Ordinary);<br>
><br>
>   StringRef Name = VD->getName();<br>
>   FD = FieldDecl::Create(*Context, nullptr, SourceLocation(), SourceLocation(),<br>
> @@ -3850,9 +3849,8 @@ Stmt *RewriteObjC::RewriteBlockDeclRefEx<br>
>                          Context->VoidPtrTy, nullptr,<br>
>                          /*BitWidth=*/nullptr, /*Mutable=*/true,<br>
>                          ICIS_NoInit);<br>
> -  ME =<br>
> -      new (Context) MemberExpr(ME, true, SourceLocation(), FD, SourceLocation(),<br>
> -                               DeclRefExp->getType(), VK_LValue, OK_Ordinary);<br>
> +  ME = MemberExpr::CreateImplicit(*Context, ME, true, FD, DeclRefExp->getType(),<br>
> +                                  VK_LValue, OK_Ordinary);<br>
><br>
>   // Need parens to enforce precedence.<br>
>   ParenExpr *PE = new (Context) ParenExpr(DeclRefExp->getExprLoc(),<br>
> @@ -5830,10 +5828,10 @@ Stmt *RewriteObjCFragileABI::RewriteObjC<br>
>                                               OldRange.getEnd(),<br>
>                                               castExpr);<br>
>       if (IV->isFreeIvar() &&<br>
> -          declaresSameEntity(CurMethodDef->getClassInterface(), iFaceDecl->getDecl())) {<br>
> -        MemberExpr *ME = new (Context)<br>
> -            MemberExpr(PE, true, SourceLocation(), D, IV->getLocation(),<br>
> -                       D->getType(), VK_LValue, OK_Ordinary);<br>
> +          declaresSameEntity(CurMethodDef->getClassInterface(),<br>
> +                             iFaceDecl->getDecl())) {<br>
> +        MemberExpr *ME = MemberExpr::CreateImplicit(<br>
> +            *Context, PE, true, D, D->getType(), VK_LValue, OK_Ordinary);<br>
>         Replacement = ME;<br>
>       } else {<br>
>         IV->setBase(PE);<br>
><br>
> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=362551&r1=362550&r2=362551&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=362551&r1=362550&r2=362551&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)<br>
> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Jun  4 14:29:28 2019<br>
> @@ -7189,9 +7189,12 @@ ExprResult Sema::BuildCXXMemberCallExpr(<br>
>     }<br>
>   }<br>
> <br>
> -  MemberExpr *ME = new (Context) MemberExpr(<br>
> -      Exp.get(), /*IsArrow=*/false, SourceLocation(), Method, SourceLocation(),<br>
> -      Context.BoundMemberTy, VK_RValue, OK_Ordinary);<br>
> +  MemberExpr *ME = MemberExpr::Create(<br>
> +      Context, Exp.get(), /*IsArrow=*/false, SourceLocation(),<br>
> +      NestedNameSpecifierLoc(), SourceLocation(), Method,<br>
> +      DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()),<br>
> +      DeclarationNameInfo(), /*TemplateArgs=*/nullptr, Context.BoundMemberTy,<br>
> +      VK_RValue, OK_Ordinary);<br>
>   if (HadMultipleCandidates)<br>
>     ME->setHadMultipleCandidates(true);<br>
>   MarkMemberReferenced(ME);<br>
><br>
> Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=362551&r1=362550&r2=362551&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=362551&r1=362550&r2=362551&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)<br>
> +++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Tue Jun  4 14:29:28 2019<br>
> @@ -752,9 +752,42 @@ void ASTStmtReader::VisitCXXMemberCallEx<br>
> }<br>
> <br>
> void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {<br>
> -  // Don't call VisitExpr, this is fully initialized at creation.<br>
> -  assert(E->getStmtClass() == Stmt::MemberExprClass &&<br>
> -         "It's a subclass, we must advance Idx!");<br>
> +  VisitExpr(E);<br>
> +<br>
> +  bool HasQualifier = Record.readInt();<br>
> +  bool HasFoundDecl = Record.readInt();<br>
> +  bool HasTemplateInfo = Record.readInt();<br>
> +  unsigned NumTemplateArgs = Record.readInt();<br>
> +<br>
> +  E->Base = Record.readSubExpr();<br>
> +  E->MemberDecl = Record.readDeclAs<ValueDecl>();<br>
> +  Record.readDeclarationNameLoc(E->MemberDNLoc, E->MemberDecl->getDeclName());<br>
> +  E->MemberLoc = Record.readSourceLocation();<br>
> +  E->MemberExprBits.IsArrow = Record.readInt();<br>
> +  E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;<br>
> +  E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;<br>
> +  E->MemberExprBits.HadMultipleCandidates = Record.readInt();<br>
> +  E->MemberExprBits.OperatorLoc = Record.readSourceLocation();<br>
> +<br>
> +  if (HasQualifier || HasFoundDecl)<br>
> +    *E->getTrailingObjects<MemberExprNameQualifier>() =<br>
> +        MemberExprNameQualifier();<br>
> +<br>
> +  if (HasFoundDecl) {<br>
> +    auto *FoundD = Record.readDeclAs<NamedDecl>();<br>
> +    auto AS = (AccessSpecifier)Record.readInt();<br>
> +    E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl =<br>
> +        DeclAccessPair::make(FoundD, AS);<br>
> +  }<br>
> +<br>
> +  if (HasQualifier)<br>
> +    E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =<br>
> +        Record.readNestedNameSpecifierLoc();<br>
> +<br>
> +  if (HasTemplateInfo)<br>
> +    ReadTemplateKWAndArgsInfo(<br>
> +        *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),<br>
> +        E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);<br>
> }<br>
> <br>
> void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {<br>
> @@ -2551,55 +2584,12 @@ Stmt *ASTReader::ReadStmtFromStream(Modu<br>
>           Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);<br>
>       break;<br>
> <br>
> -    case EXPR_MEMBER: {<br>
> -      // We load everything here and fully initialize it at creation.<br>
> -      // That way we can use MemberExpr::Create and don't have to duplicate its<br>
> -      // logic with a MemberExpr::CreateEmpty.<br>
> -<br>
> -      assert(Record.getIdx() == 0);<br>
> -      NestedNameSpecifierLoc QualifierLoc;<br>
> -      if (Record.readInt()) { // HasQualifier.<br>
> -        QualifierLoc = Record.readNestedNameSpecifierLoc();<br>
> -      }<br>
> -<br>
> -      SourceLocation TemplateKWLoc;<br>
> -      TemplateArgumentListInfo ArgInfo;<br>
> -      bool HasTemplateKWAndArgsInfo = Record.readInt();<br>
> -      if (HasTemplateKWAndArgsInfo) {<br>
> -        TemplateKWLoc = Record.readSourceLocation();<br>
> -        unsigned NumTemplateArgs = Record.readInt();<br>
> -        ArgInfo.setLAngleLoc(Record.readSourceLocation());<br>
> -        ArgInfo.setRAngleLoc(Record.readSourceLocation());<br>
> -        for (unsigned i = 0; i != NumTemplateArgs; ++i)<br>
> -          ArgInfo.addArgument(Record.readTemplateArgumentLoc());<br>
> -      }<br>
> -<br>
> -      bool HadMultipleCandidates = Record.readInt();<br>
> -<br>
> -      auto *FoundD = Record.readDeclAs<NamedDecl>();<br>
> -      auto AS = (AccessSpecifier)Record.readInt();<br>
> -      DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);<br>
> -<br>
> -      QualType T = Record.readType();<br>
> -      auto VK = static_cast<ExprValueKind>(Record.readInt());<br>
> -      auto OK = static_cast<ExprObjectKind>(Record.readInt());<br>
> -      Expr *Base = ReadSubExpr();<br>
> -      auto *MemberD = Record.readDeclAs<ValueDecl>();<br>
> -      SourceLocation MemberLoc = Record.readSourceLocation();<br>
> -      DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);<br>
> -      bool IsArrow = Record.readInt();<br>
> -      SourceLocation OperatorLoc = Record.readSourceLocation();<br>
> -<br>
> -      S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc,<br>
> -                             TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,<br>
> -                             HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T,<br>
> -                             VK, OK);<br>
> -      Record.readDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc,<br>
> -                                    MemberD->getDeclName());<br>
> -      if (HadMultipleCandidates)<br>
> -        cast<MemberExpr>(S)->setHadMultipleCandidates(true);<br>
> +    case EXPR_MEMBER:<br>
> +      S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],<br>
> +                                  Record[ASTStmtReader::NumExprFields + 1],<br>
> +                                  Record[ASTStmtReader::NumExprFields + 2],<br>
> +                                  Record[ASTStmtReader::NumExprFields + 3]);<br>
>       break;<br>
> -    }<br>
><br>
>     case EXPR_BINARY_OPERATOR:<br>
>       S = new (Context) BinaryOperator(Empty);<br>
><br>
> Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=362551&r1=362550&r2=362551&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=362551&r1=362550&r2=362551&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)<br>
> +++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Tue Jun  4 14:29:28 2019<br>
> @@ -660,39 +660,45 @@ void ASTStmtWriter::VisitCallExpr(CallEx<br>
> }<br>
> <br>
> void ASTStmtWriter::VisitMemberExpr(MemberExpr *E) {<br>
> -  // Don't call VisitExpr, we'll write everything here.<br>
> +  VisitExpr(E);<br>
> <br>
> -  Record.push_back(E->hasQualifier());<br>
> -  if (E->hasQualifier())<br>
> -    Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());<br>
> -<br>
> -  Record.push_back(E->hasTemplateKWAndArgsInfo());<br>
> -  if (E->hasTemplateKWAndArgsInfo()) {<br>
> -    Record.AddSourceLocation(E->getTemplateKeywordLoc());<br>
> -    unsigned NumTemplateArgs = E->getNumTemplateArgs();<br>
> -    Record.push_back(NumTemplateArgs);<br>
> -    Record.AddSourceLocation(E->getLAngleLoc());<br>
> -    Record.AddSourceLocation(E->getRAngleLoc());<br>
> -    for (unsigned i=0; i != NumTemplateArgs; ++i)<br>
> -      Record.AddTemplateArgumentLoc(E->getTemplateArgs()[i]);<br>
> -  }<br>
> -<br>
> -  Record.push_back(E->hadMultipleCandidates());<br>
> +  bool HasQualifier = E->hasQualifier();<br>
> +  bool HasFoundDecl =<br>
> +      E->hasQualifierOrFoundDecl() &&<br>
> +      (E->getFoundDecl().getDecl() != E->getMemberDecl() ||<br>
> +       E->getFoundDecl().getAccess() != E->getMemberDecl()->getAccess());<br>
> +  bool HasTemplateInfo = E->hasTemplateKWAndArgsInfo();<br>
> +  unsigned NumTemplateArgs = E->getNumTemplateArgs();<br>
> +<br>
> +  // Write these first for easy access when deserializing, as they affect the<br>
> +  // size of the MemberExpr.<br>
> +  Record.push_back(HasQualifier);<br>
> +  Record.push_back(HasFoundDecl);<br>
> +  Record.push_back(HasTemplateInfo);<br>
> +  Record.push_back(NumTemplateArgs);<br>
> <br>
> -  DeclAccessPair FoundDecl = E->getFoundDecl();<br>
> -  Record.AddDeclRef(FoundDecl.getDecl());<br>
> -  Record.push_back(FoundDecl.getAccess());<br>
> -<br>
> -  Record.AddTypeRef(E->getType());<br>
> -  Record.push_back(E->getValueKind());<br>
> -  Record.push_back(E->getObjectKind());<br>
>   Record.AddStmt(E->getBase());<br>
>   Record.AddDeclRef(E->getMemberDecl());<br>
> +  Record.AddDeclarationNameLoc(E->MemberDNLoc,<br>
> +                               E->getMemberDecl()->getDeclName());<br>
>   Record.AddSourceLocation(E->getMemberLoc());<br>
>   Record.push_back(E->isArrow());<br>
> +  Record.push_back(E->hadMultipleCandidates());<br>
>   Record.AddSourceLocation(E->getOperatorLoc());<br>
> -  Record.AddDeclarationNameLoc(E->MemberDNLoc,<br>
> -                               E->getMemberDecl()->getDeclName());<br>
> +<br>
> +  if (HasFoundDecl) {<br>
> +    DeclAccessPair FoundDecl = E->getFoundDecl();<br>
> +    Record.AddDeclRef(FoundDecl.getDecl());<br>
> +    Record.push_back(FoundDecl.getAccess());<br>
> +  }<br>
> +<br>
> +  if (HasQualifier)<br>
> +    Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());<br>
> +<br>
> +  if (HasTemplateInfo)<br>
> +    AddTemplateKWAndArgsInfo(*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),<br>
> +                             E->getTrailingObjects<TemplateArgumentLoc>());<br>
> +<br>
>   Code = serialization::EXPR_MEMBER;<br>
> }<br>
> <br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org" target="_blank" rel="noreferrer">cfe-commits@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" rel="noreferrer">cfe-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" rel="noreferrer">cfe-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a>Yes,<br>
</blockquote></div></div></div>