Skip to content

Commit 7e5f393

Browse files
authored
[TBDGen] update usages of MachO::SymbolKind -> MachO::EncodeKind, NFC (#71247)
1 parent a52e96e commit 7e5f393

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

lib/IRGen/TBDGen.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,21 @@ using namespace swift::irgen;
6161
using namespace swift::tbdgen;
6262
using namespace llvm::yaml;
6363
using StringSet = llvm::StringSet<>;
64-
using SymbolKind = llvm::MachO::SymbolKind;
64+
using EncodeKind = llvm::MachO::EncodeKind;
6565
using SymbolFlags = llvm::MachO::SymbolFlags;
6666

6767
TBDGenVisitor::TBDGenVisitor(const TBDGenDescriptor &desc,
6868
APIRecorder &recorder)
6969
: TBDGenVisitor(desc.getTarget(), desc.getDataLayoutString(),
7070
desc.getParentModule(), desc.getOptions(), recorder) {}
7171

72-
void TBDGenVisitor::addSymbolInternal(StringRef name, SymbolKind kind,
72+
void TBDGenVisitor::addSymbolInternal(StringRef name, EncodeKind kind,
7373
SymbolSource source, SymbolFlags flags) {
7474
if (!source.isLinkerDirective() && Opts.LinkerDirectivesOnly)
7575
return;
7676

7777
#ifndef NDEBUG
78-
if (kind == SymbolKind::GlobalSymbol) {
78+
if (kind == EncodeKind::GlobalSymbol) {
7979
if (!DuplicateSymbolChecker.insert(name).second) {
8080
llvm::dbgs() << "TBDGen duplicate symbol: " << name << '\n';
8181
assert(false && "TBDGen symbol appears twice");
@@ -291,9 +291,9 @@ static llvm::VersionTuple calculateLdPreviousVersionStart(ASTContext &ctx,
291291
return introVer;
292292
}
293293

294-
void TBDGenVisitor::addLinkerDirectiveSymbolsLdPrevious(StringRef name,
295-
llvm::MachO::SymbolKind kind) {
296-
if (kind != llvm::MachO::SymbolKind::GlobalSymbol)
294+
void TBDGenVisitor::addLinkerDirectiveSymbolsLdPrevious(
295+
StringRef name, llvm::MachO::EncodeKind kind) {
296+
if (kind != llvm::MachO::EncodeKind::GlobalSymbol)
297297
return;
298298
if(DeclStack.empty())
299299
return;
@@ -341,14 +341,14 @@ void TBDGenVisitor::addLinkerDirectiveSymbolsLdPrevious(StringRef name,
341341
OS << verStart.getMajor() << "." << getMinor(verStart.getMinor()) << "$";
342342
OS << Ver.Version.getMajor() << "." << getMinor(Ver.Version.getMinor()) << "$";
343343
OS << name << "$";
344-
addSymbolInternal(OS.str(), SymbolKind::GlobalSymbol,
344+
addSymbolInternal(OS.str(), EncodeKind::GlobalSymbol,
345345
SymbolSource::forLinkerDirective(), SymbolFlags::Data);
346346
}
347347
}
348348

349-
void TBDGenVisitor::addLinkerDirectiveSymbolsLdHide(StringRef name,
350-
llvm::MachO::SymbolKind kind) {
351-
if (kind != llvm::MachO::SymbolKind::GlobalSymbol)
349+
void TBDGenVisitor::addLinkerDirectiveSymbolsLdHide(
350+
StringRef name, llvm::MachO::EncodeKind kind) {
351+
if (kind != llvm::MachO::EncodeKind::GlobalSymbol)
352352
return;
353353
if (DeclStack.empty())
354354
return;
@@ -387,19 +387,19 @@ void TBDGenVisitor::addLinkerDirectiveSymbolsLdHide(StringRef name,
387387
llvm::SmallString<64> Buffer;
388388
llvm::raw_svector_ostream OS(Buffer);
389389
OS << "$ld$hide$os" << CurMaj << "." << CurMin << "$" << name;
390-
addSymbolInternal(OS.str(), SymbolKind::GlobalSymbol,
390+
addSymbolInternal(OS.str(), EncodeKind::GlobalSymbol,
391391
SymbolSource::forLinkerDirective(), SymbolFlags::Data);
392392
}
393393
}
394394
}
395395

396396
void TBDGenVisitor::addSymbol(StringRef name, SymbolSource source,
397-
SymbolFlags flags, SymbolKind kind) {
397+
SymbolFlags flags, EncodeKind kind) {
398398
// The linker expects to see mangled symbol names in TBD files,
399399
// except when being passed objective c classes,
400400
// so make sure to mangle before inserting the symbol.
401401
SmallString<32> mangled;
402-
if (kind == SymbolKind::ObjectiveCClass) {
402+
if (kind == EncodeKind::ObjectiveCClass) {
403403
mangled = name;
404404
} else {
405405
if (!DataLayout)
@@ -461,7 +461,7 @@ void TBDGenVisitor::addObjCInterface(ClassDecl *CD) {
461461
// FIXME: We ought to have a symbol source for this.
462462
SmallString<128> buffer;
463463
addSymbol(CD->getObjCRuntimeName(buffer), SymbolSource::forUnknown(),
464-
SymbolFlags::Data, SymbolKind::ObjectiveCClass);
464+
SymbolFlags::Data, EncodeKind::ObjectiveCClass);
465465
recorder.addObjCInterface(CD);
466466
}
467467

@@ -619,7 +619,7 @@ TBDFile GenerateTBDRequest::evaluate(Evaluator &evaluator,
619619
targets.push_back(targetVar);
620620
}
621621

622-
auto addSymbol = [&](StringRef symbol, SymbolKind kind, SymbolSource source,
622+
auto addSymbol = [&](StringRef symbol, EncodeKind kind, SymbolSource source,
623623
Decl *decl, SymbolFlags flags) {
624624
file.addSymbol(kind, symbol, targets, flags);
625625
};
@@ -633,12 +633,12 @@ std::vector<std::string>
633633
PublicSymbolsRequest::evaluate(Evaluator &evaluator,
634634
TBDGenDescriptor desc) const {
635635
std::vector<std::string> symbols;
636-
auto addSymbol = [&](StringRef symbol, SymbolKind kind, SymbolSource source,
636+
auto addSymbol = [&](StringRef symbol, EncodeKind kind, SymbolSource source,
637637
Decl *decl, SymbolFlags flags) {
638-
if (kind == SymbolKind::GlobalSymbol)
638+
if (kind == EncodeKind::GlobalSymbol)
639639
symbols.push_back(symbol.str());
640640
// TextAPI ObjC Class Kinds represents two symbols.
641-
else if (kind == SymbolKind::ObjectiveCClass) {
641+
else if (kind == EncodeKind::ObjectiveCClass) {
642642
symbols.push_back((llvm::MachO::ObjC2ClassNamePrefix + symbol).str());
643643
symbols.push_back((llvm::MachO::ObjC2MetaClassNamePrefix + symbol).str());
644644
}
@@ -681,9 +681,9 @@ class APIGenRecorder final : public APIRecorder {
681681
}
682682
~APIGenRecorder() {}
683683

684-
void addSymbol(StringRef symbol, SymbolKind kind, SymbolSource source,
684+
void addSymbol(StringRef symbol, EncodeKind kind, SymbolSource source,
685685
Decl *decl, SymbolFlags flags) override {
686-
if (kind != SymbolKind::GlobalSymbol)
686+
if (kind != EncodeKind::GlobalSymbol)
687687
return;
688688

689689
apigen::APIAvailability availability;
@@ -885,7 +885,7 @@ SymbolSourceMapRequest::evaluate(Evaluator &evaluator,
885885
auto &Ctx = desc.getParentModule()->getASTContext();
886886
auto *SymbolSources = Ctx.Allocate<SymbolSourceMap>();
887887

888-
auto addSymbol = [=](StringRef symbol, SymbolKind kind, SymbolSource source,
888+
auto addSymbol = [=](StringRef symbol, EncodeKind kind, SymbolSource source,
889889
Decl *decl, SymbolFlags flags) {
890890
SymbolSources->insert({symbol, source});
891891
};

lib/IRGen/TBDGenVisitor.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class APIRecorder {
6161
public:
6262
virtual ~APIRecorder() {}
6363

64-
virtual void addSymbol(StringRef name, llvm::MachO::SymbolKind kind,
64+
virtual void addSymbol(StringRef name, llvm::MachO::EncodeKind kind,
6565
SymbolSource source, Decl *decl,
6666
llvm::MachO::SymbolFlags flags) {}
6767
virtual void addObjCInterface(const ClassDecl *decl) {}
@@ -72,12 +72,12 @@ class APIRecorder {
7272
class SimpleAPIRecorder final : public APIRecorder {
7373
public:
7474
using SymbolCallbackFn =
75-
llvm::function_ref<void(StringRef, llvm::MachO::SymbolKind, SymbolSource,
75+
llvm::function_ref<void(StringRef, llvm::MachO::EncodeKind, SymbolSource,
7676
Decl *, llvm::MachO::SymbolFlags)>;
7777

7878
SimpleAPIRecorder(SymbolCallbackFn func) : func(func) {}
7979

80-
void addSymbol(StringRef symbol, llvm::MachO::SymbolKind kind,
80+
void addSymbol(StringRef symbol, llvm::MachO::EncodeKind kind,
8181
SymbolSource source, Decl *decl,
8282
llvm::MachO::SymbolFlags flags) override {
8383
func(symbol, kind, source, decl, flags);
@@ -101,20 +101,20 @@ class TBDGenVisitor : public IRSymbolVisitor {
101101
const TBDGenOptions &Opts;
102102
APIRecorder &recorder;
103103

104-
using SymbolKind = llvm::MachO::SymbolKind;
104+
using EncodeKind = llvm::MachO::EncodeKind;
105105
using SymbolFlags = llvm::MachO::SymbolFlags;
106106

107107
std::vector<Decl*> DeclStack;
108108
std::unique_ptr<std::map<std::string, InstallNameStore>>
109109
previousInstallNameMap;
110110
std::unique_ptr<std::map<std::string, InstallNameStore>>
111111
parsePreviousModuleInstallNameMap();
112-
void addSymbolInternal(StringRef name, SymbolKind kind, SymbolSource source,
112+
void addSymbolInternal(StringRef name, EncodeKind kind, SymbolSource source,
113113
SymbolFlags);
114-
void addLinkerDirectiveSymbolsLdHide(StringRef name, SymbolKind kind);
115-
void addLinkerDirectiveSymbolsLdPrevious(StringRef name, SymbolKind kind);
114+
void addLinkerDirectiveSymbolsLdHide(StringRef name, EncodeKind kind);
115+
void addLinkerDirectiveSymbolsLdPrevious(StringRef name, EncodeKind kind);
116116
void addSymbol(StringRef name, SymbolSource source, SymbolFlags flags,
117-
SymbolKind kind = SymbolKind::GlobalSymbol);
117+
EncodeKind kind = EncodeKind::GlobalSymbol);
118118

119119
void addSymbol(LinkEntity entity);
120120

0 commit comments

Comments
 (0)