ModuleObjcMessageTrace: indicate whether a method is instance method or class method

This commit is contained in:
Xi Ge
2024-10-28 15:58:51 -07:00
parent 7b32de27c6
commit b1fa3e65b5
2 changed files with 14 additions and 3 deletions

View File

@@ -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);
});

View File

@@ -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"