Skip to content

Commit b1fa3e6

Browse files
committed
ModuleObjcMessageTrace: indicate whether a method is instance method or class method
1 parent 7b32de2 commit b1fa3e6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/FrontendTool/LoadedModuleTrace.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,15 @@ class ObjcMethodReferenceCollector: public SourceEntityWalker {
829829
}
830830
return true;
831831
}
832+
static StringRef selectMethodKey(const clang::ObjCMethodDecl* clangD) {
833+
assert(clangD);
834+
if (clangD->isInstanceMethod())
835+
return "instance_method";
836+
else if (clangD->isClassMethod())
837+
return "class_method";
838+
else
839+
return "method";
840+
}
832841
public:
833842
void setFileBeforeVisiting(SourceFile *SF) {
834843
assert(SF && "need to visit actual source files");
@@ -850,7 +859,7 @@ class ObjcMethodReferenceCollector: public SourceEntityWalker {
850859
if (!pName.empty())
851860
out.attribute("type", pName);
852861
}
853-
out.attribute("method", clangD->getNameAsString());
862+
out.attribute(selectMethodKey(clangD), clangD->getNameAsString());
854863
out.attribute("declared_at", Loc.printToString(SM));
855864
out.attribute("referenced_at", visitingFilePath);
856865
});

test/IDE/objc_send_collector.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import Foo
1010
public func testProperties(_ x: FooClassBase) {
1111
_ = x.fooBaseInstanceFunc0()
1212
x.fooBaseInstanceFunc1(1.2)
13+
_ = FooClassBase.fooBaseClassFunc0()
1314
}
1415

15-
// CHECK-DAG: fooBaseInstanceFunc0
16-
// CHECK-DAG: fooBaseInstanceFunc1
16+
// CHECK-DAG: "instance_method": "fooBaseInstanceFunc0"
17+
// CHECK-DAG: "instance_method": "fooBaseInstanceFunc1:"
18+
// CHECK-DAG: "class_method": "fooBaseClassFunc0"
1719
// CHECK-DAG: "type": "FooClassBase"
1820
// CHECK-DAG: "declared_at": "SOURCE_DIR/test/IDE/Inputs/mock-sdk/Foo.framework/Headers/Foo.h
1921
// CHECK-DAG: "referenced_at": "SOURCE_DIR/test/IDE/objc_send_collector.swift"

0 commit comments

Comments
 (0)