mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-05-14 01:46:41 +00:00

For each selector encountered in the source code, we need to load selectors from the imported modules and check that we are calling a selector with compatible types. At the moment, for each module we are storing methods declared in the headers belonging to this module and methods from the transitive closure of imported modules. When a module is imported by a few other modules, methods from the shared module are duplicated in each importer. As the result, we can end up with lots of identical methods that we try to add to the global method pool. Doing this duplicate work is useless and relatively expensive. Avoid processing duplicate methods by storing in each module only its own methods and not storing methods from dependencies. Collect methods from dependencies by walking the graph of module dependencies. The issue was discovered and reported by Richard Howell. He has done the hard work for this fix as he has investigated and provided a detailed explanation of the performance problem. Differential Revision: https://reviews.llvm.org/D110123
41 lines
1.1 KiB
Objective-C
41 lines
1.1 KiB
Objective-C
// RUN: rm -rf %t
|
|
// RUN: split-file %s %t
|
|
// RUN: %clang_cc1 -Wobjc-multiple-method-names -fsyntax-only -fmodules-cache-path=%t/modules.cache -fmodules -fimplicit-module-maps -F %t/Frameworks %t/test.m -verify
|
|
|
|
// Verify we are handling methods from transitive modules, not just from immediate ones.
|
|
|
|
//--- Frameworks/Indirect.framework/Headers/Indirect.h
|
|
@interface NSObject
|
|
@end
|
|
|
|
@interface Indirect : NSObject
|
|
- (int)method;
|
|
@end
|
|
|
|
//--- Frameworks/Indirect.framework/Modules/module.modulemap
|
|
framework module Indirect {
|
|
header "Indirect.h"
|
|
export *
|
|
}
|
|
|
|
//--- Frameworks/Immediate.framework/Headers/Immediate.h
|
|
#import <Indirect/Indirect.h>
|
|
@interface Immediate : NSObject
|
|
- (void)method;
|
|
@end
|
|
|
|
//--- Frameworks/Immediate.framework/Modules/module.modulemap
|
|
framework module Immediate {
|
|
header "Immediate.h"
|
|
export *
|
|
}
|
|
|
|
//--- test.m
|
|
#import <Immediate/Immediate.h>
|
|
|
|
void test(id obj) {
|
|
[obj method]; // expected-warning{{multiple methods named 'method' found}}
|
|
// expected-note@Frameworks/Indirect.framework/Headers/Indirect.h:5{{using}}
|
|
// expected-note@Frameworks/Immediate.framework/Headers/Immediate.h:3{{also found}}
|
|
}
|