[clang][Interp][NFC] Clean up getOrCreateDummy()
authorTimm Bäder <tbaeder@redhat.com>
Sun, 23 Jul 2023 05:21:37 +0000 (07:21 +0200)
committerTimm Bäder <tbaeder@redhat.com>
Sun, 23 Jul 2023 08:27:51 +0000 (10:27 +0200)
clang/lib/AST/Interp/Program.cpp

index 1ebf9e8..c1697bb 100644 (file)
@@ -139,17 +139,17 @@ std::optional<unsigned> Program::getOrCreateGlobal(const ValueDecl *VD,
 }
 
 std::optional<unsigned> Program::getOrCreateDummy(const ParmVarDecl *PD) {
-  auto &ASTCtx = Ctx.getASTContext();
 
+  // Dedup blocks since they are immutable and pointers cannot be compared.
+  if (auto It = DummyParams.find(PD);
+      It != DummyParams.end())
+    return It->second;
+
+  auto &ASTCtx = Ctx.getASTContext();
   // Create a pointer to an incomplete array of the specified elements.
   QualType ElemTy = PD->getType()->castAs<PointerType>()->getPointeeType();
   QualType Ty = ASTCtx.getIncompleteArrayType(ElemTy, ArrayType::Normal, 0);
 
-  // Dedup blocks since they are immutable and pointers cannot be compared.
-  auto It = DummyParams.find(PD);
-  if (It != DummyParams.end())
-    return It->second;
-
   if (auto Idx = createGlobal(PD, Ty, /*isStatic=*/true, /*isExtern=*/true)) {
     DummyParams[PD] = *Idx;
     return Idx;