[PATCH] D148723: [clang] Restrict Inline Builtin to non-static, non-odr linkage
serge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 29 01:02:38 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe20931b2ccd1: [clang] Restrict Inline Builtin to non-static, non-odr linkage (authored by serge-sans-paille).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148723/new/
https://reviews.llvm.org/D148723
Files:
clang/lib/AST/Decl.cpp
clang/test/CodeGen/inline-builtin-comdat.c
Index: clang/test/CodeGen/inline-builtin-comdat.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/inline-builtin-comdat.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-windows -S -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s
+// Inline builtin are not supported for odr linkage
+// CHECK-NOT: .inline
+
+double __cdecl frexp( double _X, int* _Y);
+inline __attribute__((always_inline)) long double __cdecl frexpl( long double __x, int *__exp ) {
+ return (long double) frexp((double)__x, __exp );
+}
+
+long double pain(void)
+{
+ long double f = 123.45;
+ int i;
+ long double f2 = frexpl(f, &i);
+ return f2;
+}
Index: clang/lib/AST/Decl.cpp
===================================================================
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3314,8 +3314,23 @@
return false;
const FunctionDecl *Definition;
- return hasBody(Definition) && Definition->isInlineSpecified() &&
- Definition->hasAttr<AlwaysInlineAttr>();
+ if (!hasBody(Definition))
+ return false;
+
+ if (!Definition->isInlineSpecified() ||
+ !Definition->hasAttr<AlwaysInlineAttr>())
+ return false;
+
+ ASTContext &Context = getASTContext();
+ switch (Context.GetGVALinkageForFunction(this)) {
+ case GVA_Internal:
+ case GVA_DiscardableODR:
+ case GVA_StrongODR:
+ return false;
+ case GVA_AvailableExternally:
+ case GVA_StrongExternal:
+ return true;
+ }
}
bool FunctionDecl::isDestroyingOperatorDelete() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148723.526407.patch
Type: text/x-patch
Size: 1546 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230529/f9b501b4/attachment.bin>
More information about the cfe-commits
mailing list