This fixes a bug which causes clang to emit incorrect IR for the following code in C++:
int foo(void) { unsigned a = get_size(); volatile char b[a]; b; return b[0]; }
The code crashes because the destination of the memcpy that is generated to do the lvalue-to-rvalue conversion of discarded-value expression b is incorrect. To fix this bug, I've added a check to Sema which prevents an lvalue cast expression to be emitted if the expression has an array type. My understanding is that lvalue-to-rvalue conversion isn't applied to array type expressions, so I think we should detect this in Sema rather than fixing the code in IRGen that emits the lvalue for the destination of the lvalue-to-rvalue conversion. I've also made changes to Sema::DiagnoseUnusedExprResult so that clang doesn't tell users to assign a reference to a volatile array to a variable to force its value to be loaded.
clang-format: please reformat the code