From a4e1e60397177ae06c200fc52b756736ad18cde8 Mon Sep 17 00:00:00 2001 From: wuhuiquan Date: Fri, 11 Oct 2024 18:41:11 +0800 Subject: [PATCH] [BSC] Fix the issue of ASM function name invalidation in BSC language --- clang/lib/AST/Mangle.cpp | 6 ++++-- .../BSC/Positive/Others/asm_function/asm_function.cbs | 8 ++++++++ clang/test/BSC/Positive/Others/asm_function/test.s | 6 ++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 clang/test/BSC/Positive/Others/asm_function/asm_function.cbs create mode 100644 clang/test/BSC/Positive/Others/asm_function/test.s diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp index fba2808c08a2..6d4d296d9593 100644 --- a/clang/lib/AST/Mangle.cpp +++ b/clang/lib/AST/Mangle.cpp @@ -133,8 +133,10 @@ bool MangleContext::shouldMangleDeclName(const NamedDecl *D) { // In BSC, generic function always does mangling. if (getASTContext().getLangOpts().BSC) { if (auto FD = dyn_cast(D)) { - return FD->getTemplatedKind() == - FunctionDecl::TemplatedKind::TK_FunctionTemplateSpecialization; + if (FD->getTemplatedKind() == + FunctionDecl::TemplatedKind::TK_FunctionTemplateSpecialization) { + return true; + } } } #endif diff --git a/clang/test/BSC/Positive/Others/asm_function/asm_function.cbs b/clang/test/BSC/Positive/Others/asm_function/asm_function.cbs new file mode 100644 index 000000000000..f67679183300 --- /dev/null +++ b/clang/test/BSC/Positive/Others/asm_function/asm_function.cbs @@ -0,0 +1,8 @@ +// RUN: %clang %s %S/test.s -o %t.output + +int asmfunction1() asm ("_asmfunction1"); + +int main(){ + asmfunction1(); + return 0; +} diff --git a/clang/test/BSC/Positive/Others/asm_function/test.s b/clang/test/BSC/Positive/Others/asm_function/test.s new file mode 100644 index 000000000000..c5d4a88f0ed6 --- /dev/null +++ b/clang/test/BSC/Positive/Others/asm_function/test.s @@ -0,0 +1,6 @@ +.section .text +.align 8 +.global _asmfunction1 +.type _asmfunction1, @function + +_asmfunction1: -- Gitee