File tree Expand file tree Collapse file tree 3 files changed +14
-10
lines changed Expand file tree Collapse file tree 3 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -1318,13 +1318,9 @@ void LinkerDriver::convertResources() {
13181318}
13191319
13201320void LinkerDriver::maybeCreateECExportThunk (StringRef name, Symbol *&sym) {
1321- Defined *def;
13221321 if (!sym)
13231322 return ;
1324- if (auto undef = dyn_cast<Undefined>(sym))
1325- def = undef->getDefinedWeakAlias ();
1326- else
1327- def = dyn_cast<Defined>(sym);
1323+ Defined *def = sym->getDefined ();
13281324 if (!def)
13291325 return ;
13301326
@@ -1356,11 +1352,7 @@ void LinkerDriver::createECExportThunks() {
13561352 Symbol *sym = ctx.symtab .find (targetName);
13571353 if (!sym)
13581354 continue ;
1359- Defined *targetSym;
1360- if (auto undef = dyn_cast<Undefined>(sym))
1361- targetSym = undef->getDefinedWeakAlias ();
1362- else
1363- targetSym = dyn_cast<Defined>(sym);
1355+ Defined *targetSym = sym->getDefined ();
13641356 if (!targetSym)
13651357 continue ;
13661358
Original file line number Diff line number Diff line change @@ -91,6 +91,14 @@ bool Symbol::isLive() const {
9191 return true ;
9292}
9393
94+ Defined *Symbol::getDefined () {
95+ if (auto d = dyn_cast<Defined>(this ))
96+ return d;
97+ if (auto u = dyn_cast<Undefined>(this ))
98+ return u->getDefinedWeakAlias ();
99+ return nullptr ;
100+ }
101+
94102void Symbol::replaceKeepingName (Symbol *other, size_t size) {
95103 StringRef origName = getName ();
96104 memcpy (this , other, size);
Original file line number Diff line number Diff line change @@ -95,6 +95,10 @@ class Symbol {
9595 symbolKind == LazyDLLSymbolKind;
9696 }
9797
98+ // Get the Defined symbol associated with this symbol, either itself or its
99+ // weak alias.
100+ Defined *getDefined ();
101+
98102private:
99103 void computeName ();
100104
You can’t perform that action at this time.
0 commit comments