Files
clang-p2996/clang/test/CodeGen/strlen-inline-builtin-redecl.c
serge-sans-paille 6bfc85c217 Fix inline builtin handling in case of redefinition
Basically, inline builtin definition are shadowed by externally visible
redefinition. This matches GCC behavior.

The implementation has to workaround the fact that:

1. inline builtin are renamed at callsite during codegen, but
2. they may be shadowed by a later external definition

As a consequence, during codegen, we need to walk redecls and eventually rewrite
some call sites, which is totally inelegant.

Differential Revision: https://reviews.llvm.org/D112059
2021-11-02 09:53:49 +01:00

22 lines
609 B
C

// RUN: %clang_cc1 -triple x86_64 -S -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
//
// Verifies that clang-generated *.inline are removed when shadowed by an external definition
// CHECK-NOT: strlen.inline
unsigned long strnlen(const char *, unsigned long);
void fortify_panic(const char *);
extern inline __attribute__((always_inline)) __attribute__((gnu_inline)) unsigned long strlen(const char *p) {
return 1;
}
unsigned long mystrlen(char const *s) {
return strlen(s);
}
unsigned long strlen(const char *s) {
return 2;
}
unsigned long yourstrlen(char const *s) {
return strlen(s);
}