aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorKrzysztof Parzyszek <kparzysz@quicinc.com>2022-12-03 16:01:15 -0600
committerKrzysztof Parzyszek <kparzysz@quicinc.com>2022-12-04 11:52:02 -0600
commit0ca43d44888885d6caf7636db91fe810e822263c (patch)
tree1b8e5ee0f5ae8e0163d551a99fcfccd33aa27456 /clang/lib/CodeGen/CGDebugInfo.cpp
parentfcf4e360ba6b5f005d2c478ca79112be7a61dacb (diff)
downloadllvm-0ca43d44888885d6caf7636db91fe810e822263c.zip
llvm-0ca43d44888885d6caf7636db91fe810e822263c.tar.gz
llvm-0ca43d44888885d6caf7636db91fe810e822263c.tar.bz2
DebugInfoMetadata: convert Optional to std::optional
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 12b74ee..b0fe96d 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -51,6 +51,7 @@
#include "llvm/Support/SHA1.h"
#include "llvm/Support/SHA256.h"
#include "llvm/Support/TimeProfiler.h"
+#include <optional>
using namespace clang;
using namespace clang::CodeGen;
@@ -345,7 +346,7 @@ StringRef CGDebugInfo::getClassName(const RecordDecl *RD) {
return StringRef();
}
-Optional<llvm::DIFile::ChecksumKind>
+std::optional<llvm::DIFile::ChecksumKind>
CGDebugInfo::computeChecksum(FileID FID, SmallString<64> &Checksum) const {
Checksum.clear();
@@ -373,8 +374,8 @@ CGDebugInfo::computeChecksum(FileID FID, SmallString<64> &Checksum) const {
llvm_unreachable("Unhandled DebugSrcHashKind enum");
}
-Optional<StringRef> CGDebugInfo::getSource(const SourceManager &SM,
- FileID FID) {
+std::optional<StringRef> CGDebugInfo::getSource(const SourceManager &SM,
+ FileID FID) {
if (!CGM.getCodeGenOpts().EmbedSource)
return std::nullopt;
@@ -419,17 +420,18 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
SmallString<64> Checksum;
- Optional<llvm::DIFile::ChecksumKind> CSKind = computeChecksum(FID, Checksum);
- Optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo;
+ std::optional<llvm::DIFile::ChecksumKind> CSKind =
+ computeChecksum(FID, Checksum);
+ std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo;
if (CSKind)
CSInfo.emplace(*CSKind, Checksum);
return createFile(FileName, CSInfo, getSource(SM, SM.getFileID(Loc)));
}
-llvm::DIFile *
-CGDebugInfo::createFile(StringRef FileName,
- Optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
- Optional<StringRef> Source) {
+llvm::DIFile *CGDebugInfo::createFile(
+ StringRef FileName,
+ std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo,
+ std::optional<StringRef> Source) {
StringRef Dir;
StringRef File;
std::string RemappedFile = remapDIPath(FileName);
@@ -512,8 +514,8 @@ StringRef CGDebugInfo::getCurrentDirname() {
void CGDebugInfo::CreateCompileUnit() {
SmallString<64> Checksum;
- Optional<llvm::DIFile::ChecksumKind> CSKind;
- Optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo;
+ std::optional<llvm::DIFile::ChecksumKind> CSKind;
+ std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo;
// Should we be asking the SourceManager for the main file name, instead of
// accepting it as an argument? This just causes the main file name to
@@ -1148,8 +1150,9 @@ llvm::DIType *CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag Tag,
// Size is always the size of a pointer.
uint64_t Size = CGM.getContext().getTypeSize(Ty);
auto Align = getTypeAlignIfRequired(Ty, CGM.getContext());
- Optional<unsigned> DWARFAddressSpace = CGM.getTarget().getDWARFAddressSpace(
- CGM.getTypes().getTargetAddressSpace(PointeeTy));
+ std::optional<unsigned> DWARFAddressSpace =
+ CGM.getTarget().getDWARFAddressSpace(
+ CGM.getTypes().getTargetAddressSpace(PointeeTy));
SmallVector<llvm::Metadata *, 4> Annots;
auto *BTFAttrTy = dyn_cast<BTFTagAttributedType>(PointeeTy);
@@ -2201,7 +2204,7 @@ llvm::DIType *CGDebugInfo::getOrCreateVTablePtrType(llvm::DIFile *Unit) {
llvm::DIType *SubTy = DBuilder.createSubroutineType(SElements);
unsigned Size = Context.getTypeSize(Context.VoidPtrTy);
unsigned VtblPtrAddressSpace = CGM.getTarget().getVtblPtrAddressSpace();
- Optional<unsigned> DWARFAddressSpace =
+ std::optional<unsigned> DWARFAddressSpace =
CGM.getTarget().getDWARFAddressSpace(VtblPtrAddressSpace);
llvm::DIType *vtbl_ptr_type = DBuilder.createPointerType(
@@ -2298,7 +2301,7 @@ void CGDebugInfo::CollectVTableInfo(const CXXRecordDecl *RD, llvm::DIFile *Unit,
VFTLayout.vtable_components().size() - CGM.getLangOpts().RTTIData;
unsigned VTableWidth = PtrWidth * VSlotCount;
unsigned VtblPtrAddressSpace = CGM.getTarget().getVtblPtrAddressSpace();
- Optional<unsigned> DWARFAddressSpace =
+ std::optional<unsigned> DWARFAddressSpace =
CGM.getTarget().getDWARFAddressSpace(VtblPtrAddressSpace);
// Create a very wide void* type and insert it directly in the element list.
@@ -4284,7 +4287,7 @@ void CGDebugInfo::CreateLexicalBlock(SourceLocation Loc) {
void CGDebugInfo::AppendAddressSpaceXDeref(
unsigned AddressSpace, SmallVectorImpl<uint64_t> &Expr) const {
- Optional<unsigned> DWARFAddressSpace =
+ std::optional<unsigned> DWARFAddressSpace =
CGM.getTarget().getDWARFAddressSpace(AddressSpace);
if (!DWARFAddressSpace)
return;