Skip to content

Commit e362e7a

Browse files
authored
[CodeGen] Fix ICE caused by invalid cast (#3206)
CodeGen wrongly casts function declaration to a variable declaration assuming that alias attribute can be applied to variable declarations only.
1 parent d3118b2 commit e362e7a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5100,8 +5100,8 @@ void CodeGenModule::EmitAliasDefinition(GlobalDecl GD) {
51005100
LT = getFunctionLinkage(GD);
51015101
AS = Aliasee->getType()->getPointerAddressSpace();
51025102
} else {
5103-
const auto *VarD = cast<VarDecl>(GD.getDecl());
5104-
AS = ArgInfoAddressSpace(GetGlobalVarAddressSpace(VarD));
5103+
AS = ArgInfoAddressSpace(
5104+
GetGlobalVarAddressSpace(dyn_cast<VarDecl>(GD.getDecl())));
51055105
Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(), DeclTy->getPointerTo(AS),
51065106
/*D=*/nullptr);
51075107
if (const auto *VD = dyn_cast<VarDecl>(GD.getDecl()))

0 commit comments

Comments
 (0)