mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
ModuleObjcMessageTrace: indicate whether a method is instance method or class method
This commit is contained in:
@@ -829,6 +829,15 @@ class ObjcMethodReferenceCollector: public SourceEntityWalker {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static StringRef selectMethodKey(const clang::ObjCMethodDecl* clangD) {
|
||||
assert(clangD);
|
||||
if (clangD->isInstanceMethod())
|
||||
return "instance_method";
|
||||
else if (clangD->isClassMethod())
|
||||
return "class_method";
|
||||
else
|
||||
return "method";
|
||||
}
|
||||
public:
|
||||
void setFileBeforeVisiting(SourceFile *SF) {
|
||||
assert(SF && "need to visit actual source files");
|
||||
@@ -850,7 +859,7 @@ public:
|
||||
if (!pName.empty())
|
||||
out.attribute("type", pName);
|
||||
}
|
||||
out.attribute("method", clangD->getNameAsString());
|
||||
out.attribute(selectMethodKey(clangD), clangD->getNameAsString());
|
||||
out.attribute("declared_at", Loc.printToString(SM));
|
||||
out.attribute("referenced_at", visitingFilePath);
|
||||
});
|
||||
|
||||
@@ -10,10 +10,12 @@ import Foo
|
||||
public func testProperties(_ x: FooClassBase) {
|
||||
_ = x.fooBaseInstanceFunc0()
|
||||
x.fooBaseInstanceFunc1(1.2)
|
||||
_ = FooClassBase.fooBaseClassFunc0()
|
||||
}
|
||||
|
||||
// CHECK-DAG: fooBaseInstanceFunc0
|
||||
// CHECK-DAG: fooBaseInstanceFunc1
|
||||
// CHECK-DAG: "instance_method": "fooBaseInstanceFunc0"
|
||||
// CHECK-DAG: "instance_method": "fooBaseInstanceFunc1:"
|
||||
// CHECK-DAG: "class_method": "fooBaseClassFunc0"
|
||||
// CHECK-DAG: "type": "FooClassBase"
|
||||
// CHECK-DAG: "declared_at": "SOURCE_DIR/test/IDE/Inputs/mock-sdk/Foo.framework/Headers/Foo.h
|
||||
// CHECK-DAG: "referenced_at": "SOURCE_DIR/test/IDE/objc_send_collector.swift"
|
||||
|
||||
Reference in New Issue
Block a user