[clang] 0d91cb5 - [clang][Interp][NFC] Clean up getOrCreateDummy()
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 23 01:28:11 PDT 2023
Author: Timm Bäder
Date: 2023-07-23T10:27:51+02:00
New Revision: 0d91cb5ef9c01ab633243838e892f61f73ebc56b
URL: https://github.com/llvm/llvm-project/commit/0d91cb5ef9c01ab633243838e892f61f73ebc56b
DIFF: https://github.com/llvm/llvm-project/commit/0d91cb5ef9c01ab633243838e892f61f73ebc56b.diff
LOG: [clang][Interp][NFC] Clean up getOrCreateDummy()
Added:
Modified:
clang/lib/AST/Interp/Program.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/Program.cpp b/clang/lib/AST/Interp/Program.cpp
index 1ebf9e8cbb1655..c1697bb7fa6d64 100644
--- a/clang/lib/AST/Interp/Program.cpp
+++ b/clang/lib/AST/Interp/Program.cpp
@@ -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;
More information about the cfe-commits
mailing list