Skip to content

Commit 9ceb9e2

Browse files
mdtoguchibader
authored andcommitted
[SYCL] Check return of Expected<T> when reading section size content
Community pull down introduced Expected<T> on the return of getContents. Apply the needed check after return to satisfy. From the llvm manual: All Error instances, whether success or failure, must be either checked or moved from (via std::move or a return) before they are destructed Signed-off-by: Michael D Toguchi <[email protected]>
1 parent 6540810 commit 9ceb9e2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,12 @@ class ObjectFileHandler final : public FileHandler {
555555
if (matchSectionName(SIZE_SECTION_PREFIX, *Sec, OffloadTriple)) {
556556
// yes, it is - parse object sizes
557557
Expected<StringRef> Content = Sec->getContents();
558+
if (!Content) {
559+
consumeError(Content.takeError());
560+
return;
561+
}
558562
unsigned int ElemSize =
559563
getSectionSizeTy(VMContext)->getPrimitiveSizeInBits() / 8;
560-
561564
// the size of the size section must be a multiple of ElemSize
562565
if (Content->size() % ElemSize != 0)
563566
report_fatal_error(

0 commit comments

Comments
 (0)