clang/CodeGen: Stop using SourceManager::getBuffer, NFC

Update `clang/lib/CodeGen` to use a `MemoryBufferRef` from
`getBufferOrNone` instead of `MemoryBuffer*` from `getBuffer`. No
functionality change here.

Differential Revision: https://reviews.llvm.org/D89411
This commit is contained in:
Duncan P. N. Exon Smith 2020-10-14 13:48:52 -04:00
parent 63af242279
commit dde4e0318c
2 changed files with 5 additions and 8 deletions

View File

@ -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<llvm::MemoryBufferRef> MemBuffer = SM.getBufferOrNone(FID);
if (!MemBuffer)
return None;
llvm::MD5 Hash;

View File

@ -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<MemoryBufferRef> 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,