Skip to content

Commit 04c5ceb

Browse files
committed
Adjust for svn r368826
LLVM svn r368826 changed the SectionRef::getName() interface to return an Expected<StringRef> instead of filling out one that is passed to it. Adjust accordingly.
1 parent 40545b9 commit 04c5ceb

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

lib/IRGen/IRGen.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,13 @@ static bool needsRecompile(StringRef OutputFilename, ArrayRef<uint8_t> HashData,
383383

384384
// Search for the section which holds the hash.
385385
for (auto &Section : ObjectFile->sections()) {
386-
StringRef SectionName;
387-
Section.getName(SectionName);
386+
llvm::Expected<StringRef> SectionNameOrErr = Section.getName();
387+
if (!SectionNameOrErr) {
388+
llvm::consumeError(SectionNameOrErr.takeError());
389+
continue;
390+
}
391+
392+
StringRef SectionName = *SectionNameOrErr;
388393
if (SectionName == HashSectionName) {
389394
llvm::Expected<llvm::StringRef> SectionData = Section.getContents();
390395
if (!SectionData) {

tools/driver/autolink_extract_main.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,12 @@ extractLinkerFlagsFromObjectFile(const llvm::object::ObjectFile *ObjectFile,
114114
CompilerInstance &Instance) {
115115
// Search for the section we hold autolink entries in
116116
for (auto &Section : ObjectFile->sections()) {
117-
llvm::StringRef SectionName;
118-
Section.getName(SectionName);
117+
llvm::Expected<llvm::StringRef> SectionNameOrErr = Section.getName();
118+
if (!SectionNameOrErr) {
119+
llvm::consumeError(SectionNameOrErr.takeError());
120+
continue;
121+
}
122+
llvm::StringRef SectionName = *SectionNameOrErr;
119123
if (SectionName == ".swift1_autolink_entries") {
120124
llvm::Expected<llvm::StringRef> SectionData = Section.getContents();
121125
if (!SectionData) {

tools/lldb-moduleimport-test/lldb-moduleimport-test.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,12 @@ collectASTModules(llvm::cl::list<std::string> &InputNames,
167167
}
168168

169169
for (auto &Section : Obj->sections()) {
170-
llvm::StringRef Name;
171-
Section.getName(Name);
170+
llvm::Expected<llvm::StringRef> NameOrErr = Section.getName();
171+
if (!NameOrErr) {
172+
llvm::consumeError(NameOrErr.takeError());
173+
continue;
174+
}
175+
llvm::StringRef Name = *NameOrErr;
172176
if ((MachO && Name == swift::MachOASTSectionName) ||
173177
(ELF && Name == swift::ELFASTSectionName) ||
174178
(COFF && Name == swift::COFFASTSectionName)) {

tools/swift-reflection-dump/swift-reflection-dump.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ static bool needToRelocate(SectionRef S) {
112112
"swift5_typeref", "swift5_reflstr", "swift5_assocty", "swift5_replace",
113113
"swift5_type_metadata", "swift5_fieldmd", "swift5_capture", "swift5_builtin"
114114
};
115-
StringRef Name;
116-
if (auto EC = S.getName(Name))
117-
reportError(EC);
118-
return ELFSectionsList.count(Name);
115+
llvm::Expected<llvm::StringRef> NameOrErr = S.getName();
116+
if (!NameOrErr) {
117+
reportError(errorToErrorCode(NameOrErr.takeError()));
118+
return false;
119+
}
120+
return ELFSectionsList.count(*NameOrErr);
119121
}
120122

121123
return true;

0 commit comments

Comments
 (0)