From 79bfc7f39fdfd61ca80fe41b9de47e63adcccf8c Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Fri, 10 Jul 2015 20:55:38 +0000 Subject: [PATCH] [MS ABI] Don't generates code for unreferenced inline definitions of library builtins We should only consider declarations which were written, implicit declarations shouldn't be considered. This fixes PR24084. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241941 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/Decl.cpp | 4 ++-- test/CodeGen/inline.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index d9a3389c58..74c0e2dc69 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -2712,7 +2712,7 @@ bool FunctionDecl::isMSExternInline() const { for (const FunctionDecl *FD = getMostRecentDecl(); FD; FD = FD->getPreviousDecl()) - if (FD->getStorageClass() == SC_Extern) + if (!FD->isImplicit() && FD->getStorageClass() == SC_Extern) return true; return false; @@ -2724,7 +2724,7 @@ static bool redeclForcesDefMSVC(const FunctionDecl *Redecl) { for (const FunctionDecl *FD = Redecl->getPreviousDecl(); FD; FD = FD->getPreviousDecl()) - if (FD->getStorageClass() == SC_Extern) + if (!FD->isImplicit() && FD->getStorageClass() == SC_Extern) return false; return true; diff --git a/test/CodeGen/inline.c b/test/CodeGen/inline.c index a45bccc513..16e95c03c8 100644 --- a/test/CodeGen/inline.c +++ b/test/CodeGen/inline.c @@ -54,6 +54,7 @@ // RUN: echo "MS C Mode tests:" // RUN: %clang_cc1 %s -triple i386-unknown-unknown -O1 -disable-llvm-optzns -emit-llvm -o - -std=c99 -fms-compatibility | FileCheck %s --check-prefix=CHECK4 +// CHECK4-NOT: define weak_odr void @_Exit( // CHECK4-LABEL: define weak_odr i32 @ei() // CHECK4-LABEL: define i32 @bar() // CHECK4-NOT: unreferenced1 @@ -62,6 +63,9 @@ // CHECK4-LABEL: define linkonce_odr i32 @foo() // CHECK4-LABEL: define available_externally void @gnu_ei_inline() +__attribute__((noreturn)) void __cdecl _exit(int _Code); +__inline void __cdecl _Exit(int status) { _exit(status); } + extern __inline int ei() { return 123; } __inline int foo() { -- 2.50.1