aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Program.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-07-21 17:16:13 +0200
committerGitHub <noreply@github.com>2025-07-21 17:16:13 +0200
commite39ee62c5bdbe71b9f191bc5da7d47577e2099a9 (patch)
tree1ce84ccb27cd0a034e932152dbf7ce5df74c8f87 /clang/lib/AST/ByteCode/Program.cpp
parent49d7a9b14ef1cc1c7231507f5f2feff7e7653966 (diff)
downloadllvm-e39ee62c5bdbe71b9f191bc5da7d47577e2099a9.zip
llvm-e39ee62c5bdbe71b9f191bc5da7d47577e2099a9.tar.gz
llvm-e39ee62c5bdbe71b9f191bc5da7d47577e2099a9.tar.bz2
[clang][bytecode] Use OptPrimType instead of std::optional<PrimType> (#149812)
We use this construct a lot. Use something similar to clang's UnsignedOrNone. This results in some slighy compile time improvements: https://llvm-compile-time-tracker.com/compare.php?from=17a4b0399d161a3b89d8f0ce82add1638f23f5d4&to=a251d81ecd0ed45dd190462663155fdb303ef04d&stat=instructions:u
Diffstat (limited to 'clang/lib/AST/ByteCode/Program.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Program.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/clang/lib/AST/ByteCode/Program.cpp b/clang/lib/AST/ByteCode/Program.cpp
index af6d7c7..7002724 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -169,7 +169,7 @@ unsigned Program::getOrCreateDummy(const DeclTy &D) {
assert(!QT.isNull());
Descriptor *Desc;
- if (std::optional<PrimType> T = Ctx.classify(QT))
+ if (OptPrimType T = Ctx.classify(QT))
Desc = createDescriptor(D, *T, /*SourceTy=*/nullptr, std::nullopt,
/*IsConst=*/QT.isConstQualified());
else
@@ -248,7 +248,7 @@ std::optional<unsigned> Program::createGlobal(const DeclTy &D, QualType Ty,
const bool IsConst = Ty.isConstQualified();
const bool IsTemporary = D.dyn_cast<const Expr *>();
const bool IsVolatile = Ty.isVolatileQualified();
- if (std::optional<PrimType> T = Ctx.classify(Ty))
+ if (OptPrimType T = Ctx.classify(Ty))
Desc = createDescriptor(D, *T, nullptr, Descriptor::GlobalMD, IsConst,
IsTemporary, /*IsMutable=*/false, IsVolatile);
else
@@ -371,7 +371,7 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) {
const bool IsMutable = FD->isMutable();
const bool IsVolatile = FT.isVolatileQualified();
const Descriptor *Desc;
- if (std::optional<PrimType> T = Ctx.classify(FT)) {
+ if (OptPrimType T = Ctx.classify(FT)) {
Desc = createDescriptor(FD, *T, nullptr, std::nullopt, IsConst,
/*isTemporary=*/false, IsMutable, IsVolatile);
} else {
@@ -410,7 +410,7 @@ Descriptor *Program::createDescriptor(const DeclTy &D, const Type *Ty,
// Array of well-known bounds.
if (const auto *CAT = dyn_cast<ConstantArrayType>(ArrayType)) {
size_t NumElems = CAT->getZExtSize();
- if (std::optional<PrimType> T = Ctx.classify(ElemTy)) {
+ if (OptPrimType T = Ctx.classify(ElemTy)) {
// Arrays of primitives.
unsigned ElemSize = primSize(*T);
if (std::numeric_limits<unsigned>::max() / ElemSize <= NumElems) {
@@ -437,7 +437,7 @@ Descriptor *Program::createDescriptor(const DeclTy &D, const Type *Ty,
// is forbidden on pointers to such objects.
if (isa<IncompleteArrayType>(ArrayType) ||
isa<VariableArrayType>(ArrayType)) {
- if (std::optional<PrimType> T = Ctx.classify(ElemTy)) {
+ if (OptPrimType T = Ctx.classify(ElemTy)) {
return allocateDescriptor(D, *T, MDSize, IsConst, IsTemporary,
Descriptor::UnknownSize{});
} else {
@@ -460,7 +460,7 @@ Descriptor *Program::createDescriptor(const DeclTy &D, const Type *Ty,
// Complex types - represented as arrays of elements.
if (const auto *CT = Ty->getAs<ComplexType>()) {
- std::optional<PrimType> ElemTy = Ctx.classify(CT->getElementType());
+ OptPrimType ElemTy = Ctx.classify(CT->getElementType());
if (!ElemTy)
return nullptr;
@@ -470,7 +470,7 @@ Descriptor *Program::createDescriptor(const DeclTy &D, const Type *Ty,
// Same with vector types.
if (const auto *VT = Ty->getAs<VectorType>()) {
- std::optional<PrimType> ElemTy = Ctx.classify(VT->getElementType());
+ OptPrimType ElemTy = Ctx.classify(VT->getElementType());
if (!ElemTy)
return nullptr;