mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
ModuleObjcMessageTrace: report ObjC method calls from all source files under compilation
This commit is contained in:
@@ -823,14 +823,14 @@ class ObjcMethodReferenceCollector: public SourceEntityWalker {
|
||||
std::string targetVariant;
|
||||
SmallVector<StringRef, 32> FilePaths;
|
||||
unsigned CurrentFileID;
|
||||
llvm::DenseSet<const clang::ObjCMethodDecl*> results;
|
||||
llvm::DenseMap<const clang::ObjCMethodDecl*, unsigned> results;
|
||||
bool visitDeclReference(ValueDecl *D, CharSourceRange Range,
|
||||
TypeDecl *CtorTyRef, ExtensionDecl *ExtTyRef,
|
||||
Type T, ReferenceMetaData Data) override {
|
||||
if (!Range.isValid())
|
||||
return true;
|
||||
if (auto *clangD = dyn_cast_or_null<clang::ObjCMethodDecl>(D->getClangDecl())) {
|
||||
results.insert(clangD);
|
||||
results[clangD] = CurrentFileID;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -873,7 +873,8 @@ public:
|
||||
if (!targetVariant.empty())
|
||||
out.attribute("target-variant", targetVariant);
|
||||
out.attributeArray("references", [&] {
|
||||
for (const clang::ObjCMethodDecl* clangD: results) {
|
||||
for (auto pair: results) {
|
||||
auto *clangD = pair.first;
|
||||
auto &SM = clangD->getASTContext().getSourceManager();
|
||||
clang::SourceLocation Loc = clangD->getLocation();
|
||||
if (!Loc.isValid()) {
|
||||
@@ -881,14 +882,14 @@ public:
|
||||
}
|
||||
out.object([&] {
|
||||
if (auto *parent = dyn_cast_or_null<clang::NamedDecl>(clangD
|
||||
->getParent())) {
|
||||
->getParent())) {
|
||||
auto pName = parent->getName();
|
||||
if (!pName.empty())
|
||||
out.attribute(selectMethodOwnerKey(parent), pName);
|
||||
}
|
||||
out.attribute(selectMethodKey(clangD), clangD->getNameAsString());
|
||||
out.attribute("declared_at", Loc.printToString(SM));
|
||||
out.attribute("referenced_at_file_id", CurrentFileID);
|
||||
out.attribute("referenced_at_file_id", pair.second);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user