[clang][Interp][NFC] Simplify creating parameter descriptors
authorTimm Bäder <tbaeder@redhat.com>
Tue, 11 Oct 2022 07:06:04 +0000 (09:06 +0200)
committerTimm Bäder <tbaeder@redhat.com>
Sat, 22 Oct 2022 08:32:05 +0000 (10:32 +0200)
... using value_or instead of the if-else statement.

clang/lib/AST/Interp/ByteCodeEmitter.cpp

index d653da3..1328470 100644 (file)
@@ -56,13 +56,7 @@ ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl) {
   // Assign descriptors to all parameters.
   // Composite objects are lowered to pointers.
   for (const ParmVarDecl *PD : FuncDecl->parameters()) {
-    PrimType Ty;
-    if (llvm::Optional<PrimType> T = Ctx.classify(PD->getType())) {
-      Ty = *T;
-    } else {
-      Ty = PT_Ptr;
-    }
-
+    PrimType Ty = Ctx.classify(PD->getType()).value_or(PT_Ptr);
     Descriptor *Desc = P.createDescriptor(PD, Ty);
     ParamDescriptors.insert({ParamOffset, {Ty, Desc}});
     Params.insert({PD, ParamOffset});