Introduce a single AST node SizeOfAlignOfExpr for all sizeof and alignof expressions, both of values and types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59057 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 1201064..99fa8d5 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -222,14 +222,10 @@
   bool VisitCastExpr(CastExpr* E) {
     return HandleCast(E->getLocStart(), E->getSubExpr(), E->getType());
   }
-  bool VisitSizeOfAlignOfTypeExpr(const SizeOfAlignOfTypeExpr *E) {
-    return EvaluateSizeAlignOf(E->isSizeOf(), E->getArgumentType(),
-                               E->getType());
-  }
-    
+  bool VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E);
+
 private:
   bool HandleCast(SourceLocation CastLoc, Expr *SubExpr, QualType DestType);
-  bool EvaluateSizeAlignOf(bool isSizeOf, QualType SrcTy, QualType DstTy);
 };
 } // end anonymous namespace
 
@@ -426,14 +422,16 @@
   return true;
 }
 
-/// EvaluateSizeAlignOf - Evaluate sizeof(SrcTy) or alignof(SrcTy) with a result
-/// as a DstTy type.
-bool IntExprEvaluator::EvaluateSizeAlignOf(bool isSizeOf, QualType SrcTy,
-                                           QualType DstTy) {
+/// VisitSizeAlignOfExpr - Evaluate a sizeof or alignof with a result as the
+/// expression's type.
+bool IntExprEvaluator::VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E) {
+  QualType DstTy = E->getType();
   // Return the result in the right width.
   Result.zextOrTrunc(getIntTypeSizeInBits(DstTy));
   Result.setIsUnsigned(DstTy->isUnsignedIntegerType());
 
+  QualType SrcTy = E->getTypeOfArgument();
+
   // sizeof(void) and __alignof__(void) = 1 as a gcc extension.
   if (SrcTy->isVoidType())
     Result = 1;
@@ -443,6 +441,8 @@
     // FIXME: Should we attempt to evaluate this?
     return false;
   }
+
+  bool isSizeOf = E->isSizeOf();
   
   // GCC extension: sizeof(function) = 1.
   if (SrcTy->isFunctionType()) {
@@ -470,10 +470,6 @@
     return true;
   }
   
-  if (E->isSizeOfAlignOfOp())
-    return EvaluateSizeAlignOf(E->getOpcode() == UnaryOperator::SizeOf,
-                               E->getSubExpr()->getType(), E->getType());
-  
   // Get the operand value into 'Result'.
   if (!Visit(E->getSubExpr()))
     return false;