diff options
author | serge-sans-paille <sguelton@redhat.com> | 2019-12-05 17:08:10 +0100 |
---|---|---|
committer | serge-sans-paille <sguelton@redhat.com> | 2020-01-10 09:44:20 +0100 |
commit | 921f871ac438175ca8fcfcafdfcfac4d7ddf3905 (patch) | |
tree | 7e7d223ab1fb1ec6111231b9151f0c5629acac02 /clang/lib/AST/Decl.cpp | |
parent | 164da673009ba6c100ce45b6fa9a5dfd3b0b8e38 (diff) | |
download | bcm5719-llvm-921f871ac438175ca8fcfcafdfcfac4d7ddf3905.tar.gz bcm5719-llvm-921f871ac438175ca8fcfcafdfcfac4d7ddf3905.zip |
Allow system header to provide their own implementation of some builtin
If a system header provides an (inline) implementation of some of their
function, clang still matches on the function name and generate the appropriate
llvm builtin, e.g. memcpy. This behavior is in line with glibc recommendation «
users may not provide their own version of symbols » but doesn't account for the
fact that glibc itself can provide inline version of some functions.
It is the case for the memcpy function when -D_FORTIFY_SOURCE=1 is on. In that
case an inline version of memcpy calls __memcpy_chk, a function that performs
extra runtime checks. Clang currently ignores the inline version and thus
provides no runtime check.
This code fixes the issue by detecting functions whose name is a builtin name
but also have an inline implementation.
Differential Revision: https://reviews.llvm.org/D71082
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index be59d88b73f..0d30f64b992 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -3046,6 +3046,14 @@ bool FunctionDecl::isReplaceableGlobalAllocationFunction(bool *IsAligned) const return Params == FPT->getNumParams(); } +bool FunctionDecl::isInlineBuiltinDeclaration() const { + if (!getBuiltinID()) + return false; + + const FunctionDecl *Definition; + return hasBody(Definition) && Definition->isInlineSpecified(); +} + bool FunctionDecl::isDestroyingOperatorDelete() const { // C++ P0722: // Within a class C, a single object deallocation function with signature |