[clang] dde4e03 - clang/CodeGen: Stop using SourceManager::getBuffer, NFC
Duncan P. N. Exon Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 14 20:58:35 PDT 2020
Author: Duncan P. N. Exon Smith
Date: 2020-10-14T23:32:43-04:00
New Revision: dde4e0318c4cd2054ed241bf248fdddb8d1973e3
URL: https://github.com/llvm/llvm-project/commit/dde4e0318c4cd2054ed241bf248fdddb8d1973e3
DIFF: https://github.com/llvm/llvm-project/commit/dde4e0318c4cd2054ed241bf248fdddb8d1973e3.diff
LOG: 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
Added:
Modified:
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CodeGenAction.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 71ebd268f630..8280fe718f26 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<llvm::MemoryBufferRef> 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 5ea2fc23ee11..871cdb7dac3b 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<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,
More information about the cfe-commits
mailing list