nickdesaulniers created this revision. nickdesaulniers added reviewers: aaron.ballman, iajbar. Herald added a project: clang. Herald added a subscriber: cfe-commits. nickdesaulniers requested review of this revision.
Via bugreport: https://reviews.llvm.org/D66492#2350947 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D90073 Files: clang/lib/CodeGen/CodeGenModule.cpp clang/test/CodeGen/alias.c Index: clang/test/CodeGen/alias.c =================================================================== --- clang/test/CodeGen/alias.c +++ clang/test/CodeGen/alias.c @@ -109,3 +109,9 @@ // CHECKGLOBALS: @test12_alias = alias void (), void ()* @test12 void test12(void) {} inline void test12_alias(void) __attribute__((gnu_inline, alias("test12"))); + +// Test that a non visible (-Wvisibility) type doesn't assert. +// CHECKGLOBALS: @test13_alias = alias {}, bitcast (void (i32)* @test13 to {}*) +enum a_type { test13_a }; +void test13(enum a_type y) {} +void test13_alias(enum undeclared_type y) __attribute__((alias ("test13"))); Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -4637,8 +4637,13 @@ Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(), llvm::PointerType::getUnqual(DeclTy), /*D=*/nullptr); - LT = getLLVMLinkageVarDefinition(cast<VarDecl>(GD.getDecl()), - D->getType().isConstQualified()); + if (isa<VarDecl>(GD.getDecl())) + LT = getLLVMLinkageVarDefinition(cast<VarDecl>(GD.getDecl()), + D->getType().isConstQualified()); + else if (isa<FunctionDecl>(GD.getDecl())) + LT = getFunctionLinkage(GD); + assert((isa<VarDecl>(GD.getDecl()) || isa<FunctionDecl>(GD.getDecl())) && + "unexpected DeclType"); } // Create the new alias itself, but don't set a name yet.
Index: clang/test/CodeGen/alias.c =================================================================== --- clang/test/CodeGen/alias.c +++ clang/test/CodeGen/alias.c @@ -109,3 +109,9 @@ // CHECKGLOBALS: @test12_alias = alias void (), void ()* @test12 void test12(void) {} inline void test12_alias(void) __attribute__((gnu_inline, alias("test12"))); + +// Test that a non visible (-Wvisibility) type doesn't assert. +// CHECKGLOBALS: @test13_alias = alias {}, bitcast (void (i32)* @test13 to {}*) +enum a_type { test13_a }; +void test13(enum a_type y) {} +void test13_alias(enum undeclared_type y) __attribute__((alias ("test13"))); Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -4637,8 +4637,13 @@ Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(), llvm::PointerType::getUnqual(DeclTy), /*D=*/nullptr); - LT = getLLVMLinkageVarDefinition(cast<VarDecl>(GD.getDecl()), - D->getType().isConstQualified()); + if (isa<VarDecl>(GD.getDecl())) + LT = getLLVMLinkageVarDefinition(cast<VarDecl>(GD.getDecl()), + D->getType().isConstQualified()); + else if (isa<FunctionDecl>(GD.getDecl())) + LT = getFunctionLinkage(GD); + assert((isa<VarDecl>(GD.getDecl()) || isa<FunctionDecl>(GD.getDecl())) && + "unexpected DeclType"); } // Create the new alias itself, but don't set a name yet.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits