diff --git a/clang/lib/AST/ByteCode/Program.cpp b/clang/lib/AST/ByteCode/Program.cpp index c33d7fd7a2dc5..665e87bb5d2c8 100644 --- a/clang/lib/AST/ByteCode/Program.cpp +++ b/clang/lib/AST/ByteCode/Program.cpp @@ -213,12 +213,12 @@ std::optional Program::createGlobal(const ValueDecl *VD, if (auto Idx = createGlobal(VD, VD->getType(), IsStatic, IsExtern, IsWeak, Init)) { for (const Decl *P = VD; P; P = P->getPreviousDecl()) { + unsigned &PIdx = GlobalIndices[P]; if (P != VD) { - unsigned PIdx = GlobalIndices[P]; if (Globals[PIdx]->block()->isExtern()) Globals[PIdx] = Globals[*Idx]; } - GlobalIndices[P] = *Idx; + PIdx = *Idx; } return *Idx; }