r229402 - Fix crash when clang tries to build NSNumber literal after forward declaration
jahanian
fjahanian at apple.com
Mon Feb 16 11:26:54 PST 2015
> On Feb 16, 2015, at 8:17 AM, Alex Denisov <1101.debian at gmail.com> wrote:
>
> Author: alexdenisov
> Date: Mon Feb 16 10:17:05 2015
> New Revision: 229402
>
> URL: http://llvm.org/viewvc/llvm-project?rev=229402&view=rev
> Log:
> Fix crash when clang tries to build NSNumber literal after forward declaration
>
> Bug report: http://llvm.org/bugs/show_bug.cgi?id=22561
>
> Clang tries to create ObjCBoxedExpression of type 'NSNumber'
> when 'NSNumber' has only forward declaration, this cause a crash later,
> when 'Sema' refers to a nil QualType of the whole expression.
> Please, refer to the bug report for the better explanation.
>
>
> Modified:
> cfe/trunk/lib/Sema/SemaExprObjC.cpp
> cfe/trunk/test/SemaObjC/objc-literal-nsnumber.m
>
> Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=229402&r1=229401&r2=229402&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Mon Feb 16 10:17:05 2015
> @@ -218,7 +218,9 @@ static ObjCMethodDecl *getNSNumberFactor
> S.Diag(Loc, diag::err_undeclared_nsnumber);
> return nullptr;
> }
> -
> + }
> +
> + if (S.NSNumberPointer.isNull()) {
Creation of NSNumberPointer should go inside if (!S.NSNumberDecl)
which is right before this code.
- Fariborz
> // generate the pointer to NSNumber type.
> QualType NSNumberObject = CX.getObjCInterfaceType(S.NSNumberDecl);
> S.NSNumberPointer = CX.getObjCObjectPointerType(NSNumberObject);
>
> Modified: cfe/trunk/test/SemaObjC/objc-literal-nsnumber.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objc-literal-nsnumber.m?rev=229402&r1=229401&r2=229402&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaObjC/objc-literal-nsnumber.m (original)
> +++ cfe/trunk/test/SemaObjC/objc-literal-nsnumber.m Mon Feb 16 10:17:05 2015
> @@ -9,6 +9,24 @@ typedef unsigned int NSUInteger;
> typedef int NSInteger;
> #endif
>
> +void checkNSNumberUnavailableDiagnostic() {
> + id num = @1000; // expected-error {{NSNumber must be available to use Objective-C literals}}
> +
> + int x = 1000;
> + id num1 = @(x); // expected-error {{NSNumber must be available to use Objective-C literals}}\
> + // expected-error {{illegal type 'int' used in a boxed expression}}
> +}
> +
> + at class NSNumber;
> +
> +void checkNSNumberFDDiagnostic() {
> + id num = @1000; // expected-error {{NSNumber must be available to use Objective-C literals}}
> +
> + int x = 1000;
> + id num1 = @(x); // expected-error {{declaration of 'numberWithInt:' is missing in NSNumber class}}\
> + // expected-error {{illegal type 'int' used in a boxed expression}}
> +}
> +
> @interface NSObject
> + (NSObject*)nsobject;
> @end
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150216/089754ff/attachment.html>
More information about the cfe-commits
mailing list