File: redefine_extname.c

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb11u2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,634,820 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (38 lines) | stat: -rw-r--r-- 1,323 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// RUN: %clang_cc1 -triple=i386-pc-solaris2.11 -w -emit-llvm %s -o - | FileCheck %s

#pragma redefine_extname fake real
#pragma redefine_extname name alias

extern int fake(void);

int name;

// __PRAGMA_REDEFINE_EXTNAME should be defined.  This will fail if it isn't...
int fish(void) { return fake() + __PRAGMA_REDEFINE_EXTNAME + name; }
// Check that the call to fake() is emitted as a call to real()
// CHECK:   call i32 @real()
// Check that this also works with variables names
// CHECK:   load i32, ptr @alias

// This is a case when redefenition is deferred *and* we have a local of the
// same name. PR23923.
#pragma redefine_extname foo bar
int f(void) {
  int foo = 0;
  return foo;
}
extern int foo(void) { return 1; }
// CHECK: define{{.*}} i32 @bar()

// Check that pragma redefine_extname applies to external declarations only.
#pragma redefine_extname foo_static bar_static
static int foo_static(void) { return 1; }
int baz(void) { return foo_static(); }
// CHECK-NOT: call i32 @bar_static()

// Check that pragma redefine_extname applies to builtin functions.
typedef unsigned long size_t;
extern void *memcpy(void *, const void *, size_t);
#pragma redefine_extname memcpy __GI_memcpy
void *test_memcpy(void *dst, const void *src, size_t n) { return memcpy(dst, src, n); }
// CHECK: call ptr @__GI_memcpy(