diff --git a/docs/ObjectiveCLiterals.rst b/docs/ObjectiveCLiterals.rst
index 8907c1e..e003af0 100644
--- a/docs/ObjectiveCLiterals.rst
+++ b/docs/ObjectiveCLiterals.rst
@@ -120,7 +120,8 @@ Objective-C provides a new syntax for boxing C expressions:
     @( <expression> )
 
 Expressions of scalar (numeric, enumerated, BOOL) and C string pointer
-types are supported:
+types are supported, as well as some NSFoundation C structures 
+(e.g. ``NSPoint``, ``NSRect``, etc.):
 
 .. code-block:: objc
 
@@ -136,6 +137,10 @@ types are supported:
     NSString *path = @(getenv("PATH"));       // [NSString stringWithUTF8String:(getenv("PATH"))]
     NSArray *pathComponents = [path componentsSeparatedByString:@":"];
 
+    // NS structs
+    NSValue *center = @(view.center);         // [NSValue valueWithPoint:view.center]
+    NSValue *frame = @(view.frame);           // [NSValue valueWithRect:view.frame]
+
 Boxed Enums
 -----------
 
@@ -218,6 +223,24 @@ character data is valid. Passing ``NULL`` as the character pointer will
 raise an exception at runtime. When possible, the compiler will reject
 ``NULL`` character pointers used in boxed expressions.
 
+Boxed C Structures
+------------------
+
+Some C structures might be boxed into a NSValue using corresponding class' 
+methods:
+
+.. code-block:: objc
+
+    NSPoint p;
+    NSValue *point = @(p);    // valueWithPoint
+    NSSize s;
+    NSValue *size = @(s);     // valueWithSize
+
+Full list of available types if programmer targets:
+
+  - OSX: ``NSPoint``, ``NSSize``, ``NSRect``, ``NSRange``
+  - iOS: ``CGPoint``, ``CGSize``, ``CGRect``, ``NSRange``
+
 Container Literals
 ==================
 
diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h
index 817c0cc..82738da 100644
--- a/include/clang/AST/ExprObjC.h
+++ b/include/clang/AST/ExprObjC.h
@@ -124,6 +124,15 @@ public:
   
   // Iterators
   child_range children() { return child_range(&SubExpr, &SubExpr+1); }
+ 
+  typedef ConstExprIterator const_arg_iterator;
+  
+  const_arg_iterator arg_begin() const {
+    return reinterpret_cast<Stmt const * const*>(&SubExpr);
+  }
+  const_arg_iterator arg_end() const {
+    return reinterpret_cast<Stmt const * const*>(&SubExpr + 1);
+  }
   
   friend class ASTStmtReader;
 };
diff --git a/include/clang/AST/NSAPI.h b/include/clang/AST/NSAPI.h
index 33fcce2..cc91b94 100644
--- a/include/clang/AST/NSAPI.h
+++ b/include/clang/AST/NSAPI.h
@@ -33,9 +33,10 @@ public:
     ClassId_NSMutableArray,
     ClassId_NSDictionary,
     ClassId_NSMutableDictionary,
-    ClassId_NSNumber
+    ClassId_NSNumber,
+    ClassId_NSValue
   };
-  static const unsigned NumClassIds = 7;
+  static const unsigned NumClassIds = 8;
 
   enum NSStringMethodKind {
     NSStr_stringWithString,
@@ -158,11 +159,26 @@ public:
   };
   static const unsigned NumNSNumberLiteralMethods = 15;
 
+  /// \brief Enumerates the NSValue methods used to generate literals.
+  enum NSValueLiteralMethodKind {
+    NSValueWithPoint,
+    NSValueWithSize,
+    NSValueWithRect,
+    NSValueWithCGPoint,
+    NSValueWithCGSize,
+    NSValueWithCGRect,
+    NSValueWithRange
+  };
+  static const unsigned NumNSValueLiteralMethods = 7;
+  
   /// \brief The Objective-C NSNumber selectors used to create NSNumber literals.
   /// \param Instance if true it will return the selector for the init* method
   /// otherwise it will return the selector for the number* method.
   Selector getNSNumberLiteralSelector(NSNumberLiteralMethodKind MK,
                                       bool Instance) const;
