Fix code to mark block variables as const to actually work.  Fix 
isObjCObjectPointerType to work with qualified types.  Adjust test for 
changes.

If the SemaExpr changes are wrong or break existing code, feel free to 
delete the "ExprTy.addConst();" line and revert my changes to 
test/Sema/block-literal.c.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67489 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 079ff74..3220a9e 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -932,15 +932,14 @@
     // Blocks that have these can't be constant.
     CurBlock->hasBlockDeclRefExprs = true;
 
+    QualType ExprTy = VD->getType().getNonReferenceType();
     // The BlocksAttr indicates the variable is bound by-reference.
     if (VD->getAttr<BlocksAttr>())
-      return Owned(new (Context) BlockDeclRefExpr(VD, 
-                               VD->getType().getNonReferenceType(), Loc, true));
+      return Owned(new (Context) BlockDeclRefExpr(VD, ExprTy, Loc, true));
 
     // Variable will be bound by-copy, make it const within the closure.
-    VD->getType().addConst();
-    return Owned(new (Context) BlockDeclRefExpr(VD, 
-                             VD->getType().getNonReferenceType(), Loc, false));
+    ExprTy.addConst();
+    return Owned(new (Context) BlockDeclRefExpr(VD, ExprTy, Loc, false));
   }
   // If this reference is not in a block or if the referenced variable is
   // within the block, create a normal DeclRefExpr.