diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2011-10-11 22:09:24 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2011-10-11 22:09:24 +0000 |
commit | 94ab9308d73811ae45258462d74a7b77e59bc791 (patch) | |
tree | dae205b0fb4a74edef9c8ab1210eb7f53b23f560 | |
parent | 1c18465859e9f6dfcf8f18eda5fba146c6c3dbcd (diff) | |
download | bcm5719-llvm-94ab9308d73811ae45258462d74a7b77e59bc791.tar.gz bcm5719-llvm-94ab9308d73811ae45258462d74a7b77e59bc791.zip |
PR11062: Make C99 inlining work properly for names with associated builtin libcalls.
llvm-svn: 141723
-rw-r--r-- | clang/lib/AST/Decl.cpp | 7 | ||||
-rw-r--r-- | clang/test/CodeGen/inline.c | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 5cd98584bf9..3e5c2537376 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1856,7 +1856,12 @@ bool FunctionDecl::isInlineDefinitionExternallyVisible() const { // 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 } diff --git a/clang/test/CodeGen/inline.c b/clang/test/CodeGen/inline.c index 2f6bd72dab5..6bc583df8c9 100644 --- a/clang/test/CodeGen/inline.c +++ b/clang/test/CodeGen/inline.c @@ -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 @@ extern int test6(); // 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); } |