<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Richard, I'm not sure that you're right
      in this case.<br>
      Technically yes, for lambdas it means that DRE refers to enclosing
      local, but you can consider this enclosing local as a captured
      copy of an original variable. From this point of view you can
      consider DRE for this local as a ref to the original captured
      variable.<br>
      Moreover, a fix committed in <span style="font-size:13px">r225060
        fixes just the order of captures processing for some corner
        cases, but not the processing itself. <br>
      </span>
      <pre class="moz-signature" cols="72">Best regards,
Alexey Bataev
=============
Software Engineer
Intel Compiler Team</pre>
      02.01.2015 18:10, Richard Smith пишет:<br>
    </div>
    <blockquote
cite="mid:CAOfiQqmiboYKSChnzDqD=py7NBtOSRYBR1hR+BMAEZhT1+b0pg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">On Tue, Dec 16, 2014 at 12:01 AM,
            Alexey Bataev <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:a.bataev@hotmail.com" target="_blank">a.bataev@hotmail.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author:
              abataev<br>
              Date: Tue Dec 16 02:01:48 2014<br>
              New Revision: 224329<br>
              <br>
              URL: <a moz-do-not-send="true"
                href="http://llvm.org/viewvc/llvm-project?rev=224329&view=rev"
                target="_blank">http://llvm.org/viewvc/llvm-project?rev=224329&view=rev</a><br>
              Log:<br>
              Renamed RefersToEnclosingLocal bitfield to
              RefersToCapturedVariable.<br>
              Bitfield RefersToEnclosingLocal of
              Stmt::DeclRefExprBitfields renamed to
              RefersToCapturedVariable to reflect latest changes
              introduced in commit 224323. Also renamed method
              Expr::refersToEnclosingLocal() to
              Expr::refersToCapturedVariable() and comments for constant
              arguments.<br>
              No functional changes.<br>
            </blockquote>
            <div><br>
            </div>
            <div>This seems like a bad idea for me. It's incorrect: for
              a lambda, the flag means that the DeclRefExpr refers to an
              enclosing local, and does *not* imply that the variable is
              necessarily captured. This confusion has already led to a
              bug (fixed in <span style="font-size:13px">r225060).</span></div>
            <div><span style="font-size:13px"><br>
              </span></div>
            <div><span style="font-size:13px">It seems like the purpose
                of this change is to allow the same flag to be used to
                represent the case where a CapturedStmt captures a
                global variable? Using the same flag to mean "this is a
                local from an enclosing function scope (that may or may
                not be captured)" and to mean "this is a global that is
                definitely captured" seems problematic.</span></div>
            <div><br>
            </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Modified:<br>
                  cfe/trunk/include/clang/AST/Expr.h<br>
                  cfe/trunk/include/clang/AST/Stmt.h<br>
                  cfe/trunk/lib/AST/ASTImporter.cpp<br>
                  cfe/trunk/lib/AST/Expr.cpp<br>
                  cfe/trunk/lib/Analysis/BodyFarm.cpp<br>
                  cfe/trunk/lib/CodeGen/CGExpr.cpp<br>
                  cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp<br>
                  cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp<br>
                  cfe/trunk/lib/Sema/SemaChecking.cpp<br>
                  cfe/trunk/lib/Sema/SemaDecl.cpp<br>
                  cfe/trunk/lib/Sema/SemaExpr.cpp<br>
                  cfe/trunk/lib/Sema/SemaOpenMP.cpp<br>
                  cfe/trunk/lib/Sema/SemaStmt.cpp<br>
                  cfe/trunk/lib/Serialization/ASTReaderStmt.cpp<br>
                  cfe/trunk/lib/Serialization/ASTWriterDecl.cpp<br>
                  cfe/trunk/lib/Serialization/ASTWriterStmt.cpp<br>
              <br>
              Modified: cfe/trunk/include/clang/AST/Expr.h<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/include/clang/AST/Expr.h (original)<br>
              +++ cfe/trunk/include/clang/AST/Expr.h Tue Dec 16 02:01:48
              2014<br>
              @@ -886,9 +886,9 @@ public:<br>
               ///   DeclRefExprBits.HasTemplateKWAndArgsInfo:<br>
               ///       Specifies when this declaration reference
              expression has an explicit<br>
               ///       C++ template keyword and/or template argument
              list.<br>
              -///   DeclRefExprBits.RefersToEnclosingLocal<br>
              +///   DeclRefExprBits.RefersToCapturedVariable<br>
               ///       Specifies when this declaration reference
              expression (validly)<br>
              -///       refers to a local variable from a different
              function.<br>
              +///       refers to a captured variable.<br>
               class DeclRefExpr : public Expr {<br>
                 /// \brief The declaration that we are referencing.<br>
                 ValueDecl *D;<br>
              @@ -933,7 +933,7 @@ class DeclRefExpr : public Expr {<br>
                 DeclRefExpr(const ASTContext &Ctx,<br>
                             NestedNameSpecifierLoc QualifierLoc,<br>
                             SourceLocation TemplateKWLoc,<br>
              -              ValueDecl *D, bool refersToEnclosingLocal,<br>
              +              ValueDecl *D, bool
              RefersToCapturedVariable,<br>
                             const DeclarationNameInfo &NameInfo,<br>
                             NamedDecl *FoundD,<br>
                             const TemplateArgumentListInfo
              *TemplateArgs,<br>
              @@ -948,7 +948,7 @@ class DeclRefExpr : public Expr {<br>
                 void computeDependence(const ASTContext &C);<br>
              <br>
               public:<br>
              -  DeclRefExpr(ValueDecl *D, bool refersToEnclosingLocal,
              QualType T,<br>
              +  DeclRefExpr(ValueDecl *D, bool
              RefersToCapturedVariable, QualType T,<br>
                             ExprValueKind VK, SourceLocation L,<br>
                             const DeclarationNameLoc &LocInfo =
              DeclarationNameLoc())<br>
                   : Expr(DeclRefExprClass, T, VK, OK_Ordinary, false,
              false, false, false),<br>
              @@ -957,22 +957,22 @@ public:<br>
                   DeclRefExprBits.HasTemplateKWAndArgsInfo = 0;<br>
                   DeclRefExprBits.HasFoundDecl = 0;<br>
                   DeclRefExprBits.HadMultipleCandidates = 0;<br>
              -    DeclRefExprBits.RefersToEnclosingLocal =
              refersToEnclosingLocal;<br>
              +    DeclRefExprBits.RefersToCapturedVariable =
              RefersToCapturedVariable;<br>
                   computeDependence(D->getASTContext());<br>
                 }<br>
              <br>
                 static DeclRefExpr *<br>
                 Create(const ASTContext &Context,
              NestedNameSpecifierLoc QualifierLoc,<br>
              -         SourceLocation TemplateKWLoc, ValueDecl *D, bool
              isEnclosingLocal,<br>
              -         SourceLocation NameLoc, QualType T,
              ExprValueKind VK,<br>
              -         NamedDecl *FoundD = nullptr,<br>
              +         SourceLocation TemplateKWLoc, ValueDecl *D,<br>
              +         bool RefersToCapturedVariable, SourceLocation
              NameLoc, QualType T,<br>
              +         ExprValueKind VK, NamedDecl *FoundD = nullptr,<br>
                        const TemplateArgumentListInfo *TemplateArgs =
              nullptr);<br>
              <br>
                 static DeclRefExpr *<br>
                 Create(const ASTContext &Context,
              NestedNameSpecifierLoc QualifierLoc,<br>
              -         SourceLocation TemplateKWLoc, ValueDecl *D, bool
              isEnclosingLocal,<br>
              -         const DeclarationNameInfo &NameInfo,
              QualType T, ExprValueKind VK,<br>
              -         NamedDecl *FoundD = nullptr,<br>
              +         SourceLocation TemplateKWLoc, ValueDecl *D,<br>
              +         bool RefersToCapturedVariable, const
              DeclarationNameInfo &NameInfo,<br>
              +         QualType T, ExprValueKind VK, NamedDecl *FoundD
              = nullptr,<br>
                        const TemplateArgumentListInfo *TemplateArgs =
              nullptr);<br>
              <br>
                 /// \brief Construct an empty declaration reference
              expression.<br>
              @@ -1144,10 +1144,9 @@ public:<br>
                   DeclRefExprBits.HadMultipleCandidates = V;<br>
                 }<br>
              <br>
              -  /// Does this DeclRefExpr refer to a local declaration
              from an<br>
              -  /// enclosing function scope?<br>
              -  bool refersToEnclosingLocal() const {<br>
              -    return DeclRefExprBits.RefersToEnclosingLocal;<br>
              +  /// \brief Does this DeclRefExpr refer to a captured
              variable?<br>
              +  bool refersToCapturedVariable() const {<br>
              +    return DeclRefExprBits.RefersToCapturedVariable;<br>
                 }<br>
              <br>
                 static bool classof(const Stmt *T) {<br>
              <br>
              Modified: cfe/trunk/include/clang/AST/Stmt.h<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/include/clang/AST/Stmt.h (original)<br>
              +++ cfe/trunk/include/clang/AST/Stmt.h Tue Dec 16 02:01:48
              2014<br>
              @@ -212,7 +212,7 @@ protected:<br>
                   unsigned HasTemplateKWAndArgsInfo : 1;<br>
                   unsigned HasFoundDecl : 1;<br>
                   unsigned HadMultipleCandidates : 1;<br>
              -    unsigned RefersToEnclosingLocal : 1;<br>
              +    unsigned RefersToCapturedVariable : 1;<br>
                 };<br>
              <br>
                 class CastExprBitfields {<br>
              <br>
              Modified: cfe/trunk/lib/AST/ASTImporter.cpp<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/lib/AST/ASTImporter.cpp (original)<br>
              +++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Dec 16 02:01:48
              2014<br>
              @@ -4406,7 +4406,7 @@ Expr
              *ASTNodeImporter::VisitDeclRefExpr(<br>
                                                       
              Importer.Import(E->getQualifierLoc()),<br>
                                                 
              Importer.Import(E->getTemplateKeywordLoc()),<br>
                                                        ToD,<br>
              -                                       
               E->refersToEnclosingLocal(),<br>
              +                                       
               E->refersToCapturedVariable(),<br>
                                                       
              Importer.Import(E->getLocation()),<br>
                                                        T,
              E->getValueKind(),<br>
                                                        FoundD,<br>
              <br>
              Modified: cfe/trunk/lib/AST/Expr.cpp<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/lib/AST/Expr.cpp (original)<br>
              +++ cfe/trunk/lib/AST/Expr.cpp Tue Dec 16 02:01:48 2014<br>
              @@ -322,7 +322,7 @@ void
              DeclRefExpr::computeDependence(cons<br>
               DeclRefExpr::DeclRefExpr(const ASTContext &Ctx,<br>
                                        NestedNameSpecifierLoc
              QualifierLoc,<br>
                                        SourceLocation TemplateKWLoc,<br>
              -                         ValueDecl *D, bool
              RefersToEnclosingLocal,<br>
              +                         ValueDecl *D, bool
              RefersToCapturedVariable,<br>
                                        const DeclarationNameInfo
              &NameInfo,<br>
                                        NamedDecl *FoundD,<br>
                                        const TemplateArgumentListInfo
              *TemplateArgs,<br>
              @@ -343,7 +343,7 @@ DeclRefExpr::DeclRefExpr(const
              ASTContex<br>
                   getInternalFoundDecl() = FoundD;<br>
                 DeclRefExprBits.HasTemplateKWAndArgsInfo<br>
                   = (TemplateArgs || TemplateKWLoc.isValid()) ? 1 : 0;<br>
              -  DeclRefExprBits.RefersToEnclosingLocal =
              RefersToEnclosingLocal;<br>
              +  DeclRefExprBits.RefersToCapturedVariable =
              RefersToCapturedVariable;<br>
                 if (TemplateArgs) {<br>
                   bool Dependent = false;<br>
                   bool InstantiationDependent = false;<br>
              @@ -367,14 +367,14 @@ DeclRefExpr
              *DeclRefExpr::Create(const A<br>
                                                NestedNameSpecifierLoc
              QualifierLoc,<br>
                                                SourceLocation
              TemplateKWLoc,<br>
                                                ValueDecl *D,<br>
              -                                 bool
              RefersToEnclosingLocal,<br>
              +                                 bool
              RefersToCapturedVariable,<br>
                                                SourceLocation NameLoc,<br>
                                                QualType T,<br>
                                                ExprValueKind VK,<br>
                                                NamedDecl *FoundD,<br>
                                                const
              TemplateArgumentListInfo *TemplateArgs) {<br>
                 return Create(Context, QualifierLoc, TemplateKWLoc, D,<br>
              -                RefersToEnclosingLocal,<br>
              +                RefersToCapturedVariable,<br>
                               DeclarationNameInfo(D->getDeclName(),
              NameLoc),<br>
                               T, VK, FoundD, TemplateArgs);<br>
               }<br>
              @@ -383,7 +383,7 @@ DeclRefExpr *DeclRefExpr::Create(const
              A<br>
                                                NestedNameSpecifierLoc
              QualifierLoc,<br>
                                                SourceLocation
              TemplateKWLoc,<br>
                                                ValueDecl *D,<br>
              -                                 bool
              RefersToEnclosingLocal,<br>
              +                                 bool
              RefersToCapturedVariable,<br>
                                                const
              DeclarationNameInfo &NameInfo,<br>
                                                QualType T,<br>
                                                ExprValueKind VK,<br>
              @@ -405,7 +405,7 @@ DeclRefExpr *DeclRefExpr::Create(const
              A<br>
              <br>
                 void *Mem = Context.Allocate(Size,
              llvm::alignOf<DeclRefExpr>());<br>
                 return new (Mem) DeclRefExpr(Context, QualifierLoc,
              TemplateKWLoc, D,<br>
              -                               RefersToEnclosingLocal,<br>
              +                               RefersToCapturedVariable,<br>
                                              NameInfo, FoundD,
              TemplateArgs, T, VK);<br>
               }<br>
              <br>
              <br>
              Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)<br>
              +++ cfe/trunk/lib/Analysis/BodyFarm.cpp Tue Dec 16
              02:01:48 2014<br>
              @@ -115,7 +115,7 @@ DeclRefExpr
              *ASTMaker::makeDeclRefExpr(c<br>
                                       /* QualifierLoc = */
              NestedNameSpecifierLoc(),<br>
                                       /* TemplateKWLoc = */
              SourceLocation(),<br>
                                       /* D = */
              const_cast<VarDecl*>(D),<br>
              -                        /* isEnclosingLocal = */ false,<br>
              +                        /* RefersToCapturedVariable = */
              false,<br>
                                       /* NameLoc = */ SourceLocation(),<br>
                                       /* T = */ D->getType(),<br>
                                       /* VK = */ VK_LValue);<br>
              <br>
              Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)<br>
              +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Dec 16 02:01:48
              2014<br>
              @@ -1907,7 +1907,7 @@ LValue
              CodeGenFunction::EmitDeclRefLValu<br>
              <br>
                 if (const auto *VD = dyn_cast<VarDecl>(ND)) {<br>
                   // Check for captured variables.<br>
              -    if (E->refersToEnclosingLocal()) {<br>
              +    if (E->refersToCapturedVariable()) {<br>
                     if (auto *FD = LambdaCaptureFields.lookup(VD))<br>
                       return EmitCapturedFieldLValue(*this, FD,
              CXXABIThisValue);<br>
                     else if (CapturedStmtInfo) {<br>
              @@ -1916,9 +1916,10 @@ LValue
              CodeGenFunction::EmitDeclRefLValu<br>
                       else<br>
                         return EmitCapturedFieldLValue(*this,
              CapturedStmtInfo->lookup(VD),<br>
                                                       
              CapturedStmtInfo->getContextValue());<br>
              -      } else<br>
              -        return MakeAddrLValue(GetAddrOfBlockDecl(VD,
              VD->hasAttr<BlocksAttr>()),<br>
              -                              T, Alignment);<br>
              +      }<br>
              +      assert(isa<BlockDecl>(CurCodeDecl));<br>
              +      return MakeAddrLValue(GetAddrOfBlockDecl(VD,
              VD->hasAttr<BlocksAttr>()),<br>
              +                            T, Alignment);<br>
                   }<br>
              <br>
                   // Global Named registers access via intrinsics only<br>
              <br>
              Modified:
              cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
              (original)<br>
              +++ cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
              Tue Dec 16 02:01:48 2014<br>
              @@ -4564,7 +4564,7 @@ void
              RewriteModernObjC::GetBlockDeclRefE<br>
                   }<br>
                 // Handle specific things.<br>
                 if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S))<br>
              -    if (DRE->refersToEnclosingLocal() ||<br>
              +    if (DRE->refersToCapturedVariable() ||<br>
                     
               HasLocalVariableExternalStorage(DRE->getDecl()))<br>
                     // FIXME: Handle enums.<br>
                     BlockDeclRefs.push_back(DRE);<br>
              @@ -4591,7 +4591,7 @@ void
              RewriteModernObjC::GetInnerBlockDec<br>
                   }<br>
                 // Handle specific things.<br>
                 if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S))
              {<br>
              -    if (DRE->refersToEnclosingLocal() ||<br>
              +    if (DRE->refersToCapturedVariable() ||<br>
                     
               HasLocalVariableExternalStorage(DRE->getDecl())) {<br>
                     if
              (!InnerContexts.count(DRE->getDecl()->getDeclContext()))<br>
                       InnerBlockDeclRefs.push_back(DRE);<br>
              @@ -4772,7 +4772,7 @@ Stmt
              *RewriteModernObjC::RewriteBlockDec<br>
                 // Rewrite the byref variable into
              BYREFVAR->__forwarding->BYREFVAR<br>
                 // for each DeclRefExp where BYREFVAR is name of the
              variable.<br>
                 ValueDecl *VD = DeclRefExp->getDecl();<br>
              -  bool isArrow = DeclRefExp->refersToEnclosingLocal()
              ||<br>
              +  bool isArrow =
              DeclRefExp->refersToCapturedVariable() ||<br>
                               
              HasLocalVariableExternalStorage(DeclRefExp->getDecl());<br>
              <br>
                 FieldDecl *FD = FieldDecl::Create(*Context, nullptr,
              SourceLocation(),<br>
              <br>
              Modified: cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
              (original)<br>
              +++ cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp Tue Dec
              16 02:01:48 2014<br>
              @@ -3672,7 +3672,7 @@ void
              RewriteObjC::GetBlockDeclRefExprs(S<br>
                   }<br>
                 // Handle specific things.<br>
                 if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S))<br>
              -    if (DRE->refersToEnclosingLocal() ||<br>
              +    if (DRE->refersToCapturedVariable() ||<br>
                     
               HasLocalVariableExternalStorage(DRE->getDecl()))<br>
                     // FIXME: Handle enums.<br>
                     BlockDeclRefs.push_back(DRE);<br>
              @@ -3699,7 +3699,7 @@ void
              RewriteObjC::GetInnerBlockDeclRefEx<br>
                   }<br>
                 // Handle specific things.<br>
                 if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S))
              {<br>
              -    if (DRE->refersToEnclosingLocal() ||<br>
              +    if (DRE->refersToCapturedVariable() ||<br>
                     
               HasLocalVariableExternalStorage(DRE->getDecl())) {<br>
                     if
              (!InnerContexts.count(DRE->getDecl()->getDeclContext()))<br>
                       InnerBlockDeclRefs.push_back(DRE);<br>
              @@ -3861,7 +3861,7 @@ Stmt
              *RewriteObjC::RewriteBlockDeclRefEx<br>
                 // Rewrite the byref variable into
              BYREFVAR->__forwarding->BYREFVAR<br>
                 // for each DeclRefExp where BYREFVAR is name of the
              variable.<br>
                 ValueDecl *VD = DeclRefExp->getDecl();<br>
              -  bool isArrow = DeclRefExp->refersToEnclosingLocal()
              ||<br>
              +  bool isArrow =
              DeclRefExp->refersToCapturedVariable() ||<br>
                               
              HasLocalVariableExternalStorage(DeclRefExp->getDecl());<br>
              <br>
                 FieldDecl *FD = FieldDecl::Create(*Context, nullptr,
              SourceLocation(),<br>
              <br>
              Modified: cfe/trunk/lib/Sema/SemaChecking.cpp<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)<br>
              +++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Dec 16
              02:01:48 2014<br>
              @@ -4972,7 +4972,7 @@ static Expr *EvalAddr(Expr *E,
              SmallVect<br>
                   DeclRefExpr *DR = cast<DeclRefExpr>(E);<br>
              <br>
                   // If we leave the immediate function, the lifetime
              isn't about to end.<br>
              -    if (DR->refersToEnclosingLocal())<br>
              +    if (DR->refersToCapturedVariable())<br>
                     return nullptr;<br>
              <br>
                   if (VarDecl *V =
              dyn_cast<VarDecl>(DR->getDecl()))<br>
              @@ -5139,7 +5139,7 @@ do {<br>
                   DeclRefExpr *DR = cast<DeclRefExpr>(E);<br>
              <br>
                   // If we leave the immediate function, the lifetime
              isn't about to end.<br>
              -    if (DR->refersToEnclosingLocal())<br>
              +    if (DR->refersToCapturedVariable())<br>
                     return nullptr;<br>
              <br>
                   if (VarDecl *V =
              dyn_cast<VarDecl>(DR->getDecl())) {<br>
              <br>
              Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
              +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Dec 16 02:01:48
              2014<br>
              @@ -10181,7 +10181,7 @@ static void
              RebuildLambdaScopeInfo(CXXMe<br>
                     QualType CaptureType = VD->getType();<br>
                     const bool ByRef = C.getCaptureKind() == LCK_ByRef;<br>
                     LSI->addCapture(VD, /*IsBlock*/false, ByRef,<br>
              -          /*RefersToEnclosingLocal*/true,
              C.getLocation(),<br>
              +          /*RefersToCapturedVariable*/true,
              C.getLocation(),<br>
                         /*EllipsisLoc*/C.isPackExpansion()<br>
                                        ? C.getEllipsisLoc() :
              SourceLocation(),<br>
                         CaptureType, /*Expr*/ nullptr);<br>
              <br>
              Modified: cfe/trunk/lib/Sema/SemaExpr.cpp<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)<br>
              +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Dec 16 02:01:48
              2014<br>
              @@ -1601,7 +1601,7 @@ Sema::BuildDeclRefExpr(ValueDecl *D,
              Qua<br>
                       }<br>
                     }<br>
              <br>
              -  bool refersToEnclosingScope =<br>
              +  bool RefersToCapturedVariable =<br>
                     isa<VarDecl>(D) &&<br>
                     NeedToCaptureVariable(cast<VarDecl>(D),
              NameInfo.getLoc());<br>
              <br>
              @@ -1613,15 +1613,15 @@ Sema::BuildDeclRefExpr(ValueDecl
              *D, Qua<br>
                   E = DeclRefExpr::Create(<br>
                       Context,<br>
                       SS ? SS->getWithLocInContext(Context) :
              NestedNameSpecifierLoc(),<br>
              -        VarSpec->getTemplateKeywordLoc(), D,
              refersToEnclosingScope,<br>
              +        VarSpec->getTemplateKeywordLoc(), D,
              RefersToCapturedVariable,<br>
                       NameInfo.getLoc(), Ty, VK, FoundD, TemplateArgs);<br>
                 } else {<br>
                   assert(!TemplateArgs && "No template
              arguments for non-variable"<br>
                                           " template specialization
              references");<br>
              -    E = DeclRefExpr::Create(<br>
              -        Context,<br>
              -        SS ? SS->getWithLocInContext(Context) :
              NestedNameSpecifierLoc(),<br>
              -        SourceLocation(), D, refersToEnclosingScope,
              NameInfo, Ty, VK, FoundD);<br>
              +    E = DeclRefExpr::Create(Context, SS ?
              SS->getWithLocInContext(Context)<br>
              +                                        :
              NestedNameSpecifierLoc(),<br>
              +                            SourceLocation(), D,
              RefersToCapturedVariable,<br>
              +                            NameInfo, Ty, VK, FoundD);<br>
                 }<br>
              <br>
                 MarkDeclRefReferenced(E);<br>
              @@ -8586,7 +8586,7 @@ static NonConstCaptureKind
              isReferenceTo<br>
                 // Must be a reference to a declaration from an
              enclosing scope.<br>
                 DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E);<br>
                 if (!DRE) return NCCK_None;<br>
              -  if (!DRE->refersToEnclosingLocal()) return
              NCCK_None;<br>
              +  if (!DRE->refersToCapturedVariable()) return
              NCCK_None;<br>
              <br>
                 // The declaration must be a variable which is not
              declared 'const'.<br>
                 VarDecl *var =
              dyn_cast<VarDecl>(DRE->getDecl());<br>
              @@ -11965,7 +11965,7 @@ static bool
              captureInCapturedRegion(Capt<br>
                                                   const bool
              BuildAndDiagnose,<br>
                                                   QualType
              &CaptureType,<br>
                                                   QualType
              &DeclRefType,<br>
              -                                    const bool
              RefersToEnclosingLocal,<br>
              +                                    const bool
              RefersToCapturedVariable,<br>
                                                   Sema &S) {<br>
              <br>
                 // By default, capture variables by reference.<br>
              @@ -11987,7 +11987,7 @@ static bool
              captureInCapturedRegion(Capt<br>
                   Field->setAccess(AS_private);<br>
                   RD->addDecl(Field);<br>
              <br>
              -    CopyExpr = new (S.Context) DeclRefExpr(Var,
              RefersToEnclosingLocal,<br>
              +    CopyExpr = new (S.Context) DeclRefExpr(Var,
              RefersToCapturedVariable,<br>
                                                           DeclRefType,
              VK_LValue, Loc);<br>
                   Var->setReferenced(true);<br>
                   Var->markUsed(S.Context);<br>
              @@ -11995,7 +11995,7 @@ static bool
              captureInCapturedRegion(Capt<br>
              <br>
                 // Actually capture the variable.<br>
                 if (BuildAndDiagnose)<br>
              -    RSI->addCapture(Var, /*isBlock*/false, ByRef,
              RefersToEnclosingLocal, Loc,<br>
              +    RSI->addCapture(Var, /*isBlock*/false, ByRef,
              RefersToCapturedVariable, Loc,<br>
                                   SourceLocation(), CaptureType,
              CopyExpr);<br>
              <br>
              <br>
              @@ -12009,7 +12009,7 @@ static ExprResult
              addAsFieldToClosureTyp<br>
                                                 VarDecl *Var, QualType
              FieldType,<br>
                                                 QualType DeclRefType,<br>
                                                 SourceLocation Loc,<br>
              -                                  bool
              RefersToEnclosingLocal) {<br>
              +                                  bool
              RefersToCapturedVariable) {<br>
                 CXXRecordDecl *Lambda = LSI->Lambda;<br>
              <br>
                 // Build the non-static data member.<br>
              @@ -12038,7 +12038,7 @@ static ExprResult
              addAsFieldToClosureTyp<br>
                 // C++ [expr.prim.labda]p12:<br>
                 //   An entity captured by a lambda-expression is
              odr-used (3.2) in<br>
                 //   the scope containing the lambda-expression.<br>
              -  Expr *Ref = new (S.Context) DeclRefExpr(Var,
              RefersToEnclosingLocal,<br>
              +  Expr *Ref = new (S.Context) DeclRefExpr(Var,
              RefersToCapturedVariable,<br>
                                                         DeclRefType,
              VK_LValue, Loc);<br>
                 Var->setReferenced(true);<br>
                 Var->markUsed(S.Context);<br>
              @@ -12132,7 +12132,7 @@ static bool
              captureInLambda(LambdaScopeI<br>
                                           const bool BuildAndDiagnose,<br>
                                           QualType &CaptureType,<br>
                                           QualType &DeclRefType,<br>
              -                            const bool
              RefersToEnclosingLocal,<br>
              +                            const bool
              RefersToCapturedVariable,<br>
                                           const Sema::TryCaptureKind
              Kind,<br>
                                           SourceLocation EllipsisLoc,<br>
                                           const bool IsTopScope,<br>
              @@ -12206,7 +12206,7 @@ static bool
              captureInLambda(LambdaScopeI<br>
                 if (BuildAndDiagnose) {<br>
                   ExprResult Result = addAsFieldToClosureType(S, LSI,
              Var,<br>
                                                       CaptureType,
              DeclRefType, Loc,<br>
              -                                       
              RefersToEnclosingLocal);<br>
              +                                       
              RefersToCapturedVariable);<br>
                   if (!Result.isInvalid())<br>
                     CopyExpr = Result.get();<br>
                 }<br>
              @@ -12227,7 +12227,7 @@ static bool
              captureInLambda(LambdaScopeI<br>
              <br>
                 // Add the capture.<br>
                 if (BuildAndDiagnose)<br>
              -    LSI->addCapture(Var, /*IsBlock=*/false, ByRef,
              RefersToEnclosingLocal,<br>
              +    LSI->addCapture(Var, /*IsBlock=*/false, ByRef,
              RefersToCapturedVariable,<br>
                                   Loc, EllipsisLoc, CaptureType,
              CopyExpr);<br>
              <br>
                 return true;<br>
              <br>
              Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)<br>
              +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Dec 16 02:01:48
              2014<br>
              @@ -4166,11 +4166,12 @@ OMPClause
              *Sema::ActOnOpenMPPrivateClaus<br>
                   if (VDPrivate->isInvalidDecl())<br>
                     continue;<br>
                   CurContext->addDecl(VDPrivate);<br>
              -    auto VDPrivateRefExpr = DeclRefExpr::Create(<br>
              -        Context, /*QualifierLoc*/
              NestedNameSpecifierLoc(),<br>
              -        /*TemplateKWLoc*/ SourceLocation(), VDPrivate,<br>
              -        /*isEnclosingLocal*/ false, /*NameLoc*/
              SourceLocation(), DE->getType(),<br>
              -        /*VK*/ VK_LValue);<br>
              +    auto VDPrivateRefExpr =<br>
              +        DeclRefExpr::Create(Context, /*QualifierLoc*/
              NestedNameSpecifierLoc(),<br>
              +                            /*TemplateKWLoc*/
              SourceLocation(), VDPrivate,<br>
              +                            /*RefersToCapturedVariable*/
              false,<br>
              +                            /*NameLoc*/ SourceLocation(),
              DE->getType(),<br>
              +                            /*VK*/ VK_LValue);<br>
              <br>
                   DSAStack->addDSA(VD, DE, OMPC_private);<br>
                   Vars.push_back(DE);<br>
              @@ -4391,7 +4392,7 @@ OMPClause
              *Sema::ActOnOpenMPFirstprivate<br>
                     VDInitRefExpr = DeclRefExpr::Create(<br>
                         Context, /*QualifierLoc*/
              NestedNameSpecifierLoc(),<br>
                         /*TemplateKWLoc*/ SourceLocation(), VDInit,<br>
              -          /*isEnclosingLocal*/ true, ELoc, Type,<br>
              +          /*RefersToCapturedVariable*/ true, ELoc, Type,<br>
                         /*VK*/ VK_LValue);<br>
                     VDInit->setIsUsed();<br>
                     auto Init =
              DefaultLvalueConversion(VDInitRefExpr).get();<br>
              @@ -4409,7 +4410,7 @@ OMPClause
              *Sema::ActOnOpenMPFirstprivate<br>
                         VDPrivate, DefaultLvalueConversion(<br>
                                        DeclRefExpr::Create(Context,
              NestedNameSpecifierLoc(),<br>
                                                           
              SourceLocation(), DE->getDecl(),<br>
              -                                           
               /*isEnclosingLocal=*/true,<br>
              +                                           
               /*RefersToCapturedVariable=*/true,<br>
                                                           
              DE->getExprLoc(), DE->getType(),<br>
                                                           
              /*VK=*/VK_LValue)).get(),<br>
                         /*DirectInit=*/false,
              /*TypeMayContainAuto=*/false);<br>
              @@ -4425,7 +4426,7 @@ OMPClause
              *Sema::ActOnOpenMPFirstprivate<br>
                   auto VDPrivateRefExpr = DeclRefExpr::Create(<br>
                       Context, /*QualifierLoc*/
              NestedNameSpecifierLoc(),<br>
                       /*TemplateKWLoc*/ SourceLocation(), VDPrivate,<br>
              -        /*isEnclosingLocal*/ false, DE->getLocStart(),
              DE->getType(),<br>
              +        /*RefersToCapturedVariable*/ false,
              DE->getLocStart(), DE->getType(),<br>
                       /*VK*/ VK_LValue);<br>
                   DSAStack->addDSA(VD, DE, OMPC_firstprivate);<br>
                   Vars.push_back(DE);<br>
              <br>
              Modified: cfe/trunk/lib/Sema/SemaStmt.cpp<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)<br>
              +++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Dec 16 02:01:48
              2014<br>
              @@ -2484,7 +2484,7 @@ VarDecl
              *Sema::getCopyElisionCandidate(Q<br>
                 // - in a return statement in a function [where] ...<br>
                 // ... the expression is the name of a non-volatile
              automatic object ...<br>
                 DeclRefExpr *DR =
              dyn_cast<DeclRefExpr>(E->IgnoreParens());<br>
              -  if (!DR || DR->refersToEnclosingLocal())<br>
              +  if (!DR || DR->refersToCapturedVariable())<br>
                   return nullptr;<br>
                 VarDecl *VD =
              dyn_cast<VarDecl>(DR->getDecl());<br>
                 if (!VD)<br>
              <br>
              Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
              (original)<br>
              +++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Tue Dec
              16 02:01:48 2014<br>
              @@ -433,7 +433,7 @@ void
              ASTStmtReader::VisitDeclRefExpr(Dec<br>
                 E->DeclRefExprBits.HasFoundDecl = Record[Idx++];<br>
                 E->DeclRefExprBits.HasTemplateKWAndArgsInfo =
              Record[Idx++];<br>
                 E->DeclRefExprBits.HadMultipleCandidates =
              Record[Idx++];<br>
              -  E->DeclRefExprBits.RefersToEnclosingLocal =
              Record[Idx++];<br>
              +  E->DeclRefExprBits.RefersToCapturedVariable =
              Record[Idx++];<br>
                 unsigned NumTemplateArgs = 0;<br>
                 if (E->hasTemplateKWAndArgsInfo())<br>
                   NumTemplateArgs = Record[Idx++];<br>
              <br>
              Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
              (original)<br>
              +++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Tue Dec
              16 02:01:48 2014<br>
              @@ -1842,7 +1842,8 @@ void ASTWriter::WriteDeclAbbrevs() {<br>
                 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
              1)); //GetDeclFound<br>
                 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
              1)); //ExplicitTemplateArgs<br>
                 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
              1)); //HadMultipleCandidates<br>
              -  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
              1)); //RefersToEnclosingLocal<br>
              +  Abv->Add(<br>
              +      BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //
              RefersToCapturedVariable<br>
                 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
              // DeclRef<br>
                 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
              // Location<br>
                 DeclRefExprAbbrev = Stream.EmitAbbrev(Abv);<br>
              <br>
              Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp<br>
              URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=224329&r1=224328&r2=224329&view=diff"
                target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=224329&r1=224328&r2=224329&view=diff</a><br>
==============================================================================<br>
              --- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
              (original)<br>
              +++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Tue Dec
              16 02:01:48 2014<br>
              @@ -344,7 +344,7 @@ void
              ASTStmtWriter::VisitDeclRefExpr(Dec<br>
                 Record.push_back(E->getDecl() !=
              E->getFoundDecl());<br>
                 Record.push_back(E->hasTemplateKWAndArgsInfo());<br>
                 Record.push_back(E->hadMultipleCandidates());<br>
              -  Record.push_back(E->refersToEnclosingLocal());<br>
              +  Record.push_back(E->refersToCapturedVariable());<br>
              <br>
                 if (E->hasTemplateKWAndArgsInfo()) {<br>
                   unsigned NumTemplateArgs =
              E->getNumTemplateArgs();<br>
              <br>
              <br>
              _______________________________________________<br>
              cfe-commits mailing list<br>
              <a moz-do-not-send="true"
                href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
              <a moz-do-not-send="true"
                href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits"
                target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>