+  
+  /// \brief The Objective-C NSValue selectors used to create NSValue literals.
+  Selector getNSValueLiteralSelector(NSValueLiteralMethodKind MK) const;
 
   bool isNSNumberLiteralSelector(NSNumberLiteralMethodKind MK,
                                  Selector Sel) const {
@@ -178,6 +194,11 @@ public:
   /// literal of the given type.
   Optional<NSNumberLiteralMethodKind>
       getNSNumberFactoryMethodKind(QualType T) const;
+  
+  /// \brief Determine the appropriate NSValue factory method kind for a
+  /// literal of the given type.
+  Optional<NSValueLiteralMethodKind>
+      getNSValueFactoryMethodKind(QualType T) const;
 
   /// \brief Returns true if \param T is a typedef of "BOOL" in objective-c.
   bool isObjCBOOLType(QualType T) const;
@@ -185,12 +206,27 @@ public:
   bool isObjCNSIntegerType(QualType T) const;
   /// \brief Returns true if \param T is a typedef of "NSUInteger" in objective-c.
   bool isObjCNSUIntegerType(QualType T) const;
+  /// \brief Returns true if \param T is a typedef of "NSPoint" in objective-c.
+  bool isObjCNSPointType(QualType T) const;
+  /// \brief Returns true if \param T is a typedef of "NSSize" in objective-c.
+  bool isObjCNSSizeType(QualType T) const;
+  /// \brief Returns true if \param T is a typedef of "NSRect" in objective-c.
+  bool isObjCNSRectType(QualType T) const;
+  /// \brief Returns true if \param T is a typedef of "CGPoint" in objective-c.
+  bool isObjCCGPointType(QualType T) const;
+  /// \brief Returns true if \param T is a typedef of "CGSize" in objective-c.
+  bool isObjCCGSizeType(QualType T) const;
+  /// \brief Returns true if \param T is a typedef of "CGRect" in objective-c.
+  bool isObjCCGRectType(QualType T) const;
+  /// \brief Returns true if \param T is a typedef of "NSRange" in objective-c.
+  bool isObjCNSRangeType(QualType T) const;
   /// \brief Returns one of NSIntegral typedef names if \param T is a typedef
   /// of that name in objective-c.
   StringRef GetNSIntegralKind(QualType T) const;
 
 private:
   bool isObjCTypedef(QualType T, StringRef name, IdentifierInfo *&II) const;
+  bool isObjCStructure(QualType T, StringRef name) const;
   bool isObjCEnumerator(const Expr *E,
                         StringRef name, IdentifierInfo *&II) const;
   Selector getOrInitSelector(ArrayRef<StringRef> Ids, Selector &Sel) const;
@@ -210,6 +246,9 @@ private:
   /// \brief The Objective-C NSNumber selectors used to create NSNumber literals.
   mutable Selector NSNumberClassSelectors[NumNSNumberLiteralMethods];
   mutable Selector NSNumberInstanceSelectors[NumNSNumberLiteralMethods];
+  
+  /// \brief The Objective-C NSValue selectors used to create NSValue literals.
+  mutable Selector NSValueClassSelectors[NumNSValueLiteralMethods];
 
   mutable Selector objectForKeyedSubscriptSel, objectAtIndexedSubscriptSel,
                    setObjectForKeyedSubscriptSel,setObjectAtIndexedSubscriptSel,
@@ -217,6 +256,9 @@ private:
 
   mutable IdentifierInfo *BOOLId, *NSIntegerId, *NSUIntegerId;
   mutable IdentifierInfo *NSASCIIStringEncodingId, *NSUTF8StringEncodingId;
+  mutable IdentifierInfo *NSPointId, *NSSizeId, *NSRectId;
+  mutable IdentifierInfo *CGPointId, *CGSizeId, *CGRectId;
+  mutable IdentifierInfo *NSRangeId;
 };
 
 }  // end namespace clang
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 75e78bf..a51193e 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2041,6 +2041,8 @@ def err_attr_objc_ownership_redundant : Error<
   "the type %0 is already explicitly ownership-qualified">;
 def err_undeclared_nsnumber : Error<
   "NSNumber must be available to use Objective-C literals">;
+def err_undeclared_nsvalue : Error<
+  "NSValue must be available to use Objective-C literals">;
 def err_invalid_nsnumber_type : Error<
   "%0 is not a valid literal type for NSNumber">;
 def err_undeclared_nsstring : Error<
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index 0ad86a4..07a33ea 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -660,11 +660,20 @@ public:
   /// \brief The declaration of the Objective-C NSNumber class.
   ObjCInterfaceDecl *NSNumberDecl;
 
+  /// \brief The declaration of the Objective-C NSValue class.
+  ObjCInterfaceDecl *NSValueDecl;
+
   /// \brief Pointer to NSNumber type (NSNumber *).
   QualType NSNumberPointer;
+    
+  /// \brief Pointer to NSValue type (NSValue *).
+  QualType NSValuePointer;
 
   /// \brief The Objective-C NSNumber methods used to create NSNumber literals.
   ObjCMethodDecl *NSNumberLiteralMethods[NSAPI::NumNSNumberLiteralMethods];
+  
+  /// \brief The Objective-C NSValue methods used to create NSValue literals.
+  ObjCMethodDecl *NSValueLiteralMethods[NSAPI::NumNSValueLiteralMethods];
 
   /// \brief The declaration of the Objective-C NSString class.
   ObjCInterfaceDecl *NSStringDecl;
