r275466 - [arcmt/objcmt] Fix ParentMap crash with invalid code.
Argyrios Kyrtzidis via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 14 13:21:16 PDT 2016
Author: akirtzidis
Date: Thu Jul 14 15:21:16 2016
New Revision: 275466
URL: http://llvm.org/viewvc/llvm-project?rev=275466&view=rev
Log:
[arcmt/objcmt] Fix ParentMap crash with invalid code.
rdar://22489560
Added:
cfe/trunk/test/ARCMT/objcmt-invalid-code.mm
cfe/trunk/test/ARCMT/objcmt-invalid-code.mm.result
Modified:
cfe/trunk/lib/AST/ParentMap.cpp
Modified: cfe/trunk/lib/AST/ParentMap.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ParentMap.cpp?rev=275466&r1=275465&r2=275466&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ParentMap.cpp (original)
+++ cfe/trunk/lib/AST/ParentMap.cpp Thu Jul 14 15:21:16 2016
@@ -28,6 +28,8 @@ enum OpaqueValueMode {
static void BuildParentMap(MapTy& M, Stmt* S,
OpaqueValueMode OVMode = OV_Transparent) {
+ if (!S)
+ return;
switch (S->getStmtClass()) {
case Stmt::PseudoObjectExprClass: {
Added: cfe/trunk/test/ARCMT/objcmt-invalid-code.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-invalid-code.mm?rev=275466&view=auto
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-invalid-code.mm (added)
+++ cfe/trunk/test/ARCMT/objcmt-invalid-code.mm Thu Jul 14 15:21:16 2016
@@ -0,0 +1,19 @@
+// REQUIRES: x86-registered-target
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only %s -verify
+// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+
+// Make sure there is no crash.
+
+ at interface NSObject @end
+ at interface NSNumber : NSObject
+ at end
+
+ at interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithInt:(int)value;
+ at end
+
+void foo(int x = undeclared) { // expected-error {{undeclared}}
+ NSNumber *n = [NSNumber numberWithInt:1];
+}
Added: cfe/trunk/test/ARCMT/objcmt-invalid-code.mm.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-invalid-code.mm.result?rev=275466&view=auto
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-invalid-code.mm.result (added)
+++ cfe/trunk/test/ARCMT/objcmt-invalid-code.mm.result Thu Jul 14 15:21:16 2016
@@ -0,0 +1,19 @@
+// REQUIRES: x86-registered-target
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only %s -verify
+// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+
+// Make sure there is no crash.
+
+ at interface NSObject @end
+ at interface NSNumber : NSObject
+ at end
+
+ at interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithInt:(int)value;
+ at end
+
+void foo(int x = undeclared) { // expected-error {{undeclared}}
+ NSNumber *n = @1;
+}
More information about the cfe-commits
mailing list