diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 71ebd268f63076..8280fe718f26bd 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -374,9 +374,8 @@ CGDebugInfo::computeChecksum(FileID FID, SmallString<32> &Checksum) const { return None; SourceManager &SM = CGM.getContext().getSourceManager(); - bool Invalid; - const llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID, &Invalid); - if (Invalid) + Optional MemBuffer = SM.getBufferOrNone(FID); + if (!MemBuffer) return None; llvm::MD5 Hash; diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 5ea2fc23ee1193..871cdb7dac3b9c 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -1122,11 +1122,10 @@ void CodeGenAction::ExecuteAction() { if (BA != Backend_EmitNothing && !OS) return; - bool Invalid; SourceManager &SM = CI.getSourceManager(); FileID FID = SM.getMainFileID(); - const llvm::MemoryBuffer *MainFile = SM.getBuffer(FID, &Invalid); - if (Invalid) + Optional MainFile = SM.getBufferOrNone(FID); + if (!MainFile) return; TheModule = loadModule(*MainFile); @@ -1141,8 +1140,7 @@ void CodeGenAction::ExecuteAction() { TheModule->setTargetTriple(TargetOpts.Triple); } - EmbedBitcode(TheModule.get(), CodeGenOpts, - MainFile->getMemBufferRef()); + EmbedBitcode(TheModule.get(), CodeGenOpts, *MainFile); LLVMContext &Ctx = TheModule->getContext(); Ctx.setInlineAsmDiagnosticHandler(BitcodeInlineAsmDiagHandler,