From 585f62be1a438ca132aa443e556d102bc908a072 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Tue, 16 Aug 2022 21:22:27 +0000 Subject: CodeGen: correct handling of debug info generation for aliases When aliasing a static array, the aliasee is going to be a GEP which points to the value. We should strip pointer casts before forming the reference. This was occluded by the use of opaque pointers. This problem has existed since the introduction of the debug info generation for aliases in b1ea0191a42074341847d767609f66a26b6d5a41. The test case would assert due to the invalid cast with or without `-no-opaque-pointers` at that revision. Fixes: #57179 --- clang/lib/CodeGen/CodeGenModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index c30bccb1bbd3..0921008e254c 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -5338,7 +5338,7 @@ void CodeGenModule::EmitAliasDefinition(GlobalDecl GD) { // Emit global alias debug information. if (isa(D)) if (CGDebugInfo *DI = getModuleDebugInfo()) - DI->EmitGlobalAlias(cast(GA->getAliasee()), GD); + DI->EmitGlobalAlias(cast(GA->getAliasee()->stripPointerCasts()), GD); } void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) { -- cgit v1.2.3