Fix crash with -ast-dump=json (#137324)
When given an invalid Objective-C extension, Clang would crash when trying to emit the mangled name of the method to the JSON dump output. Fixes #137320
This commit is contained in:
parent
0b5daeb2e5
commit
c5bf901b1b
@ -220,6 +220,8 @@ Non-comprehensive list of changes in this release
|
|||||||
- Added `__builtin_elementwise_exp10`.
|
- Added `__builtin_elementwise_exp10`.
|
||||||
- For AMDPGU targets, added `__builtin_v_cvt_off_f32_i4` that maps to the `v_cvt_off_f32_i4` instruction.
|
- For AMDPGU targets, added `__builtin_v_cvt_off_f32_i4` that maps to the `v_cvt_off_f32_i4` instruction.
|
||||||
- Added `__builtin_elementwise_minnum` and `__builtin_elementwise_maxnum`.
|
- Added `__builtin_elementwise_minnum` and `__builtin_elementwise_maxnum`.
|
||||||
|
- No longer crashing on invalid Objective-C categories and extensions when
|
||||||
|
dumping the AST as JSON. (#GH137320)
|
||||||
|
|
||||||
New Compiler Flags
|
New Compiler Flags
|
||||||
------------------
|
------------------
|
||||||
|
@ -367,9 +367,11 @@ void MangleContext::mangleObjCMethodName(const ObjCMethodDecl *MD,
|
|||||||
}
|
}
|
||||||
OS << (MD->isInstanceMethod() ? '-' : '+') << '[';
|
OS << (MD->isInstanceMethod() ? '-' : '+') << '[';
|
||||||
if (const auto *CID = MD->getCategory()) {
|
if (const auto *CID = MD->getCategory()) {
|
||||||
OS << CID->getClassInterface()->getName();
|
if (const auto *CI = CID->getClassInterface()) {
|
||||||
if (includeCategoryNamespace) {
|
OS << CI->getName();
|
||||||
OS << '(' << *CID << ')';
|
if (includeCategoryNamespace) {
|
||||||
|
OS << '(' << *CID << ')';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (const auto *CD =
|
} else if (const auto *CD =
|
||||||
dyn_cast<ObjCContainerDecl>(MD->getDeclContext())) {
|
dyn_cast<ObjCContainerDecl>(MD->getDeclContext())) {
|
||||||
|
14
clang/test/AST/ast-crash-dump-mangled-name-json.m
Normal file
14
clang/test/AST/ast-crash-dump-mangled-name-json.m
Normal file
@ -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]",
|
Loading…
x
Reference in New Issue
Block a user