xref: /llvm-project/clang/test/CodeGen/memcpy-inline-builtin-no-extern.c (revision c5de4dd1eab00df76c1a68c5f397304ceacb71f2)
1 // RUN: %clang_cc1 -triple x86_64 -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
2 //
3 // Verifies that clang-generated *.inline are flagged as internal.
4 
5 typedef unsigned long size_t;
6 
7 #define AVAILABLE_EXTERNALLY extern inline __attribute__((always_inline)) __attribute__((gnu_inline))
8 // Clang recognizes an inline builtin and renames it to memcmp.inline to prevent conflict with builtins.
memcmp(const void * a,const void * b,size_t c)9 AVAILABLE_EXTERNALLY int memcmp(const void *a, const void *b, size_t c) {
10   return __builtin_memcmp(a, b, c);
11 }
12 
13 // CHECK: internal{{.*}}memcmp.inline
bar(const void * a,const void * b,size_t c)14 int bar(const void *a, const void *b, size_t c) {
15   return memcmp(a, b, c);
16 }
17 
18 // Note that extern has been omitted here.
19 #define TRIPLE_INLINE inline __attribute__((always_inline)) __attribute__((gnu_inline))
20 
21 // Clang recognizes an inline builtin and renames it to memcpy.inline to prevent conflict with builtins.
memcpy(void * a,const void * b,size_t c)22 TRIPLE_INLINE void *memcpy(void *a, const void *b, size_t c) {
23   return __builtin_memcpy(a, b, c);
24 }
25 
26 // CHECK: internal{{.*}}memcpy.inline
foo(void * a,const void * b,size_t c)27 void *foo(void *a, const void *b, size_t c) {
28   return memcpy(a, b, c);
29 }
30