Skip to content

Commit 1504736

Browse files
committed
Swift: add a warning to unmangled types
1 parent 3f7c4de commit 1504736

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

swift/extractor/mangler/SwiftMangler.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "swift/extractor/mangler/SwiftMangler.h"
22
#include "swift/extractor/infra/SwiftDispatcher.h"
33
#include "swift/extractor/trap/generated/decl/TrapClasses.h"
4+
#include "swift/logging/SwiftLogging.h"
5+
46
#include <swift/AST/Module.h>
57
#include <swift/AST/ParameterList.h>
68
#include <swift/AST/ASTContext.h>
@@ -10,6 +12,11 @@
1012
using namespace codeql;
1113

1214
namespace {
15+
Logger& logger() {
16+
static Logger ret{"mangler"};
17+
return ret;
18+
}
19+
1320
const swift::Decl* getParent(const swift::Decl* decl) {
1421
auto context = decl->getDeclContext();
1522
if (context->getContextKind() == swift::DeclContextKind::FileUnit) {
@@ -189,7 +196,7 @@ SwiftMangledName SwiftMangler::visitAnyGenericType(const swift::AnyGenericType*
189196
}
190197

191198
SwiftMangledName SwiftMangler::visitType(const swift::TypeBase* type) {
192-
dispatcher.emitDebugInfo("no name for ", getTypeKindStr(type));
199+
LOG_WARNING("encountered {} for which we give no name", getTypeKindStr(type));
193200
return {};
194201
}
195202

@@ -238,7 +245,7 @@ SwiftMangledName SwiftMangler::visitAnyFunctionType(const swift::AnyFunctionType
238245
ret << "_actor" << fetch(type->getGlobalActor());
239246
}
240247
// TODO: see if this needs to be used in identifying types, if not it needs to be removed from
241-
// type printing
248+
// type printing in the Swift compiler code
242249
assert(type->hasExtInfo() && "type must have ext info");
243250
auto info = type->getExtInfo();
244251
auto convention = info.getSILRepresentation();

swift/extractor/mangler/SwiftMangler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class SwiftMangler : private swift::TypeVisitor<SwiftMangler, SwiftMangledName>,
6969

7070
// default fallback for non mangled types. This covers types that should not appear in normal
7171
// successful extractor runs, like ErrorType
72-
// TODO: log this properly once we have logging infrastructure
7372
SwiftMangledName visitType(const swift::TypeBase* type);
7473

7574
SwiftMangledName visitModuleType(const swift::ModuleType* type);

0 commit comments

Comments
 (0)