forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clang][Fortify] drop inline decls when redeclared
When an inline builtin declaration is shadowed by an actual declaration, we must reference the actual declaration, even if it's not the last, following GCC behavior. This fixes llvm#54715 Differential Revision: https://reviews.llvm.org/D123308 (cherry picked from commit 301e0d9)
- Loading branch information
Showing
2 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 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, even when that definition appears at the end of the | ||
// file. | ||
|
||
// CHECK-NOT: strlen.inline | ||
|
||
extern unsigned long strlen(char const *s); | ||
|
||
extern __inline __attribute__((__always_inline__)) __attribute__((__gnu_inline__)) unsigned long strlen(char const *s) { | ||
return 1; | ||
} | ||
|
||
static unsigned long chesterfield(char const *s) { | ||
return strlen(s); | ||
} | ||
static unsigned long (*_strlen)(char const *ptr); | ||
|
||
unsigned long blutch(char const *s) { | ||
return chesterfield(s); | ||
} | ||
|
||
unsigned long strlen(char const *s) { | ||
return _strlen(s); | ||
} |