Change self/_cmd to be instances of ImplicitParamDecl instead of ParmVarDecl.
Patch by David Chisnall!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52422 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 5856531..9420f95 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -370,7 +370,8 @@
 LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
   const VarDecl *VD = dyn_cast<VarDecl>(E->getDecl());
   
-  if (VD && (VD->isBlockVarDecl() || isa<ParmVarDecl>(VD))) {
+  if (VD && (VD->isBlockVarDecl() || isa<ParmVarDecl>(VD) ||
+        isa<ImplicitParamDecl>(VD))) {
     if (VD->getStorageClass() == VarDecl::Extern)
       return LValue::MakeAddr(CGM.GetAddrOfGlobalVar(VD, false),
                               E->getType().getCVRQualifiers());
@@ -386,6 +387,12 @@
     return LValue::MakeAddr(CGM.GetAddrOfFunctionDecl(FD, false),
                             E->getType().getCVRQualifiers());
   }
+  else if (const ImplicitParamDecl *IPD =
+      dyn_cast<ImplicitParamDecl>(E->getDecl())) {
+    llvm::Value *V = LocalDeclMap[IPD];
+    assert(V && "BlockVarDecl not entered in LocalDeclMap?");
+    return LValue::MakeAddr(V, E->getType().getCVRQualifiers());
+  }
   assert(0 && "Unimp declref");
   //an invalid LValue, but the assert will
   //ensure that this point is never reached.