add comments for the various AssignConvertType's, and split int->pointer from pointer->int.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45591 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/Sema.h b/Sema/Sema.h
index e790a74..d8871d2 100644
--- a/Sema/Sema.h
+++ b/Sema/Sema.h
@@ -613,13 +613,39 @@
   // responsible for emitting appropriate error diagnostics.
   QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr,
                                       bool isCompAssign = false);
+  
+  /// AssignConvertType - All of the 'assignment' semantic checks return this
+  /// enum to indicate whether the assignment was allowed.  These checks are
+  /// done for simple assignments, as well as initialization, return from
+  /// function, argument passing, etc.  The query is phrased in terms of a
+  /// source and destination type.
   enum AssignConvertType {
+    /// Compatible - the types are compatible according to the standard.
     Compatible,
-    Incompatible,
-    PointerInt, 
+    
+    /// PointerToInt - The assignment converts a pointer to an int, which we
+    /// accept as an extension.
+    PointerToInt,
+    
+    /// IntToPointer - The assignment converts an int to a pointer, which we
+    /// accept as an extension.
+    IntToPointer,
+    
+    /// FunctionVoidPointer - The assignment is between a function pointer and
+    /// void*, which the standard doesn't allow, but we accept as an extension.
     FunctionVoidPointer,
+
+    /// IncompatiblePointer - The assignment is between two pointers types that
+    /// are not compatible, but we accept them as an extension.
     IncompatiblePointer,
-    CompatiblePointerDiscardsQualifiers
+    
+    /// CompatiblePointerDiscardsQualifiers - The assignment discards
+    /// c/v/r qualifiers, which we accept as an extension.
+    CompatiblePointerDiscardsQualifiers,
+    
+    /// Incompatible - We reject this conversion outright, it is invalid to
+    /// represent it in the AST.
+    Incompatible
   };
   
   /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 7ed0bf1..d41e219 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -1087,8 +1087,6 @@
 ///
 Sema::AssignConvertType
 Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
-
-  
   if (lhsType.getCanonicalType().getUnqualifiedType() == 
       rhsType.getCanonicalType().getUnqualifiedType())
     return Compatible; // common case, fast path...
@@ -1131,14 +1129,14 @@
     return Compatible;
   } else if (lhsType->isPointerType()) {
     if (rhsType->isIntegerType())
-      return PointerInt;
+      return IntToPointer;
       
     if (rhsType->isPointerType())
       return CheckPointerTypesForAssignment(lhsType, rhsType);
   } else if (rhsType->isPointerType()) {
     // C99 6.5.16.1p1: the left operand is _Bool and the right is a pointer.
     if ((lhsType->isIntegerType()) && (lhsType != Context.BoolTy))
-      return PointerInt;
+      return PointerToInt;
 
     if (lhsType->isPointerType()) 
       return CheckPointerTypesForAssignment(lhsType, rhsType);
@@ -2139,9 +2137,12 @@
   switch (ConvTy) {
   default: assert(0 && "Unknown conversion type");
   case Compatible: return false;
-  case PointerInt:
+  case PointerToInt:
     DiagKind = diag::ext_typecheck_convert_pointer_int;
     break;
+  case IntToPointer:
+    DiagKind = diag::ext_typecheck_convert_int_pointer;
+    break;
   case IncompatiblePointer:
     DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
     break;