[cfe-commits] r141723 - in /cfe/trunk: lib/AST/Decl.cpp test/CodeGen/inline.c

Eli Friedman eli.friedman at gmail.com
Tue Oct 11 15:09:24 PDT 2011


Author: efriedma
Date: Tue Oct 11 17:09:24 2011
New Revision: 141723

URL: http://llvm.org/viewvc/llvm-project?rev=141723&view=rev
Log:
PR11062: Make C99 inlining work properly for names with associated builtin libcalls.


Modified:
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/test/CodeGen/inline.c

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=141723&r1=141722&r2=141723&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Oct 11 17:09:24 2011
@@ -1856,7 +1856,12 @@
     // Only consider file-scope declarations in this test.
     if (!Redecl->getLexicalDeclContext()->isTranslationUnit())
       continue;
-    
+
+    // Only consider explicit declarations; the presence of a builtin for a
+    // libcall shouldn't affect whether a definition is externally visible.
+    if (Redecl->isImplicit())
+      continue;
+
     if (!Redecl->isInlineSpecified() || Redecl->getStorageClass() == SC_Extern) 
       return true; // Not an inline definition
   }

Modified: cfe/trunk/test/CodeGen/inline.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/inline.c?rev=141723&r1=141722&r2=141723&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/inline.c (original)
+++ cfe/trunk/test/CodeGen/inline.c Tue Oct 11 17:09:24 2011
@@ -15,7 +15,7 @@
 // RUN: grep "define i32 @test6" %t
 
 // RUN: echo "\nC99 tests:"
-// RUN: %clang %s -O1 -emit-llvm -S -o %t -std=c99
+// RUN: %clang %s -O1 -emit-llvm -S -o %t -std=gnu99
 // RUN: grep "define i32 @ei()" %t
 // RUN: grep "define available_externally i32 @foo()" %t
 // RUN: grep "define i32 @bar()" %t
@@ -29,6 +29,7 @@
 // RUN: grep "define available_externally i32 @test4" %t
 // RUN: grep "define available_externally i32 @test5" %t
 // RUN: grep "define i32 @test6" %t
+// RUN: grep "define available_externally i.. @strlcpy" %t
 
 // RUN: echo "\nC++ tests:"
 // RUN: %clang -x c++ %s -O1 -emit-llvm -S -o %t -std=c++98
@@ -97,3 +98,7 @@
 // redeclaration detection.
 void test7() { }
 void test7();
+
+// PR11062; the fact that the function is named strlcpy matters here.
+inline __typeof(sizeof(int)) strlcpy(char *dest, const char *src, __typeof(sizeof(int)) size) { return 3; }
+void test8() { strlcpy(0,0,0); }





More information about the cfe-commits mailing list