aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Program.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-10-20 12:55:06 +0200
committerGitHub <noreply@github.com>2025-10-20 12:55:06 +0200
commit7b0c51a43917fdd4dae2f9415b6c041ca4d1c3f1 (patch)
tree0f31685187d5a090d78f9b910e9643ddd91603a9 /clang/lib/AST/ByteCode/Program.cpp
parent6d663cd365df4e9373e60484c9b67965d01ab4a1 (diff)
downloadllvm-7b0c51a43917fdd4dae2f9415b6c041ca4d1c3f1.zip
llvm-7b0c51a43917fdd4dae2f9415b6c041ca4d1c3f1.tar.gz
llvm-7b0c51a43917fdd4dae2f9415b6c041ca4d1c3f1.tar.bz2
[clang][bytecode] Fix a crash when redeclaring extern globals (#164204)
One iteration of this loop might've already fixed up the pointers of coming globals, so check for that explicitly. Fixes https://github.com/llvm/llvm-project/issues/164151
Diffstat (limited to 'clang/lib/AST/ByteCode/Program.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Program.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/AST/ByteCode/Program.cpp b/clang/lib/AST/ByteCode/Program.cpp
index e653782..e0b2852 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -226,7 +226,10 @@ UnsignedOrNone Program::createGlobal(const ValueDecl *VD, const Expr *Init) {
Globals[PIdx] = NewGlobal;
// All pointers pointing to the previous extern decl now point to the
// new decl.
- RedeclBlock->movePointersTo(NewGlobal->block());
+ // A previous iteration might've already fixed up the pointers for this
+ // global.
+ if (RedeclBlock != NewGlobal->block())
+ RedeclBlock->movePointersTo(NewGlobal->block());
}
}
PIdx = *Idx;