[cfe-commits] r152491 - in /cfe/trunk: include/clang/AST/ include/clang/Basic/ include/clang/Sema/ include/clang/Serialization/ lib/ARCMigrate/ lib/AST/ lib/Analysis/ lib/CodeGen/ lib/Rewrite/ lib/Sema/ lib/Serialization/ lib/StaticAnalyzer/Checkers/ lib/StaticAnalyzer/Core/ tools/libclang/
Douglas Gregor
dgregor at apple.com
Mon Mar 12 13:11:11 PDT 2012
On Mar 10, 2012, at 1:33 AM, John McCall wrote:
> Author: rjmccall
> Date: Sat Mar 10 03:33:50 2012
> New Revision: 152491
>
> URL: http://llvm.org/viewvc/llvm-project?rev=152491&view=rev
> Log:
> Remove BlockDeclRefExpr and introduce a bit on DeclRefExpr to
> track whether the referenced declaration comes from an enclosing
> local context. I'm amenable to suggestions about the exact meaning
> of this bit.
FYI, this caused the regression reported in:
http://llvm.org/bugs/show_bug.cgi?id=12248
I haven't had a chance to look into it yet.
- Doug
> Modified:
> cfe/trunk/include/clang/AST/Expr.h
> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> cfe/trunk/include/clang/AST/Stmt.h
> cfe/trunk/include/clang/Basic/StmtNodes.td
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/lib/ARCMigrate/TransAutoreleasePool.cpp
> cfe/trunk/lib/ARCMigrate/TransBlockObjCVariable.cpp
> cfe/trunk/lib/ARCMigrate/Transforms.cpp
> cfe/trunk/lib/AST/ASTImporter.cpp
> cfe/trunk/lib/AST/DeclTemplate.cpp
> cfe/trunk/lib/AST/Expr.cpp
> cfe/trunk/lib/AST/ExprClassification.cpp
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/AST/ItaniumMangle.cpp
> cfe/trunk/lib/AST/StmtPrinter.cpp
> cfe/trunk/lib/AST/StmtProfile.cpp
> cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
> cfe/trunk/lib/Analysis/PseudoConstantAnalysis.cpp
> cfe/trunk/lib/Analysis/ThreadSafety.cpp
> cfe/trunk/lib/CodeGen/CGBlocks.cpp
> cfe/trunk/lib/CodeGen/CGDecl.cpp
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CGExprAgg.cpp
> cfe/trunk/lib/CodeGen/CGExprComplex.cpp
> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> cfe/trunk/lib/CodeGen/CGObjC.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
> cfe/trunk/lib/Rewrite/RewriteObjC.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
> cfe/trunk/lib/Sema/SemaInit.cpp
> cfe/trunk/lib/Sema/SemaObjCProperty.cpp
> cfe/trunk/lib/Sema/SemaOverload.cpp
> cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
> cfe/trunk/lib/Sema/TreeTransform.h
> cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
> cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
> cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
> cfe/trunk/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
> cfe/trunk/tools/libclang/CIndex.cpp
> cfe/trunk/tools/libclang/CXCursor.cpp
>
> Modified: cfe/trunk/include/clang/AST/Expr.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/Expr.h (original)
> +++ cfe/trunk/include/clang/AST/Expr.h Sat Mar 10 03:33:50 2012
> @@ -766,6 +766,9 @@
> /// DeclRefExprBits.HasTemplateKWAndArgsInfo:
> /// Specifies when this declaration reference expression has an explicit
> /// C++ template keyword and/or template argument list.
> +/// DeclRefExprBits.RefersToEnclosingLocal
> +/// Specifies when this declaration reference expression (validly)
> +/// refers to a local variable from a different function.
> class DeclRefExpr : public Expr {
> /// \brief The declaration that we are referencing.
> ValueDecl *D;
> @@ -810,7 +813,8 @@
> DeclRefExpr(ASTContext &Ctx,
> NestedNameSpecifierLoc QualifierLoc,
> SourceLocation TemplateKWLoc,
> - ValueDecl *D, const DeclarationNameInfo &NameInfo,
> + ValueDecl *D, bool refersToEnclosingLocal,
> + const DeclarationNameInfo &NameInfo,
> NamedDecl *FoundD,
> const TemplateArgumentListInfo *TemplateArgs,
> QualType T, ExprValueKind VK);
> @@ -824,7 +828,8 @@
> void computeDependence(ASTContext &C);
>
> public:
> - DeclRefExpr(ValueDecl *D, QualType T, ExprValueKind VK, SourceLocation L,
> + DeclRefExpr(ValueDecl *D, bool refersToEnclosingLocal, QualType T,
> + ExprValueKind VK, SourceLocation L,
> const DeclarationNameLoc &LocInfo = DeclarationNameLoc())
> : Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false, false),
> D(D), Loc(L), DNLoc(LocInfo) {
> @@ -832,6 +837,7 @@
> DeclRefExprBits.HasTemplateKWAndArgsInfo = 0;
> DeclRefExprBits.HasFoundDecl = 0;
> DeclRefExprBits.HadMultipleCandidates = 0;
> + DeclRefExprBits.RefersToEnclosingLocal = refersToEnclosingLocal;
> computeDependence(D->getASTContext());
> }
>
> @@ -839,6 +845,7 @@
> NestedNameSpecifierLoc QualifierLoc,
> SourceLocation TemplateKWLoc,
> ValueDecl *D,
> + bool isEnclosingLocal,
> SourceLocation NameLoc,
> QualType T, ExprValueKind VK,
> NamedDecl *FoundD = 0,
> @@ -848,6 +855,7 @@
> NestedNameSpecifierLoc QualifierLoc,
> SourceLocation TemplateKWLoc,
> ValueDecl *D,
> + bool isEnclosingLocal,
> const DeclarationNameInfo &NameInfo,
> QualType T, ExprValueKind VK,
> NamedDecl *FoundD = 0,
> @@ -1023,6 +1031,12 @@
> DeclRefExprBits.HadMultipleCandidates = V;
> }
>
> + /// Does this DeclRefExpr refer to a local declaration from an
> + /// enclosing function scope?
> + bool refersToEnclosingLocal() const {
> + return DeclRefExprBits.RefersToEnclosingLocal;
> + }
> +
> static bool classof(const Stmt *T) {
> return T->getStmtClass() == DeclRefExprClass;
> }
> @@ -4275,46 +4289,6 @@
> child_range children() { return child_range(); }
> };
>
> -/// BlockDeclRefExpr - A reference to a local variable declared in an
> -/// enclosing scope.
> -class BlockDeclRefExpr : public Expr {
> - VarDecl *D;
> - SourceLocation Loc;
> - bool IsByRef : 1;
> - bool ConstQualAdded : 1;
> -public:
> - BlockDeclRefExpr(VarDecl *d, QualType t, ExprValueKind VK,
> - SourceLocation l, bool ByRef, bool constAdded = false);
> -
> - // \brief Build an empty reference to a declared variable in a
> - // block.
> - explicit BlockDeclRefExpr(EmptyShell Empty)
> - : Expr(BlockDeclRefExprClass, Empty) { }
> -
> - VarDecl *getDecl() { return D; }
> - const VarDecl *getDecl() const { return D; }
> - void setDecl(VarDecl *VD) { D = VD; }
> -
> - SourceLocation getLocation() const { return Loc; }
> - void setLocation(SourceLocation L) { Loc = L; }
> -
> - SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); }
> -
> - bool isByRef() const { return IsByRef; }
> - void setByRef(bool BR) { IsByRef = BR; }
> -
> - bool isConstQualAdded() const { return ConstQualAdded; }
> - void setConstQualAdded(bool C) { ConstQualAdded = C; }
> -
> - static bool classof(const Stmt *T) {
> - return T->getStmtClass() == BlockDeclRefExprClass;
> - }
> - static bool classof(const BlockDeclRefExpr *) { return true; }
> -
> - // Iterators
> - child_range children() { return child_range(); }
> -};
> -
> /// AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2]
> /// This AST node provides support for reinterpreting a type to another
> /// type of the same size.
>
> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
> +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Sat Mar 10 03:33:50 2012
> @@ -2015,7 +2015,6 @@
> // over the children.
> DEF_TRAVERSE_STMT(AddrLabelExpr, { })
> DEF_TRAVERSE_STMT(ArraySubscriptExpr, { })
> -DEF_TRAVERSE_STMT(BlockDeclRefExpr, { })
> DEF_TRAVERSE_STMT(BlockExpr, {
> TRY_TO(TraverseDecl(S->getBlockDecl()));
> return true; // no child statements to loop through.
>
> Modified: cfe/trunk/include/clang/AST/Stmt.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/Stmt.h (original)
> +++ cfe/trunk/include/clang/AST/Stmt.h Sat Mar 10 03:33:50 2012
> @@ -194,6 +194,7 @@
> unsigned HasTemplateKWAndArgsInfo : 1;
> unsigned HasFoundDecl : 1;
> unsigned HadMultipleCandidates : 1;
> + unsigned RefersToEnclosingLocal : 1;
> };
>
> class CastExprBitfields {
>
> Modified: cfe/trunk/include/clang/Basic/StmtNodes.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/StmtNodes.td?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/StmtNodes.td (original)
> +++ cfe/trunk/include/clang/Basic/StmtNodes.td Sat Mar 10 03:33:50 2012
> @@ -156,7 +156,6 @@
> // Clang Extensions.
> def ShuffleVectorExpr : DStmt<Expr>;
> def BlockExpr : DStmt<Expr>;
> -def BlockDeclRefExpr : DStmt<Expr>;
> def OpaqueValueExpr : DStmt<Expr>;
>
> // Microsoft Extensions.
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Sat Mar 10 03:33:50 2012
> @@ -2419,7 +2419,6 @@
> void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D);
> void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func);
> void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var);
> - void MarkBlockDeclRefReferenced(BlockDeclRefExpr *E);
> void MarkDeclRefReferenced(DeclRefExpr *E);
> void MarkMemberReferenced(MemberExpr *E);
>
>
> Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Sat Mar 10 03:33:50 2012
> @@ -1052,8 +1052,6 @@
> EXPR_SHUFFLE_VECTOR,
> /// \brief BlockExpr
> EXPR_BLOCK,
> - /// \brief A BlockDeclRef record.
> - EXPR_BLOCK_DECL_REF,
> /// \brief A GenericSelectionExpr record.
> EXPR_GENERIC_SELECTION,
> /// \brief A PseudoObjectExpr record.
>
> Modified: cfe/trunk/lib/ARCMigrate/TransAutoreleasePool.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransAutoreleasePool.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/ARCMigrate/TransAutoreleasePool.cpp (original)
> +++ cfe/trunk/lib/ARCMigrate/TransAutoreleasePool.cpp Sat Mar 10 03:33:50 2012
> @@ -263,10 +263,6 @@
> return checkRef(E->getLocation(), E->getDecl()->getLocation());
> }
>
> - bool VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
> - return checkRef(E->getLocation(), E->getDecl()->getLocation());
> - }
> -
> bool VisitTypedefTypeLoc(TypedefTypeLoc TL) {
> return checkRef(TL.getBeginLoc(), TL.getTypedefNameDecl()->getLocation());
> }
>
> Modified: cfe/trunk/lib/ARCMigrate/TransBlockObjCVariable.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransBlockObjCVariable.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/ARCMigrate/TransBlockObjCVariable.cpp (original)
> +++ cfe/trunk/lib/ARCMigrate/TransBlockObjCVariable.cpp Sat Mar 10 03:33:50 2012
> @@ -48,8 +48,8 @@
> BlockVarChecker(VarDecl *var) : Var(var) { }
>
> bool TraverseImplicitCastExpr(ImplicitCastExpr *castE) {
> - if (BlockDeclRefExpr *
> - ref = dyn_cast<BlockDeclRefExpr>(castE->getSubExpr())) {
> + if (DeclRefExpr *
> + ref = dyn_cast<DeclRefExpr>(castE->getSubExpr())) {
> if (ref->getDecl() == Var) {
> if (castE->getCastKind() == CK_LValueToRValue)
> return true; // Using the value of the variable.
> @@ -62,7 +62,7 @@
> return base::TraverseImplicitCastExpr(castE);
> }
>
> - bool VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
> + bool VisitDeclRefExpr(DeclRefExpr *E) {
> if (E->getDecl() == Var)
> return false; // The reference of the variable, and not just its value,
> // is needed.
>
> Modified: cfe/trunk/lib/ARCMigrate/Transforms.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/Transforms.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/ARCMigrate/Transforms.cpp (original)
> +++ cfe/trunk/lib/ARCMigrate/Transforms.cpp Sat Mar 10 03:33:50 2012
> @@ -194,7 +194,6 @@
> public:
> ReferenceClear(ExprSet &refs) : Refs(refs) { }
> bool VisitDeclRefExpr(DeclRefExpr *E) { Refs.erase(E); return true; }
> - bool VisitBlockDeclRefExpr(BlockDeclRefExpr *E) { Refs.erase(E); return true; }
> };
>
> class ReferenceCollector : public RecursiveASTVisitor<ReferenceCollector> {
> @@ -210,12 +209,6 @@
> Refs.insert(E);
> return true;
> }
> -
> - bool VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
> - if (E->getDecl() == Dcl)
> - Refs.insert(E);
> - return true;
> - }
> };
>
> class RemovablesCollector : public RecursiveASTVisitor<RemovablesCollector> {
>
> Modified: cfe/trunk/lib/AST/ASTImporter.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/ASTImporter.cpp (original)
> +++ cfe/trunk/lib/AST/ASTImporter.cpp Sat Mar 10 03:33:50 2012
> @@ -3947,6 +3947,7 @@
> Importer.Import(E->getQualifierLoc()),
> Importer.Import(E->getTemplateKeywordLoc()),
> ToD,
> + E->refersToEnclosingLocal(),
> Importer.Import(E->getLocation()),
> T, E->getValueKind(),
> FoundD,
>
> Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
> +++ cfe/trunk/lib/AST/DeclTemplate.cpp Sat Mar 10 03:33:50 2012
> @@ -173,7 +173,7 @@
> Arg = TemplateArgument(ArgType);
> } else if (NonTypeTemplateParmDecl *NTTP =
> dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
> - Expr *E = new (Context) DeclRefExpr(NTTP,
> + Expr *E = new (Context) DeclRefExpr(NTTP, /*enclosing*/ false,
> NTTP->getType().getNonLValueExprType(Context),
> Expr::getValueKindForType(NTTP->getType()),
> NTTP->getLocation());
>
> Modified: cfe/trunk/lib/AST/Expr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/Expr.cpp (original)
> +++ cfe/trunk/lib/AST/Expr.cpp Sat Mar 10 03:33:50 2012
> @@ -263,7 +263,8 @@
> DeclRefExpr::DeclRefExpr(ASTContext &Ctx,
> NestedNameSpecifierLoc QualifierLoc,
> SourceLocation TemplateKWLoc,
> - ValueDecl *D, const DeclarationNameInfo &NameInfo,
> + ValueDecl *D, bool RefersToEnclosingLocal,
> + const DeclarationNameInfo &NameInfo,
> NamedDecl *FoundD,
> const TemplateArgumentListInfo *TemplateArgs,
> QualType T, ExprValueKind VK)
> @@ -277,6 +278,7 @@
> getInternalFoundDecl() = FoundD;
> DeclRefExprBits.HasTemplateKWAndArgsInfo
> = (TemplateArgs || TemplateKWLoc.isValid()) ? 1 : 0;
> + DeclRefExprBits.RefersToEnclosingLocal = RefersToEnclosingLocal;
> if (TemplateArgs) {
> bool Dependent = false;
> bool InstantiationDependent = false;
> @@ -299,12 +301,14 @@
> NestedNameSpecifierLoc QualifierLoc,
> SourceLocation TemplateKWLoc,
> ValueDecl *D,
> + bool RefersToEnclosingLocal,
> SourceLocation NameLoc,
> QualType T,
> ExprValueKind VK,
> NamedDecl *FoundD,
> const TemplateArgumentListInfo *TemplateArgs) {
> return Create(Context, QualifierLoc, TemplateKWLoc, D,
> + RefersToEnclosingLocal,
> DeclarationNameInfo(D->getDeclName(), NameLoc),
> T, VK, FoundD, TemplateArgs);
> }
> @@ -313,6 +317,7 @@
> NestedNameSpecifierLoc QualifierLoc,
> SourceLocation TemplateKWLoc,
> ValueDecl *D,
> + bool RefersToEnclosingLocal,
> const DeclarationNameInfo &NameInfo,
> QualType T,
> ExprValueKind VK,
> @@ -334,6 +339,7 @@
>
> void *Mem = Context.Allocate(Size, llvm::alignOf<DeclRefExpr>());
> return new (Mem) DeclRefExpr(Context, QualifierLoc, TemplateKWLoc, D,
> + RefersToEnclosingLocal,
> NameInfo, FoundD, TemplateArgs, T, VK);
> }
>
> @@ -1867,14 +1873,8 @@
> ->isOBJCGCCandidate(Ctx);
> case CStyleCastExprClass:
> return cast<CStyleCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
> - case BlockDeclRefExprClass:
> case DeclRefExprClass: {
> -
> - const Decl *D;
> - if (const BlockDeclRefExpr *BDRE = dyn_cast<BlockDeclRefExpr>(E))
> - D = BDRE->getDecl();
> - else
> - D = cast<DeclRefExpr>(E)->getDecl();
> + const Decl *D = cast<DeclRefExpr>(E)->getDecl();
>
> if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
> if (VD->hasGlobalStorage())
> @@ -2194,7 +2194,6 @@
> case AsTypeExprClass:
> case BinaryConditionalOperatorClass:
> case BlockExprClass:
> - case BlockDeclRefExprClass:
> case CUDAKernelCallExprClass:
> case DeclRefExprClass:
> case ObjCBridgedCastExprClass:
> @@ -3664,24 +3663,6 @@
> reinterpret_cast<Stmt **>(getArgs() + getNumArgs()));
> }
>
> -// Blocks
> -BlockDeclRefExpr::BlockDeclRefExpr(VarDecl *d, QualType t, ExprValueKind VK,
> - SourceLocation l, bool ByRef,
> - bool constAdded)
> - : Expr(BlockDeclRefExprClass, t, VK, OK_Ordinary, false, false, false,
> - d->isParameterPack()),
> - D(d), Loc(l), IsByRef(ByRef), ConstQualAdded(constAdded)
> -{
> - bool TypeDependent = false;
> - bool ValueDependent = false;
> - bool InstantiationDependent = false;
> - computeDeclRefDependence(D->getASTContext(), D, getType(), TypeDependent,
> - ValueDependent, InstantiationDependent);
> - ExprBits.TypeDependent = TypeDependent;
> - ExprBits.ValueDependent = ValueDependent;
> - ExprBits.InstantiationDependent = InstantiationDependent;
> -}
> -
> ObjCArrayLiteral::ObjCArrayLiteral(llvm::ArrayRef<Expr *> Elements,
> QualType T, ObjCMethodDecl *Method,
> SourceRange SR)
>
> Modified: cfe/trunk/lib/AST/ExprClassification.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprClassification.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/ExprClassification.cpp (original)
> +++ cfe/trunk/lib/AST/ExprClassification.cpp Sat Mar 10 03:33:50 2012
> @@ -189,9 +189,6 @@
> return isa<FunctionDecl>(cast<DeclRefExpr>(E)->getDecl())
> ? Cl::CL_PRValue : Cl::CL_LValue;
> return ClassifyDecl(Ctx, cast<DeclRefExpr>(E)->getDecl());
> - // We deal with names referenced from blocks the same way.
> - case Expr::BlockDeclRefExprClass:
> - return ClassifyDecl(Ctx, cast<BlockDeclRefExpr>(E)->getDecl());
>
> // Member access is complex.
> case Expr::MemberExprClass:
> @@ -565,8 +562,11 @@
> // it is not marked __block, e.g.
> // void takeclosure(void (^C)(void));
> // void func() { int x = 1; takeclosure(^{ x = 7; }); }
> - if (const BlockDeclRefExpr *BDR = dyn_cast<BlockDeclRefExpr>(E)) {
> - if (!BDR->isByRef() && isa<VarDecl>(BDR->getDecl()))
> + if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
> + if (DRE->refersToEnclosingLocal() &&
> + isa<VarDecl>(DRE->getDecl()) &&
> + cast<VarDecl>(DRE->getDecl())->hasLocalStorage() &&
> + !DRE->getDecl()->hasAttr<BlocksAttr>())
> return Cl::CM_NotBlockQualified;
> }
>
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Sat Mar 10 03:33:50 2012
> @@ -2284,11 +2284,6 @@
> return true;
> return false;
> }
> - bool VisitBlockDeclRefExpr (const BlockDeclRefExpr *E) {
> - if (Ctx.getCanonicalType(E->getType()).isVolatileQualified())
> - return true;
> - return false;
> - }
>
> // We don't want to evaluate BlockExprs multiple times, as they generate
> // a ton of code.
> @@ -6278,7 +6273,6 @@
> case Expr::ObjCIsaExprClass:
> case Expr::ShuffleVectorExprClass:
> case Expr::BlockExprClass:
> - case Expr::BlockDeclRefExprClass:
> case Expr::NoStmtClass:
> case Expr::OpaqueValueExprClass:
> case Expr::PackExpansionExprClass:
>
> Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
> +++ cfe/trunk/lib/AST/ItaniumMangle.cpp Sat Mar 10 03:33:50 2012
> @@ -2351,7 +2351,6 @@
> // These all can only appear in local or variable-initialization
> // contexts and so should never appear in a mangling.
> case Expr::AddrLabelExprClass:
> - case Expr::BlockDeclRefExprClass:
> case Expr::CXXThisExprClass:
> case Expr::DesignatedInitExprClass:
> case Expr::ImplicitValueInitExprClass:
>
> Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
> +++ cfe/trunk/lib/AST/StmtPrinter.cpp Sat Mar 10 03:33:50 2012
> @@ -1816,10 +1816,6 @@
> }
> }
>
> -void StmtPrinter::VisitBlockDeclRefExpr(BlockDeclRefExpr *Node) {
> - OS << *Node->getDecl();
> -}
> -
> void StmtPrinter::VisitOpaqueValueExpr(OpaqueValueExpr *Node) {
> PrintExpr(Node->getSourceExpr());
> }
>
> Modified: cfe/trunk/lib/AST/StmtProfile.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/StmtProfile.cpp (original)
> +++ cfe/trunk/lib/AST/StmtProfile.cpp Sat Mar 10 03:33:50 2012
> @@ -460,13 +460,6 @@
> VisitDecl(S->getBlockDecl());
> }
>
> -void StmtProfiler::VisitBlockDeclRefExpr(const BlockDeclRefExpr *S) {
> - VisitExpr(S);
> - VisitDecl(S->getDecl());
> - ID.AddBoolean(S->isByRef());
> - ID.AddBoolean(S->isConstQualAdded());
> -}
> -
> void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
> VisitExpr(S);
> for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
>
> Modified: cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp (original)
> +++ cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp Sat Mar 10 03:33:50 2012
> @@ -362,20 +362,16 @@
> flag = 1;
> BEVals.push_back(VD, BC);
> }
> + } else if (DR->refersToEnclosingLocal()) {
> + unsigned &flag = Visited[VD];
> + if (!flag) {
> + flag = 1;
> + if (IsTrackedDecl(VD))
> + BEVals.push_back(VD, BC);
> + }
> }
> }
>
> - void VisitBlockDeclRefExpr(BlockDeclRefExpr *DR) {
> - if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) {
> - unsigned &flag = Visited[VD];
> - if (!flag) {
> - flag = 1;
> - if (IsTrackedDecl(VD))
> - BEVals.push_back(VD, BC);
> - }
> - }
> - }
> -
> void VisitBlockExpr(BlockExpr *BR) {
> // Blocks containing blocks can transitively capture more variables.
> IgnoredContexts.insert(BR->getBlockDecl());
>
> Modified: cfe/trunk/lib/Analysis/PseudoConstantAnalysis.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/PseudoConstantAnalysis.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Analysis/PseudoConstantAnalysis.cpp (original)
> +++ cfe/trunk/lib/Analysis/PseudoConstantAnalysis.cpp Sat Mar 10 03:33:50 2012
> @@ -68,8 +68,6 @@
> const Decl *PseudoConstantAnalysis::getDecl(const Expr *E) {
> if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(E))
> return DR->getDecl();
> - else if (const BlockDeclRefExpr *BDR = dyn_cast<BlockDeclRefExpr>(E))
> - return BDR->getDecl();
> else
> return 0;
> }
> @@ -198,18 +196,7 @@
> break;
> }
>
> - // Case 4: Block variable references
> - case Stmt::BlockDeclRefExprClass: {
> - const BlockDeclRefExpr *BDR = cast<BlockDeclRefExpr>(Head);
> - if (const VarDecl *VD = dyn_cast<VarDecl>(BDR->getDecl())) {
> - // Add the Decl to the used list
> - UsedVars->insert(VD);
> - continue;
> - }
> - break;
> - }
> -
> - // Case 5: Variable references
> + // Case 4: Variable references
> case Stmt::DeclRefExprClass: {
> const DeclRefExpr *DR = cast<DeclRefExpr>(Head);
> if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) {
> @@ -220,7 +207,7 @@
> break;
> }
>
> - // Case 6: Block expressions
> + // Case 5: Block expressions
> case Stmt::BlockExprClass: {
> const BlockExpr *B = cast<BlockExpr>(Head);
> // Add the body of the block to the list
>
> Modified: cfe/trunk/lib/Analysis/ThreadSafety.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafety.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Analysis/ThreadSafety.cpp (original)
> +++ cfe/trunk/lib/Analysis/ThreadSafety.cpp Sat Mar 10 03:33:50 2012
> @@ -1040,7 +1040,7 @@
> addLock(Mutex, LockData(ExpLocation, LK));
> if (isScopedVar) {
> // For scoped lockable vars, map this var to its underlying mutex.
> - DeclRefExpr DRE(VD, VD->getType(), VK_LValue, VD->getLocation());
> + DeclRefExpr DRE(VD, false, VD->getType(), VK_LValue, VD->getLocation());
> MutexID SMutex(&DRE, 0, 0);
> addLock(SMutex, LockData(VD->getLocation(), LK, Mutex));
> }
> @@ -1656,7 +1656,7 @@
>
> // Create a dummy expression,
> VarDecl *VD = const_cast<VarDecl*>(AD->getVarDecl());
> - DeclRefExpr DRE(VD, VD->getType(), VK_LValue,
> + DeclRefExpr DRE(VD, false, VD->getType(), VK_LValue,
> AD->getTriggerStmt()->getLocEnd());
> LocksetBuilder.handleCall(&DRE, DD);
> break;
>
> Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Sat Mar 10 03:33:50 2012
> @@ -753,16 +753,12 @@
>
> // We use one of these or the other depending on whether the
> // reference is nested.
> - DeclRefExpr notNested(const_cast<VarDecl*>(variable), type, VK_LValue,
> - SourceLocation());
> - BlockDeclRefExpr nested(const_cast<VarDecl*>(variable), type,
> - VK_LValue, SourceLocation(), /*byref*/ false);
> -
> - Expr *declRef =
> - (ci->isNested() ? static_cast<Expr*>(&nested) : ¬Nested);
> + DeclRefExpr declRef(const_cast<VarDecl*>(variable),
> + /*refersToEnclosing*/ ci->isNested(), type,
> + VK_LValue, SourceLocation());
>
> ImplicitCastExpr l2r(ImplicitCastExpr::OnStack, type, CK_LValueToRValue,
> - declRef, VK_RValue);
> + &declRef, VK_RValue);
> EmitExprAsInit(&l2r, &blockFieldPseudoVar,
> MakeAddrLValue(blockField, type,
> getContext().getDeclAlign(variable)),
> @@ -1107,7 +1103,7 @@
> LocalDeclMap[variable] = alloca;
> }
>
> - // Save a spot to insert the debug information for all the BlockDeclRefDecls.
> + // Save a spot to insert the debug information for all the DeclRefExprs.
> llvm::BasicBlock *entry = Builder.GetInsertBlock();
> llvm::BasicBlock::iterator entry_ptr = Builder.GetInsertPoint();
> --entry_ptr;
> @@ -1124,7 +1120,7 @@
> ++entry_ptr;
> Builder.SetInsertPoint(entry, entry_ptr);
>
> - // Emit debug information for all the BlockDeclRefDecls.
> + // Emit debug information for all the DeclRefExprs.
> // FIXME: also for 'this'
> if (CGDebugInfo *DI = getDebugInfo()) {
> for (BlockDecl::capture_const_iterator ci = blockDecl->capture_begin(),
>
> Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Sat Mar 10 03:33:50 2012
> @@ -394,8 +394,8 @@
> void Emit(CodeGenFunction &CGF, Flags flags) {
> // Compute the address of the local variable, in case it's a
> // byref or something.
> - DeclRefExpr DRE(const_cast<VarDecl*>(&Var), Var.getType(), VK_LValue,
> - SourceLocation());
> + DeclRefExpr DRE(const_cast<VarDecl*>(&Var), false,
> + Var.getType(), VK_LValue, SourceLocation());
> llvm::Value *value = CGF.EmitLoadOfScalar(CGF.EmitDeclRefLValue(&DRE));
> CGF.EmitExtendGCLifetime(value);
> }
> @@ -411,8 +411,8 @@
> : CleanupFn(CleanupFn), FnInfo(*Info), Var(*Var) {}
>
> void Emit(CodeGenFunction &CGF, Flags flags) {
> - DeclRefExpr DRE(const_cast<VarDecl*>(&Var), Var.getType(), VK_LValue,
> - SourceLocation());
> + DeclRefExpr DRE(const_cast<VarDecl*>(&Var), false,
> + Var.getType(), VK_LValue, SourceLocation());
> // Compute the address of the local variable, in case it's a byref
> // or something.
> llvm::Value *Addr = CGF.EmitDeclRefLValue(&DRE).getAddress();
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Sat Mar 10 03:33:50 2012
> @@ -679,9 +679,6 @@
> "Only single-element init list can be lvalue.");
> return EmitLValue(cast<InitListExpr>(E)->getInit(0));
>
> - case Expr::BlockDeclRefExprClass:
> - return EmitBlockDeclRefLValue(cast<BlockDeclRefExpr>(E));
> -
> case Expr::CXXTemporaryObjectExprClass:
> case Expr::CXXConstructExprClass:
> return EmitCXXConstructLValue(cast<CXXConstructExpr>(E));
> @@ -796,7 +793,9 @@
> /// in a block or lambda, which means const int variables or constexpr
> /// literals or similar.
> CodeGenFunction::ConstantEmission
> -CodeGenFunction::tryEmitAsConstant(ValueDecl *value, Expr *refExpr) {
> +CodeGenFunction::tryEmitAsConstant(DeclRefExpr *refExpr) {
> + ValueDecl *value = refExpr->getDecl();
> +
> // The value needs to be an enum constant or a constant variable.
> ConstantEmissionKind CEK;
> if (isa<ParmVarDecl>(value)) {
> @@ -810,25 +809,19 @@
> }
> if (CEK == CEK_None) return ConstantEmission();
>
> - // We evaluate use an on-stack DeclRefExpr because the constant
> - // evaluator (quite reasonably) ignores BlockDeclRefExprs.
> - DeclRefExpr stackRef(value, refExpr->getType(), refExpr->getValueKind(),
> - refExpr->getExprLoc());
> -
> - // If it's okay to evaluate as a
> Expr::EvalResult result;
> bool resultIsReference;
> QualType resultType;
>
> // It's best to evaluate all the way as an r-value if that's permitted.
> if (CEK != CEK_AsReferenceOnly &&
> - stackRef.EvaluateAsRValue(result, getContext())) {
> + refExpr->EvaluateAsRValue(result, getContext())) {
> resultIsReference = false;
> resultType = refExpr->getType();
>
> // Otherwise, try to evaluate as an l-value.
> } else if (CEK != CEK_AsValueOnly &&
> - stackRef.EvaluateAsLValue(result, getContext())) {
> + refExpr->EvaluateAsLValue(result, getContext())) {
> resultIsReference = true;
> resultType = value->getType();
>
> @@ -848,10 +841,10 @@
> // This should probably fire even for
> if (isa<VarDecl>(value)) {
> if (!getContext().DeclMustBeEmitted(cast<VarDecl>(value)))
> - EmitDeclRefExprDbgValue(&stackRef, C);
> + EmitDeclRefExprDbgValue(refExpr, C);
> } else {
> assert(isa<EnumConstantDecl>(value));
> - EmitDeclRefExprDbgValue(&stackRef, C);
> + EmitDeclRefExprDbgValue(refExpr, C);
> }
>
> // If we emitted a reference constant, we need to dereference that.
> @@ -1499,27 +1492,34 @@
> }
>
> if (const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
> -
> // Check if this is a global variable.
> if (VD->hasExternalStorage() || VD->isFileVarDecl())
> return EmitGlobalVarDeclLValue(*this, E, VD);
>
> + bool isBlockVariable = VD->hasAttr<BlocksAttr>();
> +
> bool NonGCable = VD->hasLocalStorage() &&
> !VD->getType()->isReferenceType() &&
> - !VD->hasAttr<BlocksAttr>();
> + !isBlockVariable;
>
> llvm::Value *V = LocalDeclMap[VD];
> if (!V && VD->isStaticLocal())
> V = CGM.getStaticLocalDeclAddress(VD);
>
> // Use special handling for lambdas.
> - if (!V)
> + if (!V) {
> if (FieldDecl *FD = LambdaCaptureFields.lookup(VD))
> return EmitLValueForField(CXXABIThisValue, FD, 0);
>
> + assert(isa<BlockDecl>(CurCodeDecl) && E->refersToEnclosingLocal());
> + CharUnits alignment = getContext().getDeclAlign(VD);
> + return MakeAddrLValue(GetAddrOfBlockDecl(VD, isBlockVariable),
> + E->getType(), alignment);
> + }
> +
> assert(V && "DeclRefExpr not entered in LocalDeclMap?");
>
> - if (VD->hasAttr<BlocksAttr>())
> + if (isBlockVariable)
> V = BuildBlockByrefAddress(V, VD);
>
> LValue LV;
> @@ -1546,11 +1546,6 @@
> llvm_unreachable("Unhandled DeclRefExpr");
> }
>
> -LValue CodeGenFunction::EmitBlockDeclRefLValue(const BlockDeclRefExpr *E) {
> - CharUnits Alignment = getContext().getDeclAlign(E->getDecl());
> - return MakeAddrLValue(GetAddrOfBlockDecl(E), E->getType(), Alignment);
> -}
> -
> LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) {
> // __extension__ doesn't affect lvalue-ness.
> if (E->getOpcode() == UO_Extension)
>
> Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Sat Mar 10 03:33:50 2012
> @@ -109,26 +109,22 @@
> }
>
> // l-values.
> - void emitDeclRef(ValueDecl *VD, Expr *refExpr) {
> + void VisitDeclRefExpr(DeclRefExpr *E) {
> // For aggregates, we should always be able to emit the variable
> // as an l-value unless it's a reference. This is due to the fact
> // that we can't actually ever see a normal l2r conversion on an
> // aggregate in C++, and in C there's no language standard
> // actively preventing us from listing variables in the captures
> // list of a block.
> - if (VD->getType()->isReferenceType()) {
> + if (E->getDecl()->getType()->isReferenceType()) {
> if (CodeGenFunction::ConstantEmission result
> - = CGF.tryEmitAsConstant(VD, refExpr)) {
> - EmitFinalDestCopy(refExpr, result.getReferenceLValue(CGF, refExpr));
> + = CGF.tryEmitAsConstant(E)) {
> + EmitFinalDestCopy(E, result.getReferenceLValue(CGF, E));
> return;
> }
> }
>
> - EmitAggLoadOfLValue(refExpr);
> - }
> - void VisitDeclRefExpr(DeclRefExpr *E) { emitDeclRef(E->getDecl(), E); }
> - void VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
> - emitDeclRef(E->getDecl(), E);
> + EmitAggLoadOfLValue(E);
> }
>
> void VisitMemberExpr(MemberExpr *ME) { EmitAggLoadOfLValue(ME); }
>
> Modified: cfe/trunk/lib/CodeGen/CGExprComplex.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExprComplex.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp Sat Mar 10 03:33:50 2012
> @@ -111,23 +111,16 @@
> }
>
> // l-values.
> - ComplexPairTy emitDeclRef(ValueDecl *VD, Expr *refExpr) {
> - if (CodeGenFunction::ConstantEmission result
> - = CGF.tryEmitAsConstant(VD, refExpr)) {
> + ComplexPairTy VisitDeclRefExpr(DeclRefExpr *E) {
> + if (CodeGenFunction::ConstantEmission result = CGF.tryEmitAsConstant(E)) {
> if (result.isReference())
> - return EmitLoadOfLValue(result.getReferenceLValue(CGF, refExpr));
> + return EmitLoadOfLValue(result.getReferenceLValue(CGF, E));
>
> llvm::ConstantStruct *pair =
> cast<llvm::ConstantStruct>(result.getValue());
> return ComplexPairTy(pair->getOperand(0), pair->getOperand(1));
> }
> - return EmitLoadOfLValue(refExpr);
> - }
> - ComplexPairTy VisitDeclRefExpr(DeclRefExpr *E) {
> - return emitDeclRef(E->getDecl(), E);
> - }
> - ComplexPairTy VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
> - return emitDeclRef(E->getDecl(), E);
> + return EmitLoadOfLValue(E);
> }
> ComplexPairTy VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
> return EmitLoadOfLValue(E);
>
> Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sat Mar 10 03:33:50 2012
> @@ -213,20 +213,13 @@
> }
>
> // l-values.
> - Value *emitDeclRef(ValueDecl *VD, Expr *refExpr) {
> - if (CodeGenFunction::ConstantEmission result
> - = CGF.tryEmitAsConstant(VD, refExpr)) {
> + Value *VisitDeclRefExpr(DeclRefExpr *E) {
> + if (CodeGenFunction::ConstantEmission result = CGF.tryEmitAsConstant(E)) {
> if (result.isReference())
> - return EmitLoadOfLValue(result.getReferenceLValue(CGF, refExpr));
> + return EmitLoadOfLValue(result.getReferenceLValue(CGF, E));
> return result.getValue();
> }
> - return EmitLoadOfLValue(refExpr);
> - }
> - Value *VisitDeclRefExpr(DeclRefExpr *E) {
> - return emitDeclRef(E->getDecl(), E);
> - }
> - Value *VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
> - return emitDeclRef(E->getDecl(), E);
> + return EmitLoadOfLValue(E);
> }
>
> Value *VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
>
> Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGObjC.cpp Sat Mar 10 03:33:50 2012
> @@ -931,7 +931,7 @@
>
> // The second argument is the address of the parameter variable.
> ParmVarDecl *argVar = *OMD->param_begin();
> - DeclRefExpr argRef(argVar, argVar->getType().getNonReferenceType(),
> + DeclRefExpr argRef(argVar, false, argVar->getType().getNonReferenceType(),
> VK_LValue, SourceLocation());
> llvm::Value *argAddr = CGF.EmitLValue(&argRef).getAddress();
> argAddr = CGF.Builder.CreateBitCast(argAddr, CGF.Int8PtrTy);
> @@ -976,7 +976,7 @@
>
> // The second argument is the address of the parameter variable.
> ParmVarDecl *argVar = *OMD->param_begin();
> - DeclRefExpr argRef(argVar, argVar->getType().getNonReferenceType(),
> + DeclRefExpr argRef(argVar, false, argVar->getType().getNonReferenceType(),
> VK_LValue, SourceLocation());
> llvm::Value *argAddr = CGF.EmitLValue(&argRef).getAddress();
> argAddr = CGF.Builder.CreateBitCast(argAddr, CGF.Int8PtrTy);
> @@ -1163,7 +1163,8 @@
>
> // Otherwise, fake up some ASTs and emit a normal assignment.
> ValueDecl *selfDecl = setterMethod->getSelfDecl();
> - DeclRefExpr self(selfDecl, selfDecl->getType(), VK_LValue, SourceLocation());
> + DeclRefExpr self(selfDecl, false, selfDecl->getType(),
> + VK_LValue, SourceLocation());
> ImplicitCastExpr selfLoad(ImplicitCastExpr::OnStack,
> selfDecl->getType(), CK_LValueToRValue, &self,
> VK_RValue);
> @@ -1172,7 +1173,7 @@
>
> ParmVarDecl *argDecl = *setterMethod->param_begin();
> QualType argType = argDecl->getType().getNonReferenceType();
> - DeclRefExpr arg(argDecl, argType, VK_LValue, SourceLocation());
> + DeclRefExpr arg(argDecl, false, argType, VK_LValue, SourceLocation());
> ImplicitCastExpr argLoad(ImplicitCastExpr::OnStack,
> argType.getUnqualifiedType(), CK_LValueToRValue,
> &arg, VK_RValue);
> @@ -1525,7 +1526,7 @@
> EmitAutoVarInit(variable);
>
> const VarDecl* D = cast<VarDecl>(SD->getSingleDecl());
> - DeclRefExpr tempDRE(const_cast<VarDecl*>(D), D->getType(),
> + DeclRefExpr tempDRE(const_cast<VarDecl*>(D), false, D->getType(),
> VK_LValue, SourceLocation());
> elementLValue = EmitLValue(&tempDRE);
> elementType = D->getType();
> @@ -2817,28 +2818,23 @@
>
> StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation());
>
> - DeclRefExpr *DstExpr =
> - new (C) DeclRefExpr(&dstDecl, DestTy,
> - VK_RValue, SourceLocation());
> -
> - Expr* DST = new (C) UnaryOperator(DstExpr, UO_Deref, DestTy->getPointeeType(),
> - VK_LValue, OK_Ordinary, SourceLocation());
> -
> - DeclRefExpr *SrcExpr =
> - new (C) DeclRefExpr(&srcDecl, SrcTy,
> - VK_RValue, SourceLocation());
> + DeclRefExpr DstExpr(&dstDecl, false, DestTy,
> + VK_RValue, SourceLocation());
> + UnaryOperator DST(&DstExpr, UO_Deref, DestTy->getPointeeType(),
> + VK_LValue, OK_Ordinary, SourceLocation());
>
> - Expr* SRC = new (C) UnaryOperator(SrcExpr, UO_Deref, SrcTy->getPointeeType(),
> - VK_LValue, OK_Ordinary, SourceLocation());
> + DeclRefExpr SrcExpr(&srcDecl, false, SrcTy,
> + VK_RValue, SourceLocation());
> + UnaryOperator SRC(&SrcExpr, UO_Deref, SrcTy->getPointeeType(),
> + VK_LValue, OK_Ordinary, SourceLocation());
>
> - Expr *Args[2] = { DST, SRC };
> + Expr *Args[2] = { &DST, &SRC };
> CallExpr *CalleeExp = cast<CallExpr>(PID->getSetterCXXAssignment());
> - CXXOperatorCallExpr *TheCall =
> - new (C) CXXOperatorCallExpr(C, OO_Equal, CalleeExp->getCallee(),
> - Args, 2, DestTy->getPointeeType(),
> - VK_LValue, SourceLocation());
> -
> - EmitStmt(TheCall);
> + CXXOperatorCallExpr TheCall(C, OO_Equal, CalleeExp->getCallee(),
> + Args, 2, DestTy->getPointeeType(),
> + VK_LValue, SourceLocation());
> +
> + EmitStmt(&TheCall);
>
> FinishFunction();
> HelperFn = llvm::ConstantExpr::getBitCast(Fn, VoidPtrTy);
> @@ -2907,18 +2903,17 @@
>
> StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation());
>
> - DeclRefExpr *SrcExpr =
> - new (C) DeclRefExpr(&srcDecl, SrcTy,
> + DeclRefExpr SrcExpr(&srcDecl, false, SrcTy,
> VK_RValue, SourceLocation());
>
> - Expr* SRC = new (C) UnaryOperator(SrcExpr, UO_Deref, SrcTy->getPointeeType(),
> - VK_LValue, OK_Ordinary, SourceLocation());
> + UnaryOperator SRC(&SrcExpr, UO_Deref, SrcTy->getPointeeType(),
> + VK_LValue, OK_Ordinary, SourceLocation());
>
> CXXConstructExpr *CXXConstExpr =
> cast<CXXConstructExpr>(PID->getGetterCXXConstructor());
>
> SmallVector<Expr*, 4> ConstructorArgs;
> - ConstructorArgs.push_back(SRC);
> + ConstructorArgs.push_back(&SRC);
> CXXConstructExpr::arg_iterator A = CXXConstExpr->arg_begin();
> ++A;
>
> @@ -2936,11 +2931,10 @@
> CXXConstExpr->requiresZeroInitialization(),
> CXXConstExpr->getConstructionKind(), SourceRange());
>
> - DeclRefExpr *DstExpr =
> - new (C) DeclRefExpr(&dstDecl, DestTy,
> - VK_RValue, SourceLocation());
> + DeclRefExpr DstExpr(&dstDecl, false, DestTy,
> + VK_RValue, SourceLocation());
>
> - RValue DV = EmitAnyExpr(DstExpr);
> + RValue DV = EmitAnyExpr(&DstExpr);
> CharUnits Alignment = getContext().getTypeAlignInChars(TheCXXConstructExpr->getType());
> EmitAggExpr(TheCXXConstructExpr,
> AggValueSlot::forAddr(DV.getScalarVal(), Alignment, Qualifiers(),
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Sat Mar 10 03:33:50 2012
> @@ -1359,10 +1359,7 @@
> }
>
> void AllocateBlockCXXThisPointer(const CXXThisExpr *E);
> - void AllocateBlockDecl(const BlockDeclRefExpr *E);
> - llvm::Value *GetAddrOfBlockDecl(const BlockDeclRefExpr *E) {
> - return GetAddrOfBlockDecl(E->getDecl(), E->isByRef());
> - }
> + void AllocateBlockDecl(const DeclRefExpr *E);
> llvm::Value *GetAddrOfBlockDecl(const VarDecl *var, bool ByRef);
> llvm::Type *BuildByRefType(const VarDecl *var);
>
> @@ -2135,7 +2132,7 @@
> }
> };
>
> - ConstantEmission tryEmitAsConstant(ValueDecl *VD, Expr *refExpr);
> + ConstantEmission tryEmitAsConstant(DeclRefExpr *refExpr);
>
> RValue EmitPseudoObjectRValue(const PseudoObjectExpr *e,
> AggValueSlot slot = AggValueSlot::ignored());
> @@ -2163,8 +2160,6 @@
> LValue EmitLValueForBitfield(llvm::Value* Base, const FieldDecl* Field,
> unsigned CVRQualifiers);
>
> - LValue EmitBlockDeclRefLValue(const BlockDeclRefExpr *E);
> -
> LValue EmitCXXConstructLValue(const CXXConstructExpr *E);
> LValue EmitCXXBindTemporaryLValue(const CXXBindTemporaryExpr *E);
> LValue EmitLambdaLValue(const LambdaExpr *E);
>
> Modified: cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp (original)
> +++ cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp Sat Mar 10 03:33:50 2012
> @@ -120,9 +120,9 @@
> // Block expressions.
> SmallVector<BlockExpr *, 32> Blocks;
> SmallVector<int, 32> InnerDeclRefsCount;
> - SmallVector<BlockDeclRefExpr *, 32> InnerDeclRefs;
> + SmallVector<DeclRefExpr *, 32> InnerDeclRefs;
>
> - SmallVector<BlockDeclRefExpr *, 32> BlockDeclRefs;
> + SmallVector<DeclRefExpr *, 32> BlockDeclRefs;
>
> // Block related declarations.
> SmallVector<ValueDecl *, 8> BlockByCopyDecls;
> @@ -327,7 +327,7 @@
> // Block specific rewrite rules.
> void RewriteBlockPointerDecl(NamedDecl *VD);
> void RewriteByRefVar(VarDecl *VD);
> - Stmt *RewriteBlockDeclRefExpr(Expr *VD);
> + Stmt *RewriteBlockDeclRefExpr(DeclRefExpr *VD);
> Stmt *RewriteLocalVariableExternalStorage(DeclRefExpr *DRE);
> void RewriteBlockPointerFunctionArgs(FunctionDecl *FD);
>
> @@ -407,7 +407,7 @@
> StringRef FunName);
> FunctionDecl *SynthBlockInitFunctionDecl(StringRef name);
> Stmt *SynthBlockInitExpr(BlockExpr *Exp,
> - const SmallVector<BlockDeclRefExpr *, 8> &InnerBlockDeclRefs);
> + const SmallVector<DeclRefExpr *, 8> &InnerBlockDeclRefs);
>
> // Misc. helper routines.
> QualType getProtocolType();
> @@ -421,7 +421,7 @@
> void CollectBlockDeclRefInfo(BlockExpr *Exp);
> void GetBlockDeclRefExprs(Stmt *S);
> void GetInnerBlockDeclRefExprs(Stmt *S,
> - SmallVector<BlockDeclRefExpr *, 8> &InnerBlockDeclRefs,
> + SmallVector<DeclRefExpr *, 8> &InnerBlockDeclRefs,
> llvm::SmallPtrSet<const DeclContext *, 8> &InnerContexts);
>
> // We avoid calling Type::isBlockPointerType(), since it operates on the
> @@ -2062,7 +2062,7 @@
>
> // Create a reference to the objc_msgSend() declaration.
> DeclRefExpr *DRE =
> - new (Context) DeclRefExpr(FD, msgSendType, VK_LValue, SourceLocation());
> + new (Context) DeclRefExpr(FD, false, msgSendType, VK_LValue, SourceLocation());
>
> // Now, we cast the reference to a pointer to the objc_msgSend type.
> QualType pToFunc = Context->getPointerType(msgSendType);
> @@ -2575,7 +2575,7 @@
> VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
> SourceLocation(), &Context->Idents.get(S),
> strType, 0, SC_Static, SC_None);
> - DeclRefExpr *DRE = new (Context) DeclRefExpr(NewVD, strType, VK_LValue,
> + DeclRefExpr *DRE = new (Context) DeclRefExpr(NewVD, false, strType, VK_LValue,
> SourceLocation());
> Expr *Unop = new (Context) UnaryOperator(DRE, UO_AddrOf,
> Context->getPointerType(DRE->getType()),
> @@ -2703,6 +2703,7 @@
> NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
> CK_BitCast,
> new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
> + false,
> Context->getObjCIdType(),
> VK_RValue,
> SourceLocation()))
> @@ -2744,7 +2745,7 @@
> SynthSuperContructorFunctionDecl();
> // Simulate a contructor call...
> DeclRefExpr *DRE = new (Context) DeclRefExpr(SuperContructorFunctionDecl,
> - superType, VK_LValue,
> + false, superType, VK_LValue,
> SourceLocation());
> SuperRep = new (Context) CallExpr(*Context, DRE, &InitExprs[0],
> InitExprs.size(),
> @@ -2814,6 +2815,7 @@
> NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
> CK_BitCast,
> new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
> + false,
> Context->getObjCIdType(),
> VK_RValue, SourceLocation()))
> ); // set the 'receiver'.
> @@ -2853,7 +2855,7 @@
> SynthSuperContructorFunctionDecl();
> // Simulate a contructor call...
> DeclRefExpr *DRE = new (Context) DeclRefExpr(SuperContructorFunctionDecl,
> - superType, VK_LValue,
> + false, superType, VK_LValue,
> SourceLocation());
> SuperRep = new (Context) CallExpr(*Context, DRE, &InitExprs[0],
> InitExprs.size(),
> @@ -3005,7 +3007,7 @@
> QualType msgSendType = MsgSendFlavor->getType();
>
> // Create a reference to the objc_msgSend() declaration.
> - DeclRefExpr *DRE = new (Context) DeclRefExpr(MsgSendFlavor, msgSendType,
> + DeclRefExpr *DRE = new (Context) DeclRefExpr(MsgSendFlavor, false, msgSendType,
> VK_LValue, SourceLocation());
>
> // Need to cast objc_msgSend to "void *" (to workaround a GCC bandaid).
> @@ -3041,7 +3043,8 @@
> // method's return type.
>
> // Create a reference to the objc_msgSend_stret() declaration.
> - DeclRefExpr *STDRE = new (Context) DeclRefExpr(MsgSendStretFlavor, msgSendType,
> + DeclRefExpr *STDRE = new (Context) DeclRefExpr(MsgSendStretFlavor,
> + false, msgSendType,
> VK_LValue, SourceLocation());
> // Need to cast objc_msgSend_stret to "void *" (see above comment).
> cast = NoTypeInfoCStyleCastExpr(Context,
> @@ -3129,8 +3132,8 @@
> VarDecl *VD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
> SourceLocation(), ID, getProtocolType(), 0,
> SC_Extern, SC_None);
> - DeclRefExpr *DRE = new (Context) DeclRefExpr(VD, getProtocolType(), VK_LValue,
> - SourceLocation());
> + DeclRefExpr *DRE = new (Context) DeclRefExpr(VD, false, getProtocolType(),
> + VK_LValue, SourceLocation());
> Expr *DerefExpr = new (Context) UnaryOperator(DRE, UO_AddrOf,
> Context->getPointerType(DRE->getType()),
> VK_RValue, OK_Ordinary, SourceLocation());
> @@ -3689,21 +3692,25 @@
> // Need to copy-in the inner copied-in variables not actually used in this
> // block.
> for (int j = 0; j < InnerDeclRefsCount[i]; j++) {
> - BlockDeclRefExpr *Exp = InnerDeclRefs[count++];
> + DeclRefExpr *Exp = InnerDeclRefs[count++];
> ValueDecl *VD = Exp->getDecl();
> BlockDeclRefs.push_back(Exp);
> - if (!Exp->isByRef() && !BlockByCopyDeclsPtrSet.count(VD)) {
> - BlockByCopyDeclsPtrSet.insert(VD);
> - BlockByCopyDecls.push_back(VD);
> + if (!VD->hasAttr<BlocksAttr>()) {
> + if (!BlockByCopyDeclsPtrSet.count(VD)) {
> + BlockByCopyDeclsPtrSet.insert(VD);
> + BlockByCopyDecls.push_back(VD);
> + }
> + continue;
> }
> - if (Exp->isByRef() && !BlockByRefDeclsPtrSet.count(VD)) {
> +
> + if (!BlockByRefDeclsPtrSet.count(VD)) {
> BlockByRefDeclsPtrSet.insert(VD);
> BlockByRefDecls.push_back(VD);
> }
> +
> // imported objects in the inner blocks not used in the outer
> // blocks must be copied/disposed in the outer block as well.
> - if (Exp->isByRef() ||
> - VD->getType()->isObjCObjectPointerType() ||
> + if (VD->getType()->isObjCObjectPointerType() ||
> VD->getType()->isBlockPointerType())
> ImportedBlockDecls.insert(VD);
> }
> @@ -3791,25 +3798,17 @@
> GetBlockDeclRefExprs(*CI);
> }
> // Handle specific things.
> - if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(S)) {
> - // FIXME: Handle enums.
> - if (!isa<FunctionDecl>(CDRE->getDecl()))
> - BlockDeclRefs.push_back(CDRE);
> - }
> - else if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S))
> - if (HasLocalVariableExternalStorage(DRE->getDecl())) {
> - BlockDeclRefExpr *BDRE =
> - new (Context)BlockDeclRefExpr(cast<VarDecl>(DRE->getDecl()),
> - DRE->getType(),
> - VK_LValue, DRE->getLocation(), false);
> - BlockDeclRefs.push_back(BDRE);
> + if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S))
> + if (DRE->refersToEnclosingLocal() &&
> + HasLocalVariableExternalStorage(DRE->getDecl())) {
> + BlockDeclRefs.push_back(DRE);
> }
>
> return;
> }
>
> void RewriteModernObjC::GetInnerBlockDeclRefExprs(Stmt *S,
> - SmallVector<BlockDeclRefExpr *, 8> &InnerBlockDeclRefs,
> + SmallVector<DeclRefExpr *, 8> &InnerBlockDeclRefs,
> llvm::SmallPtrSet<const DeclContext *, 8> &InnerContexts) {
> for (Stmt::child_range CI = S->children(); CI; ++CI)
> if (*CI) {
> @@ -3826,15 +3825,15 @@
>
> }
> // Handle specific things.
> - if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(S)) {
> - if (!isa<FunctionDecl>(CDRE->getDecl()) &&
> - !InnerContexts.count(CDRE->getDecl()->getDeclContext()))
> - InnerBlockDeclRefs.push_back(CDRE);
> - }
> - else if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) {
> - if (VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl()))
> - if (Var->isFunctionOrMethodVarDecl())
> - ImportedLocalExternalDecls.insert(Var);
> + if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) {
> + if (DRE->refersToEnclosingLocal()) {
> + if (!isa<FunctionDecl>(DRE->getDecl()) &&
> + !InnerContexts.count(DRE->getDecl()->getDeclContext()))
> + InnerBlockDeclRefs.push_back(DRE);
> + if (VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl()))
> + if (Var->isFunctionOrMethodVarDecl())
> + ImportedLocalExternalDecls.insert(Var);
> + }
> }
>
> return;
> @@ -3896,9 +3895,6 @@
>
> if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BlockExp)) {
> CPT = DRE->getType()->getAs<BlockPointerType>();
> - } else if (const BlockDeclRefExpr *CDRE =
> - dyn_cast<BlockDeclRefExpr>(BlockExp)) {
> - CPT = CDRE->getType()->getAs<BlockPointerType>();
> } else if (const MemberExpr *MExpr = dyn_cast<MemberExpr>(BlockExp)) {
> CPT = MExpr->getType()->getAs<BlockPointerType>();
> }
> @@ -3999,7 +3995,7 @@
> }
>
> // We need to return the rewritten expression to handle cases where the
> -// BlockDeclRefExpr is embedded in another expression being rewritten.
> +// DeclRefExpr is embedded in another expression being rewritten.
> // For example:
> //
> // int main() {
> @@ -4007,21 +4003,15 @@
> // __block int i;
> //
> // void (^myblock)() = ^() {
> -// [f test]; // f is a BlockDeclRefExpr embedded in a message (which is being rewritten).
> +// [f test]; // f is a DeclRefExpr embedded in a message (which is being rewritten).
> // i = 77;
> // };
> //}
> -Stmt *RewriteModernObjC::RewriteBlockDeclRefExpr(Expr *DeclRefExp) {
> +Stmt *RewriteModernObjC::RewriteBlockDeclRefExpr(DeclRefExpr *DeclRefExp) {
> // Rewrite the byref variable into BYREFVAR->__forwarding->BYREFVAR
> // for each DeclRefExp where BYREFVAR is name of the variable.
> - ValueDecl *VD;
> - bool isArrow = true;
> - if (BlockDeclRefExpr *BDRE = dyn_cast<BlockDeclRefExpr>(DeclRefExp))
> - VD = BDRE->getDecl();
> - else {
> - VD = cast<DeclRefExpr>(DeclRefExp)->getDecl();
> - isArrow = false;
> - }
> + ValueDecl *VD = DeclRefExp->getDecl();
> + bool isArrow = DeclRefExp->refersToEnclosingLocal();
>
> FieldDecl *FD = FieldDecl::Create(*Context, 0, SourceLocation(),
> SourceLocation(),
> @@ -4515,7 +4505,7 @@
> if (BlockDeclRefs.size()) {
> // Unique all "by copy" declarations.
> for (unsigned i = 0; i < BlockDeclRefs.size(); i++)
> - if (!BlockDeclRefs[i]->isByRef()) {
> + if (!BlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>()) {
> if (!BlockByCopyDeclsPtrSet.count(BlockDeclRefs[i]->getDecl())) {
> BlockByCopyDeclsPtrSet.insert(BlockDeclRefs[i]->getDecl());
> BlockByCopyDecls.push_back(BlockDeclRefs[i]->getDecl());
> @@ -4523,7 +4513,7 @@
> }
> // Unique all "by ref" declarations.
> for (unsigned i = 0; i < BlockDeclRefs.size(); i++)
> - if (BlockDeclRefs[i]->isByRef()) {
> + if (BlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>()) {
> if (!BlockByRefDeclsPtrSet.count(BlockDeclRefs[i]->getDecl())) {
> BlockByRefDeclsPtrSet.insert(BlockDeclRefs[i]->getDecl());
> BlockByRefDecls.push_back(BlockDeclRefs[i]->getDecl());
> @@ -4531,7 +4521,7 @@
> }
> // Find any imported blocks...they will need special attention.
> for (unsigned i = 0; i < BlockDeclRefs.size(); i++)
> - if (BlockDeclRefs[i]->isByRef() ||
> + if (BlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>() ||
> BlockDeclRefs[i]->getType()->isObjCObjectPointerType() ||
> BlockDeclRefs[i]->getType()->isBlockPointerType())
> ImportedBlockDecls.insert(BlockDeclRefs[i]->getDecl());
> @@ -4547,7 +4537,7 @@
> }
>
> Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp,
> - const SmallVector<BlockDeclRefExpr *, 8> &InnerBlockDeclRefs) {
> + const SmallVector<DeclRefExpr *, 8> &InnerBlockDeclRefs) {
> const BlockDecl *block = Exp->getBlockDecl();
> Blocks.push_back(Exp);
>
> @@ -4557,9 +4547,9 @@
> int countOfInnerDecls = 0;
> if (!InnerBlockDeclRefs.empty()) {
> for (unsigned i = 0; i < InnerBlockDeclRefs.size(); i++) {
> - BlockDeclRefExpr *Exp = InnerBlockDeclRefs[i];
> + DeclRefExpr *Exp = InnerBlockDeclRefs[i];
> ValueDecl *VD = Exp->getDecl();
> - if (!Exp->isByRef() && !BlockByCopyDeclsPtrSet.count(VD)) {
> + if (!VD->hasAttr<BlocksAttr>() && !BlockByCopyDeclsPtrSet.count(VD)) {
> // We need to save the copied-in variables in nested
> // blocks because it is needed at the end for some of the API generations.
> // See SynthesizeBlockLiterals routine.
> @@ -4568,7 +4558,7 @@
> BlockByCopyDeclsPtrSet.insert(VD);
> BlockByCopyDecls.push_back(VD);
> }
> - if (Exp->isByRef() && !BlockByRefDeclsPtrSet.count(VD)) {
> + if (VD->hasAttr<BlocksAttr>() && !BlockByRefDeclsPtrSet.count(VD)) {
> InnerDeclRefs.push_back(Exp); countOfInnerDecls++;
> BlockDeclRefs.push_back(Exp);
> BlockByRefDeclsPtrSet.insert(VD);
> @@ -4577,7 +4567,7 @@
> }
> // Find any imported blocks...they will need special attention.
> for (unsigned i = 0; i < InnerBlockDeclRefs.size(); i++)
> - if (InnerBlockDeclRefs[i]->isByRef() ||
> + if (InnerBlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>() ||
> InnerBlockDeclRefs[i]->getType()->isObjCObjectPointerType() ||
> InnerBlockDeclRefs[i]->getType()->isBlockPointerType())
> ImportedBlockDecls.insert(InnerBlockDeclRefs[i]->getDecl());
> @@ -4607,15 +4597,15 @@
>
> // Simulate a contructor call...
> FD = SynthBlockInitFunctionDecl(Tag);
> - DeclRefExpr *DRE = new (Context) DeclRefExpr(FD, FType, VK_RValue,
> + DeclRefExpr *DRE = new (Context) DeclRefExpr(FD, false, FType, VK_RValue,
> SourceLocation());
>
> SmallVector<Expr*, 4> InitExprs;
>
> // Initialize the block function.
> FD = SynthBlockInitFunctionDecl(Func);
> - DeclRefExpr *Arg = new (Context) DeclRefExpr(FD, FD->getType(), VK_LValue,
> - SourceLocation());
> + DeclRefExpr *Arg = new (Context) DeclRefExpr(FD, false, FD->getType(),
> + VK_LValue, SourceLocation());
> CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, Context->VoidPtrTy,
> CK_BitCast, Arg);
> InitExprs.push_back(castExpr);
> @@ -4629,7 +4619,7 @@
> Context->VoidPtrTy, 0,
> SC_Static, SC_None);
> UnaryOperator *DescRefExpr =
> - new (Context) UnaryOperator(new (Context) DeclRefExpr(NewVD,
> + new (Context) UnaryOperator(new (Context) DeclRefExpr(NewVD, false,
> Context->VoidPtrTy,
> VK_LValue,
> SourceLocation()),
> @@ -4648,8 +4638,8 @@
> if (isObjCType((*I)->getType())) {
> // FIXME: Conform to ABI ([[obj retain] autorelease]).
> FD = SynthBlockInitFunctionDecl((*I)->getName());
> - Exp = new (Context) DeclRefExpr(FD, FD->getType(), VK_LValue,
> - SourceLocation());
> + Exp = new (Context) DeclRefExpr(FD, false, FD->getType(),
> + VK_LValue, SourceLocation());
> if (HasLocalVariableExternalStorage(*I)) {
> QualType QT = (*I)->getType();
> QT = Context->getPointerType(QT);
> @@ -4658,14 +4648,14 @@
> }
> } else if (isTopLevelBlockPointerType((*I)->getType())) {
> FD = SynthBlockInitFunctionDecl((*I)->getName());
> - Arg = new (Context) DeclRefExpr(FD, FD->getType(), VK_LValue,
> - SourceLocation());
> + Arg = new (Context) DeclRefExpr(FD, false, FD->getType(),
> + VK_LValue, SourceLocation());
> Exp = NoTypeInfoCStyleCastExpr(Context, Context->VoidPtrTy,
> CK_BitCast, Arg);
> } else {
> FD = SynthBlockInitFunctionDecl((*I)->getName());
> - Exp = new (Context) DeclRefExpr(FD, FD->getType(), VK_LValue,
> - SourceLocation());
> + Exp = new (Context) DeclRefExpr(FD, false, FD->getType(),
> + VK_LValue, SourceLocation());
> if (HasLocalVariableExternalStorage(*I)) {
> QualType QT = (*I)->getType();
> QT = Context->getPointerType(QT);
> @@ -4692,7 +4682,7 @@
> QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
>
> FD = SynthBlockInitFunctionDecl((*I)->getName());
> - Exp = new (Context) DeclRefExpr(FD, FD->getType(), VK_LValue,
> + Exp = new (Context) DeclRefExpr(FD, false, FD->getType(), VK_LValue,
> SourceLocation());
> bool isNestedCapturedVar = false;
> if (block)
> @@ -4786,7 +4776,7 @@
> }
>
> if (BlockExpr *BE = dyn_cast<BlockExpr>(S)) {
> - SmallVector<BlockDeclRefExpr *, 8> InnerBlockDeclRefs;
> + SmallVector<DeclRefExpr *, 8> InnerBlockDeclRefs;
> llvm::SmallPtrSet<const DeclContext *, 8> InnerContexts;
> InnerContexts.insert(BE->getBlockDecl());
> ImportedLocalExternalDecls.clear();
> @@ -4931,10 +4921,6 @@
> Stmts.pop_back();
> }
> // Handle blocks rewriting.
> - if (BlockDeclRefExpr *BDRE = dyn_cast<BlockDeclRefExpr>(S)) {
> - if (BDRE->isByRef())
> - return RewriteBlockDeclRefExpr(BDRE);
> - }
> if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) {
> ValueDecl *VD = DRE->getDecl();
> if (VD->hasAttr<BlocksAttr>())
> @@ -6551,7 +6537,8 @@
> VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
> SourceLocation(), &Context->Idents.get(IvarOffsetName),
> Context->UnsignedLongTy, 0, SC_Extern, SC_None);
> - DeclRefExpr *DRE = new (Context) DeclRefExpr(NewVD, Context->UnsignedLongTy, VK_LValue,
> + DeclRefExpr *DRE = new (Context) DeclRefExpr(NewVD, false,
> + Context->UnsignedLongTy, VK_LValue,
> SourceLocation());
> BinaryOperator *addExpr =
> new (Context) BinaryOperator(castExpr, DRE, BO_Add,
>
> Modified: cfe/trunk/lib/Rewrite/RewriteObjC.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteObjC.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Rewrite/RewriteObjC.cpp (original)
> +++ cfe/trunk/lib/Rewrite/RewriteObjC.cpp Sat Mar 10 03:33:50 2012
> @@ -119,9 +119,9 @@
> // Block expressions.
> SmallVector<BlockExpr *, 32> Blocks;
> SmallVector<int, 32> InnerDeclRefsCount;
> - SmallVector<BlockDeclRefExpr *, 32> InnerDeclRefs;
> + SmallVector<DeclRefExpr *, 32> InnerDeclRefs;
>
> - SmallVector<BlockDeclRefExpr *, 32> BlockDeclRefs;
> + SmallVector<DeclRefExpr *, 32> BlockDeclRefs;
>
> // Block related declarations.
> SmallVector<ValueDecl *, 8> BlockByCopyDecls;
> @@ -320,7 +320,7 @@
> // Block specific rewrite rules.
> void RewriteBlockPointerDecl(NamedDecl *VD);
> void RewriteByRefVar(VarDecl *VD);
> - Stmt *RewriteBlockDeclRefExpr(Expr *VD);
> + Stmt *RewriteBlockDeclRefExpr(DeclRefExpr *VD);
> Stmt *RewriteLocalVariableExternalStorage(DeclRefExpr *DRE);
> void RewriteBlockPointerFunctionArgs(FunctionDecl *FD);
>
> @@ -388,7 +388,7 @@
> StringRef FunName);
> FunctionDecl *SynthBlockInitFunctionDecl(StringRef name);
> Stmt *SynthBlockInitExpr(BlockExpr *Exp,
> - const SmallVector<BlockDeclRefExpr *, 8> &InnerBlockDeclRefs);
> + const SmallVector<DeclRefExpr *, 8> &InnerBlockDeclRefs);
>
> // Misc. helper routines.
> QualType getProtocolType();
> @@ -402,7 +402,7 @@
> void CollectBlockDeclRefInfo(BlockExpr *Exp);
> void GetBlockDeclRefExprs(Stmt *S);
> void GetInnerBlockDeclRefExprs(Stmt *S,
> - SmallVector<BlockDeclRefExpr *, 8> &InnerBlockDeclRefs,
> + SmallVector<DeclRefExpr *, 8> &InnerBlockDeclRefs,
> llvm::SmallPtrSet<const DeclContext *, 8> &InnerContexts);
>
> // We avoid calling Type::isBlockPointerType(), since it operates on the
> @@ -2045,8 +2045,8 @@
> QualType msgSendType = FD->getType();
>
> // Create a reference to the objc_msgSend() declaration.
> - DeclRefExpr *DRE =
> - new (Context) DeclRefExpr(FD, msgSendType, VK_LValue, SourceLocation());
> + DeclRefExpr *DRE = new (Context) DeclRefExpr(FD, false, msgSendType,
> + VK_LValue, SourceLocation());
>
> // Now, we cast the reference to a pointer to the objc_msgSend type.
> QualType pToFunc = Context->getPointerType(msgSendType);
> @@ -2559,7 +2559,7 @@
> VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
> SourceLocation(), &Context->Idents.get(S),
> strType, 0, SC_Static, SC_None);
> - DeclRefExpr *DRE = new (Context) DeclRefExpr(NewVD, strType, VK_LValue,
> + DeclRefExpr *DRE = new (Context) DeclRefExpr(NewVD, false, strType, VK_LValue,
> SourceLocation());
> Expr *Unop = new (Context) UnaryOperator(DRE, UO_AddrOf,
> Context->getPointerType(DRE->getType()),
> @@ -2687,6 +2687,7 @@
> NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
> CK_BitCast,
> new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
> + false,
> Context->getObjCIdType(),
> VK_RValue,
> SourceLocation()))
> @@ -2728,7 +2729,7 @@
> SynthSuperContructorFunctionDecl();
> // Simulate a contructor call...
> DeclRefExpr *DRE = new (Context) DeclRefExpr(SuperContructorFunctionDecl,
> - superType, VK_LValue,
> + false, superType, VK_LValue,
> SourceLocation());
> SuperRep = new (Context) CallExpr(*Context, DRE, &InitExprs[0],
> InitExprs.size(),
> @@ -2798,6 +2799,7 @@
> NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
> CK_BitCast,
> new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
> + false,
> Context->getObjCIdType(),
> VK_RValue, SourceLocation()))
> ); // set the 'receiver'.
> @@ -2837,7 +2839,7 @@
> SynthSuperContructorFunctionDecl();
> // Simulate a contructor call...
> DeclRefExpr *DRE = new (Context) DeclRefExpr(SuperContructorFunctionDecl,
> - superType, VK_LValue,
> + false, superType, VK_LValue,
> SourceLocation());
> SuperRep = new (Context) CallExpr(*Context, DRE, &InitExprs[0],
> InitExprs.size(),
> @@ -2989,7 +2991,7 @@
> QualType msgSendType = MsgSendFlavor->getType();
>
> // Create a reference to the objc_msgSend() declaration.
> - DeclRefExpr *DRE = new (Context) DeclRefExpr(MsgSendFlavor, msgSendType,
> + DeclRefExpr *DRE = new (Context) DeclRefExpr(MsgSendFlavor, false, msgSendType,
> VK_LValue, SourceLocation());
>
> // Need to cast objc_msgSend to "void *" (to workaround a GCC bandaid).
> @@ -3025,7 +3027,8 @@
> // method's return type.
>
> // Create a reference to the objc_msgSend_stret() declaration.
> - DeclRefExpr *STDRE = new (Context) DeclRefExpr(MsgSendStretFlavor, msgSendType,
> + DeclRefExpr *STDRE = new (Context) DeclRefExpr(MsgSendStretFlavor,
> + false, msgSendType,
> VK_LValue, SourceLocation());
> // Need to cast objc_msgSend_stret to "void *" (see above comment).
> cast = NoTypeInfoCStyleCastExpr(Context,
> @@ -3113,8 +3116,8 @@
> VarDecl *VD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
> SourceLocation(), ID, getProtocolType(), 0,
> SC_Extern, SC_None);
> - DeclRefExpr *DRE = new (Context) DeclRefExpr(VD, getProtocolType(), VK_LValue,
> - SourceLocation());
> + DeclRefExpr *DRE = new (Context) DeclRefExpr(VD, false, getProtocolType(),
> + VK_LValue, SourceLocation());
> Expr *DerefExpr = new (Context) UnaryOperator(DRE, UO_AddrOf,
> Context->getPointerType(DRE->getType()),
> VK_RValue, OK_Ordinary, SourceLocation());
> @@ -3630,20 +3633,20 @@
> // Need to copy-in the inner copied-in variables not actually used in this
> // block.
> for (int j = 0; j < InnerDeclRefsCount[i]; j++) {
> - BlockDeclRefExpr *Exp = InnerDeclRefs[count++];
> + DeclRefExpr *Exp = InnerDeclRefs[count++];
> ValueDecl *VD = Exp->getDecl();
> BlockDeclRefs.push_back(Exp);
> - if (!Exp->isByRef() && !BlockByCopyDeclsPtrSet.count(VD)) {
> + if (!VD->hasAttr<BlocksAttr>() && !BlockByCopyDeclsPtrSet.count(VD)) {
> BlockByCopyDeclsPtrSet.insert(VD);
> BlockByCopyDecls.push_back(VD);
> }
> - if (Exp->isByRef() && !BlockByRefDeclsPtrSet.count(VD)) {
> + if (VD->hasAttr<BlocksAttr>() && !BlockByRefDeclsPtrSet.count(VD)) {
> BlockByRefDeclsPtrSet.insert(VD);
> BlockByRefDecls.push_back(VD);
> }
> // imported objects in the inner blocks not used in the outer
> // blocks must be copied/disposed in the outer block as well.
> - if (Exp->isByRef() ||
> + if (VD->hasAttr<BlocksAttr>() ||
> VD->getType()->isObjCObjectPointerType() ||
> VD->getType()->isBlockPointerType())
> ImportedBlockDecls.insert(VD);
> @@ -3732,25 +3735,21 @@
> GetBlockDeclRefExprs(*CI);
> }
> // Handle specific things.
> - if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(S)) {
> - // FIXME: Handle enums.
> - if (!isa<FunctionDecl>(CDRE->getDecl()))
> - BlockDeclRefs.push_back(CDRE);
> - }
> - else if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S))
> - if (HasLocalVariableExternalStorage(DRE->getDecl())) {
> - BlockDeclRefExpr *BDRE =
> - new (Context)BlockDeclRefExpr(cast<VarDecl>(DRE->getDecl()),
> - DRE->getType(),
> - VK_LValue, DRE->getLocation(), false);
> - BlockDeclRefs.push_back(BDRE);
> + if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) {
> + if (DRE->refersToEnclosingLocal()) {
> + // FIXME: Handle enums.
> + if (!isa<FunctionDecl>(DRE->getDecl()))
> + BlockDeclRefs.push_back(DRE);
> + if (HasLocalVariableExternalStorage(DRE->getDecl()))
> + BlockDeclRefs.push_back(DRE);
> }
> + }
>
> return;
> }
>
> void RewriteObjC::GetInnerBlockDeclRefExprs(Stmt *S,
> - SmallVector<BlockDeclRefExpr *, 8> &InnerBlockDeclRefs,
> + SmallVector<DeclRefExpr *, 8> &InnerBlockDeclRefs,
> llvm::SmallPtrSet<const DeclContext *, 8> &InnerContexts) {
> for (Stmt::child_range CI = S->children(); CI; ++CI)
> if (*CI) {
> @@ -3767,15 +3766,15 @@
>
> }
> // Handle specific things.
> - if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(S)) {
> - if (!isa<FunctionDecl>(CDRE->getDecl()) &&
> - !InnerContexts.count(CDRE->getDecl()->getDeclContext()))
> - InnerBlockDeclRefs.push_back(CDRE);
> - }
> - else if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) {
> - if (VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl()))
> - if (Var->isFunctionOrMethodVarDecl())
> - ImportedLocalExternalDecls.insert(Var);
> + if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) {
> + if (DRE->refersToEnclosingLocal()) {
> + if (!isa<FunctionDecl>(DRE->getDecl()) &&
> + !InnerContexts.count(DRE->getDecl()->getDeclContext()))
> + InnerBlockDeclRefs.push_back(DRE);
> + if (VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl()))
> + if (Var->isFunctionOrMethodVarDecl())
> + ImportedLocalExternalDecls.insert(Var);
> + }
> }
>
> return;
> @@ -3818,9 +3817,6 @@
>
> if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BlockExp)) {
> CPT = DRE->getType()->getAs<BlockPointerType>();
> - } else if (const BlockDeclRefExpr *CDRE =
> - dyn_cast<BlockDeclRefExpr>(BlockExp)) {
> - CPT = CDRE->getType()->getAs<BlockPointerType>();
> } else if (const MemberExpr *MExpr = dyn_cast<MemberExpr>(BlockExp)) {
> CPT = MExpr->getType()->getAs<BlockPointerType>();
> }
> @@ -3933,17 +3929,11 @@
> // i = 77;
> // };
> //}
> -Stmt *RewriteObjC::RewriteBlockDeclRefExpr(Expr *DeclRefExp) {
> +Stmt *RewriteObjC::RewriteBlockDeclRefExpr(DeclRefExpr *DeclRefExp) {
> // Rewrite the byref variable into BYREFVAR->__forwarding->BYREFVAR
> // for each DeclRefExp where BYREFVAR is name of the variable.
> - ValueDecl *VD;
> - bool isArrow = true;
> - if (BlockDeclRefExpr *BDRE = dyn_cast<BlockDeclRefExpr>(DeclRefExp))
> - VD = BDRE->getDecl();
> - else {
> - VD = cast<DeclRefExpr>(DeclRefExp)->getDecl();
> - isArrow = false;
> - }
> + ValueDecl *VD = DeclRefExp->getDecl();
> + bool isArrow = DeclRefExp->refersToEnclosingLocal();
>
> FieldDecl *FD = FieldDecl::Create(*Context, 0, SourceLocation(),
> SourceLocation(),
> @@ -4437,7 +4427,7 @@
> if (BlockDeclRefs.size()) {
> // Unique all "by copy" declarations.
> for (unsigned i = 0; i < BlockDeclRefs.size(); i++)
> - if (!BlockDeclRefs[i]->isByRef()) {
> + if (!BlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>()) {
> if (!BlockByCopyDeclsPtrSet.count(BlockDeclRefs[i]->getDecl())) {
> BlockByCopyDeclsPtrSet.insert(BlockDeclRefs[i]->getDecl());
> BlockByCopyDecls.push_back(BlockDeclRefs[i]->getDecl());
> @@ -4445,7 +4435,7 @@
> }
> // Unique all "by ref" declarations.
> for (unsigned i = 0; i < BlockDeclRefs.size(); i++)
> - if (BlockDeclRefs[i]->isByRef()) {
> + if (BlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>()) {
> if (!BlockByRefDeclsPtrSet.count(BlockDeclRefs[i]->getDecl())) {
> BlockByRefDeclsPtrSet.insert(BlockDeclRefs[i]->getDecl());
> BlockByRefDecls.push_back(BlockDeclRefs[i]->getDecl());
> @@ -4453,7 +4443,7 @@
> }
> // Find any imported blocks...they will need special attention.
> for (unsigned i = 0; i < BlockDeclRefs.size(); i++)
> - if (BlockDeclRefs[i]->isByRef() ||
> + if (BlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>() ||
> BlockDeclRefs[i]->getType()->isObjCObjectPointerType() ||
> BlockDeclRefs[i]->getType()->isBlockPointerType())
> ImportedBlockDecls.insert(BlockDeclRefs[i]->getDecl());
> @@ -4469,7 +4459,7 @@
> }
>
> Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
> - const SmallVector<BlockDeclRefExpr *, 8> &InnerBlockDeclRefs) {
> + const SmallVector<DeclRefExpr *, 8> &InnerBlockDeclRefs) {
> const BlockDecl *block = Exp->getBlockDecl();
> Blocks.push_back(Exp);
>
> @@ -4479,9 +4469,9 @@
> int countOfInnerDecls = 0;
> if (!InnerBlockDeclRefs.empty()) {
> for (unsigned i = 0; i < InnerBlockDeclRefs.size(); i++) {
> - BlockDeclRefExpr *Exp = InnerBlockDeclRefs[i];
> + DeclRefExpr *Exp = InnerBlockDeclRefs[i];
> ValueDecl *VD = Exp->getDecl();
> - if (!Exp->isByRef() && !BlockByCopyDeclsPtrSet.count(VD)) {
> + if (!VD->hasAttr<BlocksAttr>() && !BlockByCopyDeclsPtrSet.count(VD)) {
> // We need to save the copied-in variables in nested
> // blocks because it is needed at the end for some of the API generations.
> // See SynthesizeBlockLiterals routine.
> @@ -4490,7 +4480,7 @@
> BlockByCopyDeclsPtrSet.insert(VD);
> BlockByCopyDecls.push_back(VD);
> }
> - if (Exp->isByRef() && !BlockByRefDeclsPtrSet.count(VD)) {
> + if (VD->hasAttr<BlocksAttr>() && !BlockByRefDeclsPtrSet.count(VD)) {
> InnerDeclRefs.push_back(Exp); countOfInnerDecls++;
> BlockDeclRefs.push_back(Exp);
> BlockByRefDeclsPtrSet.insert(VD);
> @@ -4499,7 +4489,7 @@
> }
> // Find any imported blocks...they will need special attention.
> for (unsigned i = 0; i < InnerBlockDeclRefs.size(); i++)
> - if (InnerBlockDeclRefs[i]->isByRef() ||
> + if (InnerBlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>() ||
> InnerBlockDeclRefs[i]->getType()->isObjCObjectPointerType() ||
> InnerBlockDeclRefs[i]->getType()->isBlockPointerType())
> ImportedBlockDecls.insert(InnerBlockDeclRefs[i]->getDecl());
> @@ -4529,15 +4519,15 @@
>
> // Simulate a contructor call...
> FD = SynthBlockInitFunctionDecl(Tag);
> - DeclRefExpr *DRE = new (Context) DeclRefExpr(FD, FType, VK_RValue,
> + DeclRefExpr *DRE = new (Context) DeclRefExpr(FD, false, FType, VK_RValue,
> SourceLocation());
>
> SmallVector<Expr*, 4> InitExprs;
>
> // Initialize the block function.
> FD = SynthBlockInitFunctionDecl(Func);
> - DeclRefExpr *Arg = new (Context) DeclRefExpr(FD, FD->getType(), VK_LValue,
> - SourceLocation());
> + DeclRefExpr *Arg = new (Context) DeclRefExpr(FD, false, FD->getType(),
> + VK_LValue, SourceLocation());
> CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, Context->VoidPtrTy,
> CK_BitCast, Arg);
> InitExprs.push_back(castExpr);
> @@ -4551,7 +4541,7 @@
> Context->VoidPtrTy, 0,
> SC_Static, SC_None);
> UnaryOperator *DescRefExpr =
> - new (Context) UnaryOperator(new (Context) DeclRefExpr(NewVD,
> + new (Context) UnaryOperator(new (Context) DeclRefExpr(NewVD, false,
> Context->VoidPtrTy,
> VK_LValue,
> SourceLocation()),
> @@ -4570,7 +4560,7 @@
> if (isObjCType((*I)->getType())) {
> // FIXME: Conform to ABI ([[obj retain] autorelease]).
> FD = SynthBlockInitFunctionDecl((*I)->getName());
> - Exp = new (Context) DeclRefExpr(FD, FD->getType(), VK_LValue,
> + Exp = new (Context) DeclRefExpr(FD, false, FD->getType(), VK_LValue,
> SourceLocation());
> if (HasLocalVariableExternalStorage(*I)) {
> QualType QT = (*I)->getType();
> @@ -4580,13 +4570,13 @@
> }
> } else if (isTopLevelBlockPointerType((*I)->getType())) {
> FD = SynthBlockInitFunctionDecl((*I)->getName());
> - Arg = new (Context) DeclRefExpr(FD, FD->getType(), VK_LValue,
> + Arg = new (Context) DeclRefExpr(FD, false, FD->getType(), VK_LValue,
> SourceLocation());
> Exp = NoTypeInfoCStyleCastExpr(Context, Context->VoidPtrTy,
> CK_BitCast, Arg);
> } else {
> FD = SynthBlockInitFunctionDecl((*I)->getName());
> - Exp = new (Context) DeclRefExpr(FD, FD->getType(), VK_LValue,
> + Exp = new (Context) DeclRefExpr(FD, false, FD->getType(), VK_LValue,
> SourceLocation());
> if (HasLocalVariableExternalStorage(*I)) {
> QualType QT = (*I)->getType();
> @@ -4614,7 +4604,7 @@
> QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
>
> FD = SynthBlockInitFunctionDecl((*I)->getName());
> - Exp = new (Context) DeclRefExpr(FD, FD->getType(), VK_LValue,
> + Exp = new (Context) DeclRefExpr(FD, false, FD->getType(), VK_LValue,
> SourceLocation());
> bool isNestedCapturedVar = false;
> if (block)
> @@ -4708,7 +4698,7 @@
> }
>
> if (BlockExpr *BE = dyn_cast<BlockExpr>(S)) {
> - SmallVector<BlockDeclRefExpr *, 8> InnerBlockDeclRefs;
> + SmallVector<DeclRefExpr *, 8> InnerBlockDeclRefs;
> llvm::SmallPtrSet<const DeclContext *, 8> InnerContexts;
> InnerContexts.insert(BE->getBlockDecl());
> ImportedLocalExternalDecls.clear();
> @@ -4853,10 +4843,6 @@
> Stmts.pop_back();
> }
> // Handle blocks rewriting.
> - if (BlockDeclRefExpr *BDRE = dyn_cast<BlockDeclRefExpr>(S)) {
> - if (BDRE->isByRef())
> - return RewriteBlockDeclRefExpr(BDRE);
> - }
> if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) {
> ValueDecl *VD = DRE->getDecl();
> if (VD->hasAttr<BlocksAttr>())
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Sat Mar 10 03:33:50 2012
> @@ -983,6 +983,7 @@
> DRE->getQualifierLoc(),
> SourceLocation(),
> NewBuiltinDecl,
> + /*enclosing*/ false,
> DRE->getLocation(),
> NewBuiltinDecl->getType(),
> DRE->getValueKind());
> @@ -4674,12 +4675,6 @@
> return considerVariable(var, ref, owner);
> }
>
> - if (BlockDeclRefExpr *ref = dyn_cast<BlockDeclRefExpr>(e)) {
> - owner.Variable = ref->getDecl();
> - owner.setLocsFrom(ref);
> - return true;
> - }
> -
> if (MemberExpr *member = dyn_cast<MemberExpr>(e)) {
> if (member->isArrow()) return false;
>
> @@ -4736,11 +4731,6 @@
> Capturer = ref;
> }
>
> - void VisitBlockDeclRefExpr(BlockDeclRefExpr *ref) {
> - if (ref->getDecl() == Variable && !Capturer)
> - Capturer = ref;
> - }
> -
> void VisitObjCIvarRefExpr(ObjCIvarRefExpr *ref) {
> if (Capturer) return;
> Visit(ref->getBase());
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Mar 10 03:33:50 2012
> @@ -6721,7 +6721,7 @@
>
> if (type->isStructureOrClassType()) {
> SourceLocation poi = var->getLocation();
> - Expr *varRef = new (Context) DeclRefExpr(var, type, VK_LValue, poi);
> + Expr *varRef =new (Context) DeclRefExpr(var, false, type, VK_LValue, poi);
> ExprResult result =
> PerformCopyInitialization(
> InitializedEntity::InitializeBlock(poi, type, false),
>
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Mar 10 03:33:50 2012
> @@ -2415,7 +2415,7 @@
>
> Expr *CopyCtorArg =
> DeclRefExpr::Create(SemaRef.Context, NestedNameSpecifierLoc(),
> - SourceLocation(), Param,
> + SourceLocation(), Param, false,
> Constructor->getLocation(), ParamType,
> VK_LValue, 0);
>
> @@ -2491,7 +2491,7 @@
>
> Expr *MemberExprBase =
> DeclRefExpr::Create(SemaRef.Context, NestedNameSpecifierLoc(),
> - SourceLocation(), Param,
> + SourceLocation(), Param, false,
> Loc, ParamType, VK_LValue, 0);
>
> SemaRef.MarkDeclRefReferenced(cast<DeclRefExpr>(MemberExprBase));
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Mar 10 03:33:50 2012
> @@ -1266,11 +1266,16 @@
> }
> }
>
> + bool refersToEnclosingScope =
> + (CurContext != D->getDeclContext() &&
> + D->getDeclContext()->isFunctionOrMethod());
> +
> DeclRefExpr *E = DeclRefExpr::Create(Context,
> SS ? SS->getWithLocInContext(Context)
> : NestedNameSpecifierLoc(),
> - SourceLocation(),
> - D, NameInfo, Ty, VK);
> + SourceLocation(),
> + D, refersToEnclosingScope,
> + NameInfo, Ty, VK);
>
> MarkDeclRefReferenced(E);
>
> @@ -2146,42 +2151,6 @@
> return Owned(ULE);
> }
>
> -static bool shouldBuildBlockDeclRef(ValueDecl *D, Sema &S) {
> - // Check for a variable with local storage not from the current scope;
> - // we need to create BlockDeclRefExprs for these.
> - // FIXME: BlockDeclRefExpr shouldn't exist!
> - VarDecl *var = dyn_cast<VarDecl>(D);
> - if (!var)
> - return false;
> - if (var->getDeclContext() == S.CurContext)
> - return false;
> - if (!var->hasLocalStorage())
> - return false;
> - return S.getCurBlock() != 0;
> -}
> -
> -static ExprResult BuildBlockDeclRefExpr(Sema &S, ValueDecl *VD,
> - const DeclarationNameInfo &NameInfo) {
> - VarDecl *var = cast<VarDecl>(VD);
> - QualType exprType = var->getType().getNonReferenceType();
> -
> - bool HasBlockAttr = var->hasAttr<BlocksAttr>();
> - bool ConstAdded = false;
> - if (!HasBlockAttr) {
> - ConstAdded = !exprType.isConstQualified();
> - exprType.addConst();
> - }
> -
> - BlockDeclRefExpr *BDRE =
> - new (S.Context) BlockDeclRefExpr(var, exprType, VK_LValue,
> - NameInfo.getLoc(), HasBlockAttr,
> - ConstAdded);
> -
> - S.MarkBlockDeclRefReferenced(BDRE);
> -
> - return S.Owned(BDRE);
> -}
> -
> /// \brief Complete semantic analysis for a reference to the given declaration.
> ExprResult
> Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS,
> @@ -2304,9 +2273,6 @@
> valueKind = VK_LValue;
> type = type.getNonReferenceType();
>
> - if (shouldBuildBlockDeclRef(VD, *this))
> - return BuildBlockDeclRefExpr(*this, VD, NameInfo);
> -
> // FIXME: Does the addition of const really only apply in
> // potentially-evaluated contexts? Since the variable isn't actually
> // captured in an unevaluated context, it seems that the answer is no.
> @@ -3721,7 +3687,7 @@
> QualType ConfigQTy = ConfigDecl->getType();
>
> DeclRefExpr *ConfigDR = new (Context) DeclRefExpr(
> - ConfigDecl, ConfigQTy, VK_LValue, LLLLoc);
> + ConfigDecl, false, ConfigQTy, VK_LValue, LLLLoc);
> MarkFunctionReferenced(LLLLoc, ConfigDecl);
>
> return ActOnCallExpr(S, ConfigDR, LLLLoc, ExecConfig, GGGLoc, 0,
> @@ -9863,7 +9829,8 @@
> // C++ [expr.prim.labda]p12:
> // An entity captured by a lambda-expression is odr-used (3.2) in
> // the scope containing the lambda-expression.
> - Expr *Ref = new (S.Context) DeclRefExpr(Var, DeclRefType, VK_LValue, Loc);
> + Expr *Ref = new (S.Context) DeclRefExpr(Var, false, DeclRefType,
> + VK_LValue, Loc);
> Var->setReferenced(true);
> Var->setUsed(true);
>
> @@ -10109,7 +10076,7 @@
> // According to the blocks spec, the capture of a variable from
> // the stack requires a const copy constructor. This is not true
> // of the copy/move done to move a __block variable to the heap.
> - Expr *DeclRef = new (Context) DeclRefExpr(Var,
> + Expr *DeclRef = new (Context) DeclRefExpr(Var, false,
> DeclRefType.withConst(),
> VK_LValue, Loc);
> ExprResult Result
> @@ -10278,10 +10245,7 @@
> i != e; ++i) {
> VarDecl *Var;
> SourceLocation Loc;
> - if (BlockDeclRefExpr *BDRE = dyn_cast<BlockDeclRefExpr>(*i)) {
> - Var = BDRE->getDecl();
> - Loc = BDRE->getLocation();
> - } else if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(*i)) {
> + if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(*i)) {
> Var = cast<VarDecl>(DRE->getDecl());
> Loc = DRE->getLocation();
> } else if (MemberExpr *ME = dyn_cast<MemberExpr>(*i)) {
> @@ -10365,12 +10329,6 @@
> SemaRef.MarkAnyDeclReferenced(Loc, D);
> }
>
> -/// \brief Perform reference-marking and odr-use handling for a
> -/// BlockDeclRefExpr.
> -void Sema::MarkBlockDeclRefReferenced(BlockDeclRefExpr *E) {
> - MarkExprReferenced(*this, E->getLocation(), E->getDecl(), E);
> -}
> -
> /// \brief Perform reference-marking and odr-use handling for a DeclRefExpr.
> void Sema::MarkDeclRefReferenced(DeclRefExpr *E) {
> MarkExprReferenced(*this, E->getLocation(), E->getDecl(), E);
> @@ -10497,14 +10455,6 @@
> Inherited::VisitCXXConstructExpr(E);
> }
>
> - void VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
> - // If we were asked not to visit local variables, don't.
> - if (SkipLocalVariables && E->getDecl()->hasLocalStorage())
> - return;
> -
> - S.MarkBlockDeclRefReferenced(E);
> - }
> -
> void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
> Visit(E->getExpr());
> }
>
> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sat Mar 10 03:33:50 2012
> @@ -2187,6 +2187,7 @@
> Owned(DeclRefExpr::Create(Context, NestedNameSpecifierLoc(),
> SourceLocation(),
> ConditionVar,
> + /*enclosing*/ false,
> ConditionVar->getLocation(),
> ConditionVar->getType().getNonReferenceType(),
> VK_LValue));
>
> Modified: cfe/trunk/lib/Sema/SemaInit.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaInit.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaInit.cpp Sat Mar 10 03:33:50 2012
> @@ -3872,16 +3872,11 @@
> }
>
> // If we have a declaration reference, it had better be a local variable.
> - } else if (isa<DeclRefExpr>(e) || isa<BlockDeclRefExpr>(e)) {
> + } else if (isa<DeclRefExpr>(e)) {
> if (!isAddressOf) return IIK_nonlocal;
>
> - VarDecl *var;
> - if (isa<DeclRefExpr>(e)) {
> - var = dyn_cast<VarDecl>(cast<DeclRefExpr>(e)->getDecl());
> - if (!var) return IIK_nonlocal;
> - } else {
> - var = cast<BlockDeclRefExpr>(e)->getDecl();
> - }
> + VarDecl *var = dyn_cast<VarDecl>(cast<DeclRefExpr>(e)->getDecl());
> + if (!var) return IIK_nonlocal;
>
> return (var->hasLocalStorage() ? IIK_okay : IIK_nonlocal);
>
>
> Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Sat Mar 10 03:33:50 2012
> @@ -834,7 +834,7 @@
> // FIXME. Eventually we want to do this for Objective-C as well.
> ImplicitParamDecl *SelfDecl = getterMethod->getSelfDecl();
> DeclRefExpr *SelfExpr =
> - new (Context) DeclRefExpr(SelfDecl, SelfDecl->getType(),
> + new (Context) DeclRefExpr(SelfDecl, false, SelfDecl->getType(),
> VK_RValue, SourceLocation());
> Expr *IvarRefExpr =
> new (Context) ObjCIvarRefExpr(Ivar, Ivar->getType(), AtLoc,
> @@ -867,7 +867,7 @@
> // FIXME. Eventually we want to do this for Objective-C as well.
> ImplicitParamDecl *SelfDecl = setterMethod->getSelfDecl();
> DeclRefExpr *SelfExpr =
> - new (Context) DeclRefExpr(SelfDecl, SelfDecl->getType(),
> + new (Context) DeclRefExpr(SelfDecl, false, SelfDecl->getType(),
> VK_RValue, SourceLocation());
> Expr *lhs =
> new (Context) ObjCIvarRefExpr(Ivar, Ivar->getType(), AtLoc,
> @@ -875,7 +875,7 @@
> ObjCMethodDecl::param_iterator P = setterMethod->param_begin();
> ParmVarDecl *Param = (*P);
> QualType T = Param->getType().getNonReferenceType();
> - Expr *rhs = new (Context) DeclRefExpr(Param, T,
> + Expr *rhs = new (Context) DeclRefExpr(Param, false, T,
> VK_LValue, SourceLocation());
> ExprResult Res = BuildBinOp(S, lhs->getLocEnd(),
> BO_Assign, lhs, rhs);
>
> Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOverload.cpp Sat Mar 10 03:33:50 2012
> @@ -40,7 +40,7 @@
> CreateFunctionRefExpr(Sema &S, FunctionDecl *Fn, bool HadMultipleCandidates,
> SourceLocation Loc = SourceLocation(),
> const DeclarationNameLoc &LocInfo = DeclarationNameLoc()){
> - DeclRefExpr *DRE = new (S.Context) DeclRefExpr(Fn, Fn->getType(),
> + DeclRefExpr *DRE = new (S.Context) DeclRefExpr(Fn, false, Fn->getType(),
> VK_LValue, Loc, LocInfo);
> if (HadMultipleCandidates)
> DRE->setHadMultipleCandidates(true);
> @@ -5580,7 +5580,7 @@
> // lvalues/rvalues and the type. Fortunately, we can allocate this
> // call on the stack and we don't need its arguments to be
> // well-formed.
> - DeclRefExpr ConversionRef(Conversion, Conversion->getType(),
> + DeclRefExpr ConversionRef(Conversion, false, Conversion->getType(),
> VK_LValue, From->getLocStart());
> ImplicitCastExpr ConversionFn(ImplicitCastExpr::OnStack,
> Context.getPointerType(Conversion->getType()),
> @@ -11053,6 +11053,7 @@
> ULE->getQualifierLoc(),
> ULE->getTemplateKeywordLoc(),
> Fn,
> + /*enclosing*/ false, // FIXME?
> ULE->getNameLoc(),
> Fn->getType(),
> VK_LValue,
> @@ -11080,6 +11081,7 @@
> MemExpr->getQualifierLoc(),
> MemExpr->getTemplateKeywordLoc(),
> Fn,
> + /*enclosing*/ false,
> MemExpr->getMemberLoc(),
> Fn->getType(),
> VK_LValue,
>
> Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Sat Mar 10 03:33:50 2012
> @@ -73,15 +73,6 @@
> return true;
> }
>
> - // \brief Record occurrences of function and non-type template parameter
> - // packs in a block-captured expression.
> - bool VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
> - if (E->getDecl()->isParameterPack())
> - Unexpanded.push_back(std::make_pair(E->getDecl(), E->getLocation()));
> -
> - return true;
> - }
> -
> /// \brief Record occurrences of template template parameter packs.
> bool TraverseTemplateName(TemplateName Template) {
> if (TemplateTemplateParmDecl *TTP
>
> Modified: cfe/trunk/lib/Sema/TreeTransform.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/TreeTransform.h (original)
> +++ cfe/trunk/lib/Sema/TreeTransform.h Sat Mar 10 03:33:50 2012
> @@ -2399,7 +2399,8 @@
> // Build a reference to the __builtin_shufflevector builtin
> FunctionDecl *Builtin = cast<FunctionDecl>(*Lookup.first);
> ExprResult Callee
> - = SemaRef.Owned(new (SemaRef.Context) DeclRefExpr(Builtin, Builtin->getType(),
> + = SemaRef.Owned(new (SemaRef.Context) DeclRefExpr(Builtin, false,
> + Builtin->getType(),
> VK_LValue, BuiltinLoc));
> Callee = SemaRef.UsualUnaryConversions(Callee.take());
> if (Callee.isInvalid())
> @@ -8770,29 +8771,6 @@
>
> template<typename Derived>
> ExprResult
> -TreeTransform<Derived>::TransformBlockDeclRefExpr(BlockDeclRefExpr *E) {
> - ValueDecl *ND
> - = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
> - E->getDecl()));
> - if (!ND)
> - return ExprError();
> -
> - if (!getDerived().AlwaysRebuild() &&
> - ND == E->getDecl()) {
> - // Mark it referenced in the new context regardless.
> - // FIXME: this is a bit instantiation-specific.
> - SemaRef.MarkBlockDeclRefReferenced(E);
> -
> - return SemaRef.Owned(E);
> - }
> -
> - DeclarationNameInfo NameInfo(E->getDecl()->getDeclName(), E->getLocation());
> - return getDerived().RebuildDeclRefExpr(NestedNameSpecifierLoc(),
> - ND, NameInfo, 0);
> -}
> -
> -template<typename Derived>
> -ExprResult
> TreeTransform<Derived>::TransformAsTypeExpr(AsTypeExpr *E) {
> llvm_unreachable("Cannot transform asType expressions yet");
> }
>
> Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Sat Mar 10 03:33:50 2012
> @@ -333,6 +333,7 @@
> E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
> E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record[Idx++];
> E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
> + E->DeclRefExprBits.RefersToEnclosingLocal = Record[Idx++];
> unsigned NumTemplateArgs = 0;
> if (E->hasTemplateKWAndArgsInfo())
> NumTemplateArgs = Record[Idx++];
> @@ -752,14 +753,6 @@
> E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
> }
>
> -void ASTStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
> - VisitExpr(E);
> - E->setDecl(ReadDeclAs<VarDecl>(Record, Idx));
> - E->setLocation(ReadSourceLocation(Record, Idx));
> - E->setByRef(Record[Idx++]);
> - E->setConstQualAdded(Record[Idx++]);
> -}
> -
> void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
> VisitExpr(E);
> E->NumAssocs = Record[Idx++];
> @@ -1703,7 +1696,7 @@
> /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
> /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
> /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
> - Record[ASTStmtReader::NumExprFields + 4] : 0);
> + Record[ASTStmtReader::NumExprFields + 5] : 0);
> break;
>
> case EXPR_INTEGER_LITERAL:
> @@ -1882,10 +1875,6 @@
> S = new (Context) BlockExpr(Empty);
> break;
>
> - case EXPR_BLOCK_DECL_REF:
> - S = new (Context) BlockDeclRefExpr(Empty);
> - break;
> -
> case EXPR_GENERIC_SELECTION:
> S = new (Context) GenericSelectionExpr(Empty);
> break;
>
> Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTWriter.cpp Sat Mar 10 03:33:50 2012
> @@ -693,7 +693,6 @@
> RECORD(EXPR_GNU_NULL);
> RECORD(EXPR_SHUFFLE_VECTOR);
> RECORD(EXPR_BLOCK);
> - RECORD(EXPR_BLOCK_DECL_REF);
> RECORD(EXPR_GENERIC_SELECTION);
> RECORD(EXPR_OBJC_STRING_LITERAL);
> RECORD(EXPR_OBJC_NUMERIC_LITERAL);
>
> Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Sat Mar 10 03:33:50 2012
> @@ -1553,6 +1553,7 @@
> Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //GetDeclFound
> Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ExplicitTemplateArgs
> Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HadMultipleCandidates
> + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //RefersToEnclosingLocal
> Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
> Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
> DeclRefExprAbbrev = Stream.EmitAbbrev(Abv);
>
> Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Sat Mar 10 03:33:50 2012
> @@ -266,6 +266,7 @@
> Record.push_back(E->getDecl() != E->getFoundDecl());
> Record.push_back(E->hasTemplateKWAndArgsInfo());
> Record.push_back(E->hadMultipleCandidates());
> + Record.push_back(E->refersToEnclosingLocal());
>
> if (E->hasTemplateKWAndArgsInfo()) {
> unsigned NumTemplateArgs = E->getNumTemplateArgs();
> @@ -712,15 +713,6 @@
> Code = serialization::EXPR_BLOCK;
> }
>
> -void ASTStmtWriter::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
> - VisitExpr(E);
> - Writer.AddDeclRef(E->getDecl(), Record);
> - Writer.AddSourceLocation(E->getLocation(), Record);
> - Record.push_back(E->isByRef());
> - Record.push_back(E->isConstQualAdded());
> - Code = serialization::EXPR_BLOCK_DECL_REF;
> -}
> -
> void ASTStmtWriter::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
> VisitExpr(E);
> Record.push_back(E->getNumAssocs());
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp Sat Mar 10 03:33:50 2012
> @@ -650,7 +650,6 @@
> case Stmt::InitListExprClass:
> case Stmt::DesignatedInitExprClass:
> case Stmt::BlockExprClass:
> - case Stmt::BlockDeclRefExprClass:
> return false;
>
> // Cases requiring custom logic
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp Sat Mar 10 03:33:50 2012
> @@ -33,16 +33,16 @@
> };
> } // end anonymous namespace
>
> -static const BlockDeclRefExpr *FindBlockDeclRefExpr(const Stmt *S,
> - const VarDecl *VD){
> - if (const BlockDeclRefExpr *BR = dyn_cast<BlockDeclRefExpr>(S))
> +static const DeclRefExpr *FindBlockDeclRefExpr(const Stmt *S,
> + const VarDecl *VD) {
> + if (const DeclRefExpr *BR = dyn_cast<DeclRefExpr>(S))
> if (BR->getDecl() == VD)
> return BR;
>
> for (Stmt::const_child_iterator I = S->child_begin(), E = S->child_end();
> I!=E; ++I)
> if (const Stmt *child = *I) {
> - const BlockDeclRefExpr *BR = FindBlockDeclRefExpr(child, VD);
> + const DeclRefExpr *BR = FindBlockDeclRefExpr(child, VD);
> if (BR)
> return BR;
> }
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Sat Mar 10 03:33:50 2012
> @@ -670,14 +670,6 @@
> Bldr.addNodes(Dst);
> break;
>
> - case Stmt::BlockDeclRefExprClass: {
> - Bldr.takeNodes(Pred);
> - const BlockDeclRefExpr *BE = cast<BlockDeclRefExpr>(S);
> - VisitCommonDeclRefExpr(BE, BE->getDecl(), Pred, Dst);
> - Bldr.addNodes(Dst);
> - break;
> - }
> -
> case Stmt::BlockExprClass:
> Bldr.takeNodes(Pred);
> VisitBlockExpr(cast<BlockExpr>(S), Pred, Dst);
>
> Modified: cfe/trunk/tools/libclang/CIndex.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/tools/libclang/CIndex.cpp (original)
> +++ cfe/trunk/tools/libclang/CIndex.cpp Sat Mar 10 03:33:50 2012
> @@ -2819,8 +2819,6 @@
>
> if (DeclRefExpr *RefExpr = dyn_cast<DeclRefExpr>(E))
> return RefExpr->getDecl();
> - if (BlockDeclRefExpr *RefExpr = dyn_cast<BlockDeclRefExpr>(E))
> - return RefExpr->getDecl();
> if (MemberExpr *ME = dyn_cast<MemberExpr>(E))
> return ME->getMemberDecl();
> if (ObjCIvarRefExpr *RE = dyn_cast<ObjCIvarRefExpr>(E))
> @@ -2862,8 +2860,6 @@
> return /*FIXME:*/Msg->getLeftLoc();
> if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
> return DRE->getLocation();
> - if (BlockDeclRefExpr *RefExpr = dyn_cast<BlockDeclRefExpr>(E))
> - return RefExpr->getLocation();
> if (MemberExpr *Member = dyn_cast<MemberExpr>(E))
> return Member->getMemberLoc();
> if (ObjCIvarRefExpr *Ivar = dyn_cast<ObjCIvarRefExpr>(E))
>
> Modified: cfe/trunk/tools/libclang/CXCursor.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=152491&r1=152490&r2=152491&view=diff
> ==============================================================================
> --- cfe/trunk/tools/libclang/CXCursor.cpp (original)
> +++ cfe/trunk/tools/libclang/CXCursor.cpp Sat Mar 10 03:33:50 2012
> @@ -420,7 +420,6 @@
> K = CXCursor_SizeOfPackExpr;
> break;
>
> - case Stmt::BlockDeclRefExprClass:
> case Stmt::DeclRefExprClass:
> case Stmt::DependentScopeDeclRefExprClass:
> case Stmt::SubstNonTypeTemplateParmExprClass:
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list