diff --git a/lib/AST/NSAPI.cpp b/lib/AST/NSAPI.cpp
index 3dc750a..55c610e 100644
--- a/lib/AST/NSAPI.cpp
+++ b/lib/AST/NSAPI.cpp
@@ -17,7 +17,9 @@ using namespace clang;
 NSAPI::NSAPI(ASTContext &ctx)
   : Ctx(ctx), ClassIds(), BOOLId(nullptr), NSIntegerId(nullptr),
     NSUIntegerId(nullptr), NSASCIIStringEncodingId(nullptr),
-    NSUTF8StringEncodingId(nullptr) {}
+    NSUTF8StringEncodingId(nullptr), NSPointId(nullptr),
+    NSSizeId(nullptr), NSRectId(nullptr), CGPointId(nullptr),
+    CGSizeId(nullptr), CGRectId(nullptr), NSRangeId(nullptr) {}
 
 IdentifierInfo *NSAPI::getNSClassId(NSClassIdKindKind K) const {
   static const char *ClassName[NumClassIds] = {
@@ -27,7 +29,8 @@ IdentifierInfo *NSAPI::getNSClassId(NSClassIdKindKind K) const {
     "NSMutableArray",
     "NSDictionary",
     "NSMutableDictionary",
-    "NSNumber"
+    "NSNumber",
+    "NSValue"
   };
 
   if (!ClassIds[K])
@@ -279,6 +282,23 @@ Selector NSAPI::getNSNumberLiteralSelector(NSNumberLiteralMethodKind MK,
   return Sels[MK];
 }
 
+Selector NSAPI::getNSValueLiteralSelector(NSValueLiteralMethodKind MK) const {
+  static const char *ClassSelectorName[NumNSValueLiteralMethods] = {
+    "valueWithPoint",
+    "valueWithSize",
+    "valueWithRect",
+    "valueWithCGPoint",
+    "valueWithCGSize",
+    "valueWithCGRect",
+    "valueWithRange",
+  };
+  
+  if (NSValueClassSelectors[MK].isNull())
+    NSValueClassSelectors[MK] =
+      Ctx.Selectors.getUnarySelector(&Ctx.Idents.get(ClassSelectorName[MK]));
+  return NSValueClassSelectors[MK];
+}
+
 Optional<NSAPI::NSNumberLiteralMethodKind>
 NSAPI::getNSNumberLiteralMethodKind(Selector Sel) const {
   for (unsigned i = 0; i != NumNSNumberLiteralMethods; ++i) {
@@ -371,6 +391,30 @@ NSAPI::getNSNumberFactoryMethodKind(QualType T) const {
   return None;
 }
 
+Optional<NSAPI::NSValueLiteralMethodKind>
+NSAPI::getNSValueFactoryMethodKind(QualType T) const {
+  const RecordType *RT = T->getAsStructureType();
+  if (!RT)
+    return None;
+  
+  if (isObjCNSPointType(T))
+    return NSAPI::NSValueWithPoint;
+  if (isObjCNSSizeType(T))
+    return NSAPI::NSValueWithSize;
+  if (isObjCNSRectType(T))
+    return NSAPI::NSValueWithRect;
+  if (isObjCCGPointType(T))
+    return NSAPI::NSValueWithCGPoint;
+  if (isObjCCGSizeType(T))
+    return NSAPI::NSValueWithCGSize;
+  if (isObjCCGRectType(T))
+    return NSAPI::NSValueWithCGRect;
+  if (isObjCNSRangeType(T))
+    return NSAPI::NSValueWithRange;
+  
+  return None;
+}
+
 /// \brief Returns true if \param T is a typedef of "BOOL" in objective-c.
 bool NSAPI::isObjCBOOLType(QualType T) const {
   return isObjCTypedef(T, "BOOL", BOOLId);
@@ -384,6 +428,41 @@ bool NSAPI::isObjCNSUIntegerType(QualType T) const {
   return isObjCTypedef(T, "NSUInteger", NSUIntegerId);
 }
 
+/// \brief Returns true if \param T is a typedef of "NSPoint" in objective-c.
+bool NSAPI::isObjCNSPointType(QualType T) const {
+  return isObjCTypedef(T, "NSPoint", NSPointId);
+}
+
+/// \brief Returns true if \param T is a typedef of "NSSize" in objective-c.
+bool NSAPI::isObjCNSSizeType(QualType T) const {
+  return isObjCTypedef(T, "NSSize", NSSizeId);
+}
+
+/// \brief Returns true if \param T is a typedef of "NSRect" in objective-c.
+bool NSAPI::isObjCNSRectType(QualType T) const {
+  return isObjCTypedef(T, "NSRect", NSRectId);
+}
+
+/// \brief Returns true if \param T is a typedef of "CGPoint" in objective-c.
+bool NSAPI::isObjCCGPointType(QualType T) const {
+  return isObjCTypedef(T, "CGPoint", CGPointId);
+}
+
+/// \brief Returns true if \param T is a typedef of "CGSize" in objective-c.
+bool NSAPI::isObjCCGSizeType(QualType T) const {
+  return isObjCTypedef(T, "CGSize", CGSizeId);
+}
+
+/// \brief Returns true if \param T is a typedef of "CGRect" in objective-c.
+bool NSAPI::isObjCCGRectType(QualType T) const {
+  return isObjCTypedef(T, "CGRect", CGRectId);
+}
+
+/// \brief Returns true if \param T is a typedef of "NSRange" in objective-c.
+bool NSAPI::isObjCNSRangeType(QualType T) const {
+  return isObjCTypedef(T, "NSRange", NSRangeId);
+}
+
 StringRef NSAPI::GetNSIntegralKind(QualType T) const {
   if (!Ctx.getLangOpts().ObjC1 || T.isNull())
     return StringRef();
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index ca67c4b..d2975b8 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -55,12 +55,12 @@ llvm::Value *CodeGenFunction::EmitObjCStringLiteral(const ObjCStringLiteral *E)
 
 /// EmitObjCBoxedExpr - This routine generates code to call
 /// the appropriate expression boxing method. This will either be
-/// one of +[NSNumber numberWith<Type>:], or +[NSString stringWithUTF8String:].
+/// one of +[NSNumber numberWith<Type>:], or +[NSString stringWithUTF8String:],
+/// or [NSValue valueWith<Type>:].
 ///
 llvm::Value *
 CodeGenFunction::EmitObjCBoxedExpr(const ObjCBoxedExpr *E) {
   // Generate the correct selector for this literal's concrete type.
-  const Expr *SubExpr = E->getSubExpr();
   // Get the method.
   const ObjCMethodDecl *BoxingMethod = E->getBoxingMethod();
   assert(BoxingMethod && "BoxingMethod is null");
@@ -73,12 +73,9 @@ CodeGenFunction::EmitObjCBoxedExpr(const ObjCBoxedExpr *E) {
   CGObjCRuntime &Runtime = CGM.getObjCRuntime();
   const ObjCInterfaceDecl *ClassDecl = BoxingMethod->getClassInterface();
   llvm::Value *Receiver = Runtime.GetClass(*this, ClassDecl);
-  
-  const ParmVarDecl *argDecl = *BoxingMethod->param_begin();
-  QualType ArgQT = argDecl->getType().getUnqualifiedType();
-  RValue RV = EmitAnyExpr(SubExpr);
+
   CallArgList Args;
-  Args.add(RV, ArgQT);
+  EmitCallArgs(Args, BoxingMethod, E->arg_begin(), E->arg_end());
 
   RValue result = Runtime.GenerateMessageSend(
       *this, ReturnValueSlot(), BoxingMethod->getReturnType(), Sel, Receiver,
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index 1100dca..854fa0a 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -910,6 +910,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
       .Case("objc_array_literals", LangOpts.ObjC2)
       .Case("objc_dictionary_literals", LangOpts.ObjC2)
       .Case("objc_boxed_expressions", LangOpts.ObjC2)
+      .Case("objc_boxed_nsgeometry_expressions", LangOpts.ObjC2)
       .Case("arc_cf_code_audited", true)
       // C11 features
       .Case("c_alignas", LangOpts.C11)
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index eeee352..f9bdf8f 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -255,6 +255,86 @@ static ObjCMethodDecl *getNSNumberFactoryMethod(Sema &S, SourceLocation Loc,
   return Method;
 }
 
+/// \brief Retrieve the NSValue factory method that should be used to create
+/// an Objective-C literal for the given type.
+static ObjCMethodDecl *getNSValueFactoryMethod(Sema &S, SourceLocation Loc,
+                                               QualType ValueType) {
+  Optional<NSAPI::NSValueLiteralMethodKind> Kind =
+  S.NSAPIObj->getNSValueFactoryMethodKind(ValueType);
+  
+  if (!Kind) {
+    return nullptr;
+  }
+  
+  // If we already looked up this method, we're done.
+  if (S.NSValueLiteralMethods[*Kind])
+    return S.NSValueLiteralMethods[*Kind];
+  
+  Selector Sel = S.NSAPIObj->getNSValueLiteralSelector(*Kind);
+  
+  ASTContext &CX = S.Context;
+  
+  // Look up the NSValue class, if we haven't done so already. It's cached
+  // in the Sema instance.
+  if (!S.NSValueDecl) {
+    IdentifierInfo *NSValueId =
+    S.NSAPIObj->getNSClassId(NSAPI::ClassId_NSValue);
+    NamedDecl *IF = S.LookupSingleName(S.TUScope, NSValueId,
+                                       Loc, Sema::LookupOrdinaryName);
+    S.NSValueDecl = dyn_cast_or_null<ObjCInterfaceDecl>(IF);
+    if (!S.NSValueDecl) {
+      if (S.getLangOpts().DebuggerObjCLiteral) {
+        // Create a stub definition of NSValue.
+        S.NSValueDecl = ObjCInterfaceDecl::Create(CX,
+                                                  CX.getTranslationUnitDecl(),
+                                                  SourceLocation(), NSValueId,
+                                                  nullptr, SourceLocation());
+      } else {
+        // Otherwise, require a declaration of NSValue.
+        S.Diag(Loc, diag::err_undeclared_nsvalue);
+        return nullptr;
+      }
+    } else if (!S.NSValueDecl->hasDefinition()) {
+      S.Diag(Loc, diag::err_undeclared_nsvalue);
+      return nullptr;
+    }
+    
+    // generate the pointer to NSValue type.
+    QualType NSValueObject = CX.getObjCInterfaceType(S.NSValueDecl);
+    S.NSValuePointer = CX.getObjCObjectPointerType(NSValueObject);
+  }
+  
+  // Look for the appropriate method within NSValue.
+  ObjCMethodDecl *Method = S.NSValueDecl->lookupClassMethod(Sel);
+  if (!Method && S.getLangOpts().DebuggerObjCLiteral) {
+    // create a stub definition this NSValue factory method.
+    TypeSourceInfo *ReturnTInfo = nullptr;
+    Method =
+    ObjCMethodDecl::Create(CX, SourceLocation(), SourceLocation(), Sel,
+                           S.NSValuePointer, ReturnTInfo, S.NSValueDecl,
+                           /*isInstance=*/false, /*isVariadic=*/false,
+                           /*isPropertyAccessor=*/false,
+                           /*isImplicitlyDeclared=*/true,
+                           /*isDefined=*/false, ObjCMethodDecl::Required,
+                           /*HasRelatedResultType=*/false);
+    ParmVarDecl *value = ParmVarDecl::Create(S.Context, Method,
+                                             SourceLocation(), SourceLocation(),
+                                             &CX.Idents.get("value"),
+                                             ValueType, /*TInfo=*/nullptr,
+                                             SC_None, nullptr);
+    Method->setMethodParams(S.Context, value, None);
+  }
+  
+  if (!validateBoxingMethod(S, Loc, S.NSValueDecl, Sel, Method))
+    return nullptr;
+  
+  // Note: if the parameter type is out-of-line, we'll catch it later in the
+  // implicit conversion.
+  
+  S.NSValueLiteralMethods[*Kind] = Method;
+  return Method;
+}
+
 /// BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the
 /// numeric literal expression. Type of the expression will be "NSNumber *".
 ExprResult Sema::BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number) {
@@ -527,10 +607,7 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) {
       BoxedType = NSStringPointer;
     }
   } else if (ValueType->isBuiltinType()) {
-    // The other types we support are numeric, char and BOOL/bool. We could also
-    // provide limited support for structure types, such as NSRange, NSRect, and
-    // NSSize. See NSValue (NSValueGeometryExtensions) in <Foundation/NSGeometry.h>
-    // for more details.
+    // The other types we support are numeric, char and BOOL/bool.
 
     // Check for a top-level character literal.
     if (const CharacterLiteral *Char =
@@ -562,6 +639,15 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) {
     BoxingMethod = getNSNumberFactoryMethod(*this, SR.getBegin(), ValueType);
     BoxedType = NSNumberPointer;
 
+  } else if (ValueType->isStructureType()) {
+    // Limited support for structure types, such as NSRange,
+    // NSRect, and NSSize. See NSValue (NSValueGeometryExtensions)
+    // in <Foundation/NSGeometry.h> for more details.
+      
+    // Look for the appropriate method within NSValue.
+    BoxingMethod = getNSValueFactoryMethod(*this, SR.getBegin(), ValueType);
+    BoxedType = NSValuePointer;
+    
   } else if (const EnumType *ET = ValueType->getAs<EnumType>()) {
     if (!ET->getDecl()->isComplete()) {
       Diag(SR.getBegin(), diag::err_objc_incomplete_boxed_expression_type)
diff --git a/test/CodeGenObjC/Inputs/nsvalue-literal-support.h b/test/CodeGenObjC/Inputs/nsvalue-literal-support.h
new file mode 100644
index 0000000..01d7248
--- /dev/null
+++ b/test/CodeGenObjC/Inputs/nsvalue-literal-support.h
@@ -0,0 +1,63 @@
+#ifndef OBJC_NSVALUE_LITERAL_SUPPORT_H
+#define OBJC_NSVALUE_LITERAL_SUPPORT_H
+
+typedef unsigned long NSUInteger;
+typedef double CGFloat;
+
+typedef struct _NSRange {
+    NSUInteger location;
+    NSUInteger length;
+} NSRange;
+
+// OS X Specific
+
+typedef struct _NSPoint {
+    CGFloat x;
+    CGFloat y;
+} NSPoint;
+
+typedef struct _NSSize {
+    CGFloat width;
+    CGFloat height;
+} NSSize;
+
+typedef struct _NSRect {
+    NSPoint origin;
+    NSSize size;
+} NSRect;
+
+// iOS Specific
+
+struct CGPoint {
+  CGFloat x;
+  CGFloat y;
+};
+typedef struct CGPoint CGPoint;
+
+struct CGSize {
+  CGFloat width;
+  CGFloat height;
+};
+typedef struct CGSize CGSize;
+
+struct CGRect {
+  CGPoint origin;
+  CGSize size;
+};
+typedef struct CGRect CGRect;
+
+@interface NSValue
++ (NSValue *)valueWithRange:(NSRange)range;
+
+// OS X Specific
++ (NSValue *)valueWithPoint:(NSPoint)point;
++ (NSValue *)valueWithSize:(NSSize)size;
++ (NSValue *)valueWithRect:(NSRect)rect;
+
+// iOS Specific
++ (NSValue *)valueWithCGPoint:(CGPoint)point;
++ (NSValue *)valueWithCGSize:(CGSize)size;
++ (NSValue *)valueWithCGRect:(CGRect)rect;
+@end
+
+#endif // OBJC_NSVALUE_LITERAL_SUPPORT_H
diff --git a/test/CodeGenObjC/nsvalue-literals.m b/test/CodeGenObjC/nsvalue-literals.m
new file mode 100644
index 0000000..d3ecc11
--- /dev/null
+++ b/test/CodeGenObjC/nsvalue-literals.m
@@ -0,0 +1,154 @@
+// RUN: %clang_cc1 -I %S/Inputs -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+
+#import "nsvalue-literal-support.h"
+
+// CHECK:      [[CLASS:@.*]]      = external global %struct._class_t
+// CHECK:      [[NSVALUE:@.*]]    = {{.*}}[[CLASS]]{{.*}}
+//
+// CHECK:      [[METH:@.*]]       = private global{{.*}}valueWithRange:{{.*}}
+// CHECK-NEXT: [[RANGE_SEL:@.*]]  = {{.*}}[[METH]]{{.*}}
+
+// OS X Specific
+// CHECK:      [[METH:@.*]]       = private global{{.*}}valueWithPoint:{{.*}}
+// CHECK-NEXT: [[POINT_SEL:@.*]]  = {{.*}}[[METH]]{{.*}}
+// CHECK:      [[METH:@.*]]       = private global{{.*}}valueWithSize:{{.*}}
+// CHECK-NEXT: [[SIZE_SEL:@.*]]   = {{.*}}[[METH]]{{.*}}
+// CHECK:      [[METH:@.*]]       = private global{{.*}}valueWithRect:{{.*}}
+// CHECK-NEXT: [[RECT_SEL:@.*]]   = {{.*}}[[METH]]{{.*}}
+
+// iOS Specfific
+// CHECK:      [[METH:@.*]]         = private global{{.*}}valueWithCGPoint:{{.*}}
+// CHECK-NEXT: [[CGPOINT_SEL:@.*]]  = {{.*}}[[METH]]{{.*}}
+// CHECK:      [[METH:@.*]]         = private global{{.*}}valueWithCGSize:{{.*}}
+// CHECK-NEXT: [[CGSIZE_SEL:@.*]]   = {{.*}}[[METH]]{{.*}}
+// CHECK:      [[METH:@.*]]         = private global{{.*}}valueWithCGRect:{{.*}}
+// CHECK-NEXT: [[CGRECT_SEL:@.*]]   = {{.*}}[[METH]]{{.*}}
+
+// CHECK-LABEL: define void @doRange()
+void doRange() {
+  // CHECK:      [[RANGE:%.*]]     = bitcast %struct._NSRange* {{.*}}
+  // CHECK:      [[RECV_PTR:%.*]]  = load {{.*}} [[NSVALUE]]
+  // CHECK:      [[SEL:%.*]]       = load i8** [[RANGE_SEL]]
+  // CHECK:      [[RECV:%.*]]      = bitcast %struct._class_t* [[RECV_PTR]] to i8*
+  // CHECK:      [[RANGE_PTR:%.*]] = bitcast %struct._NSRange* {{.*}}
+  // CHECK-NEXT: [[P1_PTR:%.*]]    = getelementptr {{.*}} [[RANGE_PTR]], i32 0, i32 0
+  // CHECK-NEXT: [[P1:%.*]]        = load i64* [[P1_PTR]], align 1
+  // CHECK-NEXT: [[P2_PTR:%.*]]    = getelementptr {{.*}} [[RANGE_PTR]], i32 0, i32 1
+  // CHECK-NEXT: [[P2:%.*]]        = load i64* [[P2_PTR]], align 1
+  NSRange ns_range = { .location = 0, .length = 42 };
+  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i64 [[P1]], i64 [[P2]])
+  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
+  NSValue *range = @(ns_range);
+  // CHECK:      call void @objc_release
+  // CHECK-NEXT: ret void
+}
+
+// CHECK-LABEL: define void @doPoint()
+void doPoint() {
+  // CHECK:      [[POINT:%.*]]     = bitcast %struct._NSPoint* {{.*}}
+  // CHECK:      [[RECV_PTR:%.*]]  = load {{.*}} [[NSVALUE]]
+  // CHECK:      [[SEL:%.*]]       = load i8** [[POINT_SEL]]
+  // CHECK:      [[RECV:%.*]]      = bitcast %struct._class_t* [[RECV_PTR]] to i8*
+  // CHECK:      [[POINT_PTR:%.*]] = bitcast %struct._NSPoint* {{.*}}
+  // CHECK-NEXT: [[P1_PTR:%.*]]    = getelementptr {{.*}} [[POINT_PTR]], i32 0, i32 0
+  // CHECK-NEXT: [[P1:%.*]]        = load double* [[P1_PTR]], align 1
+  // CHECK-NEXT: [[P2_PTR:%.*]]    = getelementptr {{.*}} [[POINT_PTR]], i32 0, i32 1
+  // CHECK-NEXT: [[P2:%.*]]        = load double* [[P2_PTR]], align 1
+  NSPoint ns_point = { .x = 42, .y = 24 };
+  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], double [[P1]], double [[P2]])
+  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
+  NSValue *point = @(ns_point);
+  // CHECK:      call void @objc_release
+  // CHECK-NEXT: ret void
+}
+
+// CHECK-LABEL: define void @doSize()
+void doSize() {
+  // CHECK:      [[SIZE:%.*]]     = bitcast %struct._NSSize* {{.*}}
+  // CHECK:      [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
+  // CHECK:      [[SEL:%.*]]      = load i8** [[SIZE_SEL]]
+  // CHECK:      [[RECV:%.*]]     = bitcast %struct._class_t* [[RECV_PTR]] to i8*
+  // CHECK:      [[SIZE_PTR:%.*]] = bitcast %struct._NSSize* {{.*}}
+  // CHECK-NEXT: [[P1_PTR:%.*]]   = getelementptr {{.*}} [[SIZE_PTR]], i32 0, i32 0
+  // CHECK-NEXT: [[P1:%.*]]       = load double* [[P1_PTR]], align 1
+  // CHECK-NEXT: [[P2_PTR:%.*]]   = getelementptr {{.*}} [[SIZE_PTR]], i32 0, i32 1
+  // CHECK-NEXT: [[P2:%.*]]       = load double* [[P2_PTR]], align 1
+  NSSize ns_size = { .width = 42, .height = 24 };
+  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], double [[P1]], double [[P2]])
+  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
+  NSValue *size = @(ns_size);
+  // CHECK:      call void @objc_release
+  // CHECK-NEXT: ret void
+}
+
+// CHECK-LABEL: define void @doRect()
+void doRect() {
+  // CHECK:      [[RECT:%.*]]     = alloca %struct._NSRect{{.*}}
+  // CHECK:      [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
+  // CHECK:      [[SEL:%.*]]      = load i8** [[RECT_SEL]]
+  // CHECK:      [[RECV:%.*]]     = bitcast %struct._class_t* [[RECV_PTR]] to i8*
+  NSPoint ns_point = { .x = 42, .y = 24 };
+  NSSize ns_size = { .width = 42, .height = 24 };
+  NSRect ns_rect = { .origin = ns_point, .size = ns_size };
+  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], %struct._NSRect* byval align 8 [[RECT]])
+  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
+  NSValue *rect = @(ns_rect);
+  // CHECK:      call void @objc_release
+  // CHECK-NEXT: ret void
+}
+
+
+// CHECK-LABEL: define void @doCGPoint()
+void doCGPoint() {
+  // CHECK:      [[POINT:%.*]]     = bitcast %struct.CGPoint* {{.*}}
+  // CHECK:      [[RECV_PTR:%.*]]  = load {{.*}} [[NSVALUE]]
+  // CHECK:      [[SEL:%.*]]       = load i8** [[CGPOINT_SEL]]
+  // CHECK:      [[RECV:%.*]]      = bitcast %struct._class_t* [[RECV_PTR]] to i8*
+  // CHECK:      [[POINT_PTR:%.*]] = bitcast %struct.CGPoint* {{.*}}
+  // CHECK-NEXT: [[P1_PTR:%.*]]    = getelementptr {{.*}} [[POINT_PTR]], i32 0, i32 0
+  // CHECK-NEXT: [[P1:%.*]]        = load double* [[P1_PTR]], align 1
+  // CHECK-NEXT: [[P2_PTR:%.*]]    = getelementptr {{.*}} [[POINT_PTR]], i32 0, i32 1
+  // CHECK-NEXT: [[P2:%.*]]        = load double* [[P2_PTR]], align 1
+  CGPoint cg_point = { .x = 42, .y = 24 };
+  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], double [[P1]], double [[P2]])
+  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
+  NSValue *point = @(cg_point);
+  // CHECK:      call void @objc_release
+  // CHECK-NEXT: ret void
+}
+
+// CHECK-LABEL: define void @doCGSize()
+void doCGSize() {
+  // CHECK:      [[SIZE:%.*]]     = bitcast %struct.CGSize* {{.*}}
+  // CHECK:      [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
+  // CHECK:      [[SEL:%.*]]      = load i8** [[CGSIZE_SEL]]
+  // CHECK:      [[RECV:%.*]]     = bitcast %struct._class_t* [[RECV_PTR]] to i8*
+  // CHECK:      [[SIZE_PTR:%.*]] = bitcast %struct.CGSize* {{.*}}
+  // CHECK-NEXT: [[P1_PTR:%.*]]   = getelementptr {{.*}} [[SIZE_PTR]], i32 0, i32 0
+  // CHECK-NEXT: [[P1:%.*]]       = load double* [[P1_PTR]], align 1
+  // CHECK-NEXT: [[P2_PTR:%.*]]   = getelementptr {{.*}} [[SIZE_PTR]], i32 0, i32 1
+  // CHECK-NEXT: [[P2:%.*]]       = load double* [[P2_PTR]], align 1
+  CGSize cg_size = { .width = 42, .height = 24 };
+  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], double [[P1]], double [[P2]])
+  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
+  NSValue *size = @(cg_size);
+  // CHECK:      call void @objc_release
+  // CHECK-NEXT: ret void
+}
+
+// CHECK-LABEL: define void @doCGRect()
+void doCGRect() {
+  // CHECK:      [[RECT:%.*]]     = alloca %struct.CGRect{{.*}}
+  // CHECK:      [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
+  // CHECK:      [[SEL:%.*]]      = load i8** [[CGRECT_SEL]]
+  // CHECK:      [[RECV:%.*]]     = bitcast %struct._class_t* [[RECV_PTR]] to i8*
+  CGPoint cg_point = { .x = 42, .y = 24 };
+  CGSize cg_size = { .width = 42, .height = 24 };
+  CGRect cg_rect = { .origin = cg_point, .size = cg_size };
+  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], %struct.CGRect* byval align 8 [[RECT]])
+  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
+  NSValue *rect = @(cg_rect);
+  // CHECK:      call void @objc_release
+  // CHECK-NEXT: ret void
+}
+
diff --git a/test/SemaObjC/objc-literal-nsvalue.m b/test/SemaObjC/objc-literal-nsvalue.m
new file mode 100644
index 0000000..dd5c781
--- /dev/null
+++ b/test/SemaObjC/objc-literal-nsvalue.m
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1  -fsyntax-only -fblocks -triple x86_64-apple-darwin10 -verify %s
+
+typedef struct _NSPoint {
+  int dummy;
+} NSPoint;
+
+typedef struct _NSSize {
+  int dummy;
+} NSSize;
+
+typedef struct _NSRect {
+  int dummy;
+} NSRect;
+
+typedef struct _CGPoint {
+  int dummy;
+} CGPoint;
+
+typedef struct _CGSize {
+  int dummy;
+} CGSize;
+
+typedef struct _CGRect {
+  int dummy;
+} CGRect;
+
+typedef struct _NSRange {
+  int dummy;
+} NSRange;
+
+typedef struct _SomeStruct {
+  double d;
+} SomeStruct;
+
+@interface NSValue
++ (NSValue *)valueWithPoint:(NSPoint)point;
++ (NSValue *)valueWithSize:(NSSize)size;
++ (NSValue *)valueWithRect:(NSRect)rect;
+
++ (NSValue *)valueWithCGPoint:(CGPoint)point;
++ (NSValue *)valueWithCGSize:(CGSize)size;
++ (NSValue *)valueWithCGRect:(CGRect)rect;
+
++ (NSValue *)valueWithRange:(NSRange)range;
+@end
+
+int main() {
+  NSPoint p;
+  id point = @(p); // no-warning
+
+  NSSize sz;
+  id size = @(sz); // no-warning
+
+  NSRect re;
+  id rect = @(re); // no-warning
+
+  CGPoint cgp;
+  id cgpoint = @(cgp); // no-warning
+
+  CGSize cgsz;
+  id cgsize = @(cgsz); // no-warning
+
+  CGRect cgre;
+  id cgrect = @(cgre); // no-warning
+
+  NSRange rn;
+  id range = @(rn); // no-warning
+
+  SomeStruct s;
+  id err = @(s); // expected-error{{illegal type 'SomeStruct' (aka 'struct _SomeStruct') used in a boxed expression}}
+}
+
