Refactor code so that isIntegerConstantExpr has an ASTContext available.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39884 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index aebc266..baa5464 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -41,7 +41,7 @@
   // Verify that the size of the array is an integer constant expr.
   SourceLocation Loc;
   llvm::APSInt SizeVal(32);
-  if (!Size->isIntegerConstantExpr(SizeVal, &Loc)) {
+  if (!Size->isIntegerConstantExpr(SizeVal, Context, &Loc)) {
     // FIXME: This emits the diagnostic to enforce 6.7.2.1p8, but the message
     // is wrong.  It is also wrong for static variables.
     // FIXME: This is also wrong for:
@@ -879,7 +879,7 @@
   if (Val) {
     // C99 6.7.2.2p2: Make sure we have an integer constant expression.
     SourceLocation ExpLoc;
-    if (!Val->isIntegerConstantExpr(EnumVal, &ExpLoc)) {
+    if (!Val->isIntegerConstantExpr(EnumVal, Context, &ExpLoc)) {
       Diag(ExpLoc, diag::err_enum_value_not_integer_constant_expr, 
            Id->getName());
       // FIXME: Don't leak memory: delete Val;
@@ -981,7 +981,7 @@
   }
   Expr *sizeExpr = static_cast<Expr *>(rawAttr->getArg(0));
   llvm::APSInt vecSize(32);
-  if (!sizeExpr->isIntegerConstantExpr(vecSize)) {
+  if (!sizeExpr->isIntegerConstantExpr(vecSize, Context)) {
     Diag(rawAttr->getAttributeLoc(), diag::err_attribute_vector_size_not_int,
          sizeExpr->getSourceRange());
     return QualType();
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index cde73ce..8029e82 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -439,7 +439,7 @@
         break;
       case PointerFromInt:
         // check for null pointer constant (C99 6.3.2.3p3)
-        if (!argExpr->isNullPointerConstant()) {
+        if (!argExpr->isNullPointerConstant(Context)) {
           Diag(l, diag::ext_typecheck_passing_pointer_int, 
                lhsType.getAsString(), rhsType.getAsString(),
                funcExpr->getSourceRange(), argExpr->getSourceRange());
@@ -513,9 +513,10 @@
       return QualType();
     }
   }
-  if (lexT->isPointerType() && rex->isNullPointerConstant()) // C99 6.5.15p3
+  // C99 6.5.15p3
+  if (lexT->isPointerType() && rex->isNullPointerConstant(Context))
     return lexT;
-  if (rexT->isPointerType() && lex->isNullPointerConstant())
+  if (rexT->isPointerType() && lex->isNullPointerConstant(Context))
     return rexT;
     
   if (lexT->isPointerType() && rexT->isPointerType()) { // C99 6.5.15p3,6
@@ -885,14 +886,14 @@
     if (rType->isPointerType())
       return Context.IntTy;
     if (rType->isIntegerType()) {
-      if (!rex->isNullPointerConstant())
+      if (!rex->isNullPointerConstant(Context))
         Diag(loc, diag::ext_typecheck_comparison_of_pointer_integer,
              lex->getSourceRange(), rex->getSourceRange());
       return Context.IntTy; // the previous diagnostic is a GCC extension.
     }
   } else if (rType->isPointerType()) {
     if (lType->isIntegerType()) {
-      if (!lex->isNullPointerConstant())
+      if (!lex->isNullPointerConstant(Context))
         Diag(loc, diag::ext_typecheck_comparison_of_pointer_integer,
              lex->getSourceRange(), rex->getSourceRange());
       return Context.IntTy; // the previous diagnostic is a GCC extension.
@@ -915,14 +916,14 @@
     if (rType->isPointerType())
       return Context.IntTy;
     if (rType->isIntegerType()) {
-      if (!rex->isNullPointerConstant())
+      if (!rex->isNullPointerConstant(Context))
         Diag(loc, diag::ext_typecheck_comparison_of_pointer_integer,
              lex->getSourceRange(), rex->getSourceRange());
       return Context.IntTy; // the previous diagnostic is a GCC extension.
     }
   } else if (rType->isPointerType()) {
     if (lType->isIntegerType()) {
-      if (!lex->isNullPointerConstant())
+      if (!lex->isNullPointerConstant(Context))
         Diag(loc, diag::ext_typecheck_comparison_of_pointer_integer,
              lex->getSourceRange(), rex->getSourceRange());
       return Context.IntTy; // the previous diagnostic is a GCC extension.
@@ -1015,7 +1016,7 @@
     break;
   case PointerFromInt:
     // check for null pointer constant (C99 6.3.2.3p3)
-    if (compoundType.isNull() && !rex->isNullPointerConstant()) {
+    if (compoundType.isNull() && !rex->isNullPointerConstant(Context)) {
       Diag(loc, diag::ext_typecheck_assign_pointer_int,
            lhsType.getAsString(), rhsType.getAsString(),
            lex->getSourceRange(), rex->getSourceRange());
diff --git a/Sema/SemaStmt.cpp b/Sema/SemaStmt.cpp
index 7333dd5..ce3f750 100644
--- a/Sema/SemaStmt.cpp
+++ b/Sema/SemaStmt.cpp
@@ -58,7 +58,7 @@
     
   SourceLocation ExpLoc;
   // C99 6.8.4.2p3: The expression shall be an integer constant.
-  if (!LHSVal->isIntegerConstantExpr(&ExpLoc))
+  if (!LHSVal->isIntegerConstantExpr(Context, &ExpLoc))
     return Diag(ExpLoc, diag::err_case_label_not_integer_constant_expr,
                 LHSVal->getSourceRange());
 
@@ -269,7 +269,7 @@
     break;
   case PointerFromInt:
     // check for null pointer constant (C99 6.3.2.3p3)
-    if (!RetValExp->isNullPointerConstant()) {
+    if (!RetValExp->isNullPointerConstant(Context)) {
       Diag(ReturnLoc, diag::ext_typecheck_return_pointer_int,
            lhsType.getAsString(), rhsType.getAsString(),
            RetValExp->getSourceRange());