r360892 - Recommit [Object] Change object::SectionRef::getContents() to return Expected<StringRef>
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Thu May 16 06:24:04 PDT 2019
Author: maskray
Date: Thu May 16 06:24:04 2019
New Revision: 360892
URL: http://llvm.org/viewvc/llvm-project?rev=360892&view=rev
Log:
Recommit [Object] Change object::SectionRef::getContents() to return Expected<StringRef>
r360876 didn't fix 2 call sites in clang.
Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now.
Follow-up of D61781.
Modified:
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp
Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=360892&r1=360891&r2=360892&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Thu May 16 06:24:04 2019
@@ -337,8 +337,14 @@ ObjectFilePCHContainerReader::ExtractPCH
StringRef Name;
Section.getName(Name);
if ((!IsCOFF && Name == "__clangast") || (IsCOFF && Name == "clangast")) {
- Section.getContents(PCH);
- return PCH;
+ if (Expected<StringRef> E = Section.getContents())
+ return *E;
+ else {
+ handleAllErrors(E.takeError(), [&](const llvm::ErrorInfoBase &EIB) {
+ EIB.log(llvm::errs());
+ });
+ return "";
+ }
}
}
}
Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp?rev=360892&r1=360891&r2=360892&view=diff
==============================================================================
--- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp (original)
+++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Thu May 16 06:24:04 2019
@@ -462,13 +462,16 @@ public:
// TODO: Instead of copying the input file as is, deactivate the section
// that is no longer needed.
- StringRef Content;
- CurrentSection->getContents(Content);
+ Expected<StringRef> Content = CurrentSection->getContents();
+ if (!Content) {
+ consumeError(Content.takeError());
+ return;
+ }
- if (Content.size() < 2)
+ if (Content->size() < 2)
OS.write(Input.getBufferStart(), Input.getBufferSize());
else
- OS.write(Content.data(), Content.size());
+ OS.write(Content->data(), Content->size());
}
void WriteHeader(raw_fd_ostream &OS,
More information about the cfe-commits
mailing list