[clang] 1c2afba - [CodeGen, test] Test llvm-libc style alias attribute with UsingShadowDecl
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 16 11:05:51 PDT 2024
Author: Fangrui Song
Date: 2024-04-16T11:05:45-07:00
New Revision: 1c2afbae9af22b58190c10e3517242d01d89d612
URL: https://github.com/llvm/llvm-project/commit/1c2afbae9af22b58190c10e3517242d01d89d612
DIFF: https://github.com/llvm/llvm-project/commit/1c2afbae9af22b58190c10e3517242d01d89d612.diff
LOG: [CodeGen,test] Test llvm-libc style alias attribute with UsingShadowDecl
The pattern is quite involved and deserves a specific codegen test.
This test would catch the bug in the first attempt of #87130
Added:
Modified:
clang/test/CodeGen/alias.cpp
Removed:
################################################################################
diff --git a/clang/test/CodeGen/alias.cpp b/clang/test/CodeGen/alias.cpp
index 17c1e1ae32f035..a468c31d369ed0 100644
--- a/clang/test/CodeGen/alias.cpp
+++ b/clang/test/CodeGen/alias.cpp
@@ -1,27 +1,42 @@
-// RUN: %clang_cc1 -triple x86_64-linux -verify -emit-llvm-only %s
-// RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux -verify -emit-llvm-only -DERR %s
+// RUN: not %clang_cc1 -triple x86_64-linux -emit-llvm-only -fdiagnostics-parseable-fixits -DERR %s 2>&1 | FileCheck %s --check-prefix=FIXIT
+// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm %s -o - | FileCheck %s
+#ifdef ERR
void *f1_ifunc(void) { return nullptr; }
void f1(void) __attribute__((alias("f1_ifunc")));
// expected-error at -1 {{alias must point to a defined variable or function}}
// expected-note at -2 {{must refer to its mangled name}}
// expected-note at -3 {{function by that name is mangled as}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:30-[[@LINE-4]]:47}:"alias(\"_Z8f1_ifuncv\")"
+// FIXIT: fix-it:"{{.*}}":{[[@LINE-4]]:30-[[@LINE-4]]:47}:"alias(\"_Z8f1_ifuncv\")"
void *f6_resolver_resolver(void) { return 0; }
void *f6_resolver(void) __attribute__((alias("f6_resolver_resolver")));
// expected-error at -1 {{alias must point to a defined variable or function}}
// expected-note at -2 {{must refer to its mangled name}}
// expected-note at -3 {{function by that name is mangled as}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:40-[[@LINE-4]]:69}:"alias(\"_Z20f6_resolver_resolverv\")"
+// FIXIT: fix-it:"{{.*}}":{[[@LINE-4]]:40-[[@LINE-4]]:69}:"alias(\"_Z20f6_resolver_resolverv\")"
void f6(void) __attribute__((alias("f6_resolver")));
// expected-error at -1 {{alias must point to a defined variable or function}}
// expected-note at -2 {{must refer to its mangled name}}
// expected-note at -3 {{function by that name is mangled as}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:30-[[@LINE-4]]:50}:"alias(\"_Z11f6_resolverv\")"
+// FIXIT: fix-it:"{{.*}}":{[[@LINE-4]]:30-[[@LINE-4]]:50}:"alias(\"_Z11f6_resolverv\")"
__attribute__((unused, alias("resolver"), deprecated("hahahaha, isn't C great?")))
void func();
// expected-error at -2 {{alias must point to a defined variable or function}}
// expected-note at -3 {{must refer to its mangled name}}
+#endif
+// CHECK: @_ZN4libc4log2Ed ={{.*}} alias double (double), ptr @log2
+// CHECK: define{{.*}} @log2(
+namespace libc { double log2(double x); }
+extern "C" double log2(double);
+namespace std { using ::log2; }
+using std::log2;
+
+namespace libc {
+decltype(libc::log2) __log2_impl__ __asm__("log2");
+decltype(libc::log2) log2 [[gnu::alias("log2")]];
+double __log2_impl__(double x) { return x; }
+}
More information about the cfe-commits
mailing list