-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Fix crash with -ast-dump=json #137324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crash with -ast-dump=json #137324
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -367,9 +367,11 @@ void MangleContext::mangleObjCMethodName(const ObjCMethodDecl *MD, | |
| } | ||
| OS << (MD->isInstanceMethod() ? '-' : '+') << '['; | ||
| if (const auto *CID = MD->getCategory()) { | ||
| OS << CID->getClassInterface()->getName(); | ||
| if (includeCategoryNamespace) { | ||
| OS << '(' << *CID << ')'; | ||
| if (const auto *CI = CID->getClassInterface()) { | ||
| OS << CI->getName(); | ||
| if (includeCategoryNamespace) { | ||
| OS << '(' << *CID << ')'; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we still try to emit the category name (
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea; what does Objective-C expect? CC @rjmccall ?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought It probably doesn't matter too much. |
||
| } | ||
| } | ||
| } else if (const auto *CD = | ||
| dyn_cast<ObjCContainerDecl>(MD->getDeclContext())) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // RUN: not %clang_cc1 -ast-dump=json %s 2>&1 | FileCheck %s | ||
|
|
||
| // Ensure that dumping this does not crash when emitting the mangled name. | ||
| // See GH137320 for details. | ||
| // Note, this file does not compile and so we also check the error. | ||
|
|
||
| @interface SomeClass (SomeExtension) | ||
| + (void)someMethod; | ||
| @end | ||
|
|
||
| // CHECK: error: cannot find interface declaration for 'SomeClass' | ||
|
|
||
| // CHECK: "name": "someMethod" | ||
| // CHECK-NEXT: "mangledName": "+[ someMethod]", |
Uh oh!
There was an error while loading. Please reload this page.