first wave of fixes for @encode sema support.  This is part of PR3648.

The big difference here is that (like string literal) @encode has 
array type, not pointer type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65391 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 3aea3e3..d551eac 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -478,7 +478,8 @@
 
   // the type looks fine, now check the expression
   switch (getStmtClass()) {
-  case StringLiteralClass: // C99 6.5.1p4
+  case StringLiteralClass:  // C99 6.5.1p4
+  case ObjCEncodeExprClass: // @encode behaves like its string in every way.
     return LV_Valid;
   case ArraySubscriptExprClass: // C99 6.5.3p4 (e1[e2] == (*((e1)+(e2))))
     // For vectors, make sure base is an lvalue (i.e. not a function call).
@@ -829,6 +830,7 @@
   switch (getStmtClass()) {
   default: break;
   case StringLiteralClass:
+  case ObjCEncodeExprClass:
     return true;
   case CompoundLiteralExprClass: {
     // This handles gcc's extension that allows global initializers like
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index bfba598..65a107b 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -153,6 +153,7 @@
   APValue VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
   APValue VisitMemberExpr(MemberExpr *E);
   APValue VisitStringLiteral(StringLiteral *E) { return APValue(E, 0); }
+  APValue VisitObjCEncodeExpr(ObjCEncodeExpr *E) { return APValue(E, 0); }
   APValue VisitArraySubscriptExpr(ArraySubscriptExpr *E);
   APValue VisitUnaryDeref(UnaryOperator *E);
   // FIXME: Missing: __extension__, __real__, __imag__, __builtin_choose_expr