]> granicus.if.org Git - clang/commitdiff
[MS ABI] Don't generates code for unreferenced inline definitions of library builtins
authorDavid Majnemer <david.majnemer@gmail.com>
Fri, 10 Jul 2015 20:55:38 +0000 (20:55 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Fri, 10 Jul 2015 20:55:38 +0000 (20:55 +0000)
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
test/CodeGen/inline.c

index d9a3389c58f3a194feb2e062a95147f52376f014..74c0e2dc69d5b3a39438dd2ba4403f69af87a60e 100644 (file)
@@ -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;
index a45bccc5132863726f87b676a108894f55cd05d1..16e95c03c875d7779b538b9555dd5c38b0824410 100644 (file)
@@ -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() {