Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package llvm11 for openSUSE:Factory checked 
in at 2021-01-29 14:56:47
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/llvm11 (Old)
 and      /work/SRC/openSUSE:Factory/.llvm11.new.28504 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "llvm11"

Fri Jan 29 14:56:47 2021 rev:7 rq:867167 version:11.0.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/llvm11/llvm11.changes    2021-01-15 
19:44:05.901826400 +0100
+++ /work/SRC/openSUSE:Factory/.llvm11.new.28504/llvm11.changes 2021-01-29 
14:57:04.349507220 +0100
@@ -1,0 +2,9 @@
+Wed Jan 27 01:53:59 UTC 2021 - Aaron Puchert <aaronpuch...@alice-dsl.net>
+
+- Revert changes that broke the ABI (boo#1181326).
+  * Sema-Introduce-BuiltinAttr-per-declaration-builtin-n.patch
+  * Sema-Handle-objc_super-special-lookup-when-checking-.patch
+  * Recognize-setjmp-and-friends-as-builtins-even-if-jmp.patch
+  * Don-t-reject-calls-to-MinGW-s-unusual-_setjmp-declar.patch
+
+-------------------------------------------------------------------

New:
----
  Don-t-reject-calls-to-MinGW-s-unusual-_setjmp-declar.patch
  Recognize-setjmp-and-friends-as-builtins-even-if-jmp.patch
  Sema-Handle-objc_super-special-lookup-when-checking-.patch
  Sema-Introduce-BuiltinAttr-per-declaration-builtin-n.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ llvm11.spec ++++++
--- /var/tmp/diff_new_pack.U30e5X/_old  2021-01-29 14:57:05.665509156 +0100
+++ /var/tmp/diff_new_pack.U30e5X/_new  2021-01-29 14:57:05.669509162 +0100
@@ -127,6 +127,11 @@
 # PATCH-FIX-OPENSUSE llvm-exegesis-link-dylib.patch -- Don't waste space for 
llvm-exegesis.
 # It's crippled anyway because of missing deps and not relevant for users. 
Eventually we should drop it.
 Patch27:        llvm-exegesis-link-dylib.patch
+# Revert changes that broke the ABI. (boo#1181326)
+Patch28:        Sema-Introduce-BuiltinAttr-per-declaration-builtin-n.patch
+Patch29:        Sema-Handle-objc_super-special-lookup-when-checking-.patch
+Patch30:        Recognize-setjmp-and-friends-as-builtins-even-if-jmp.patch
+Patch31:        Don-t-reject-calls-to-MinGW-s-unusual-_setjmp-declar.patch
 BuildRequires:  binutils-devel >= 2.21.90
 BuildRequires:  cmake
 BuildRequires:  fdupes
@@ -555,6 +560,10 @@
 %patch4 -p1
 %patch6 -p1
 %patch9 -p2
+%patch31 -R -p2
+%patch30 -R -p2
+%patch29 -R -p2
+%patch28 -R -p2
 
 # We hardcode openSUSE
 rm unittests/Driver/DistroTest.cpp

++++++ Don-t-reject-calls-to-MinGW-s-unusual-_setjmp-declar.patch ++++++
>From 98f575ff55bff1e4128ffaeef4d05c356d996ab9 Mon Sep 17 00:00:00 2001
From: Richard Smith <rich...@metafoo.co.uk>
Date: Fri, 2 Oct 2020 13:34:46 -0700
Subject: [PATCH] Don't reject calls to MinGW's unusual _setjmp declaration.

We now recognize this function as a builtin despite it having an
unexpected number of parameters; make sure we don't enforce that it has
only 1 argument for its 2 parameters.
---
 clang/include/clang/Basic/Builtins.def |  1 +
 clang/lib/CodeGen/CGBuiltin.cpp        |  6 ++-
 clang/lib/Sema/SemaChecking.cpp        |  5 --
 clang/test/Sema/builtin-setjmp.c       | 63 +++++++++++++++++++-------
 4 files changed, 52 insertions(+), 23 deletions(-)

diff --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index dbb5dde20a2b..5463b7dfc18c 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1025,6 +1025,7 @@ LIBBUILTIN(pthread_create, "",  "fC<2,3>", "pthread.h", 
ALL_GNU_LANGUAGES)
 
 // POSIX setjmp.h
 
+// FIXME: MinGW _setjmp has an additional void* parameter.
 LIBBUILTIN(_setjmp, "iJ",         "fjT",   "setjmp.h", ALL_LANGUAGES)
 LIBBUILTIN(__sigsetjmp, "iSJi",   "fjT",   "setjmp.h", ALL_LANGUAGES)
 LIBBUILTIN(sigsetjmp, "iSJi",     "fjT",   "setjmp.h", ALL_LANGUAGES)
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 8994b939093e..6b93f1b60af5 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3754,11 +3754,13 @@ RValue CodeGenFunction::EmitBuiltinExpr(const 
GlobalDecl GD, unsigned BuiltinID,
   case Builtin::BI_abnormal_termination:
     return RValue::get(EmitSEHAbnormalTermination());
   case Builtin::BI_setjmpex:
-    if (getTarget().getTriple().isOSMSVCRT())
+    if (getTarget().getTriple().isOSMSVCRT() && E->getNumArgs() == 1 &&
+        E->getArg(0)->getType()->isPointerType())
       return EmitMSVCRTSetJmp(*this, MSVCSetJmpKind::_setjmpex, E);
     break;
   case Builtin::BI_setjmp:
-    if (getTarget().getTriple().isOSMSVCRT()) {
+    if (getTarget().getTriple().isOSMSVCRT() && E->getNumArgs() == 1 &&
+        E->getArg(0)->getType()->isPointerType()) {
       if (getTarget().getTriple().getArch() == llvm::Triple::x86)
         return EmitMSVCRTSetJmp(*this, MSVCSetJmpKind::_setjmp3, E);
       else if (getTarget().getTriple().getArch() == llvm::Triple::aarch64)
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index b00d2ff5f1d5..1bf04d9cb4f2 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1573,11 +1573,6 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
     if (SemaBuiltinSetjmp(TheCall))
       return ExprError();
     break;
-  case Builtin::BI_setjmp:
-  case Builtin::BI_setjmpex:
-    if (checkArgCount(*this, TheCall, 1))
-      return true;
-    break;
   case Builtin::BI__builtin_classify_type:
     if (checkArgCount(*this, TheCall, 1)) return true;
     TheCall->setType(Context.IntTy);
diff --git a/clang/test/Sema/builtin-setjmp.c b/clang/test/Sema/builtin-setjmp.c
index 6a114fad05d9..604d534eb504 100644
--- a/clang/test/Sema/builtin-setjmp.c
+++ b/clang/test/Sema/builtin-setjmp.c
@@ -1,34 +1,47 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DNO_JMP_BUF %s -ast-dump | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DWRONG_JMP_BUF %s -ast-dump | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DRIGHT_JMP_BUF %s -ast-dump | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DONLY_JMP_BUF %s -ast-dump | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DNO_SETJMP %s -ast-dump 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=c,expected -DNO_JMP_BUF %s -ast-dump | FileCheck %s 
--check-prefixes=CHECK1,CHECK2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=c,expected -DWRONG_JMP_BUF %s -ast-dump | FileCheck %s 
--check-prefixes=CHECK1,CHECK2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=c,expected -DRIGHT_JMP_BUF %s -ast-dump | FileCheck %s 
--check-prefixes=CHECK1,CHECK2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=c,expected -DONLY_JMP_BUF %s -ast-dump | FileCheck %s 
--check-prefixes=CHECK1,CHECK2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=c,expected -DNO_SETJMP %s -ast-dump 2>&1 | FileCheck %s 
--check-prefixes=CHECK1,CHECK2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=cxx,expected -x c++ -DNO_JMP_BUF %s -ast-dump | FileCheck %s 
--check-prefixes=CHECK1,CHECK2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=cxx,expected -x c++ -DWRONG_JMP_BUF %s -ast-dump | FileCheck %s 
--check-prefixes=CHECK1,CHECK2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=cxx,expected -x c++ -DRIGHT_JMP_BUF %s -ast-dump | FileCheck %s 
--check-prefixes=CHECK1,CHECK2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=cxx,expected -x c++ -DONLY_JMP_BUF %s -ast-dump | FileCheck %s 
--check-prefixes=CHECK2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only 
-verify=cxx,expected -x c++ -DNO_SETJMP %s -ast-dump | FileCheck %s 
--check-prefixes=CHECK2
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #ifdef NO_JMP_BUF
 // This happens in some versions of glibc: the declaration of __sigsetjmp
 // precedes the declaration of sigjmp_buf.
 extern long setjmp(long *); // Can't check, so we trust that this is the right 
type
 // FIXME: We could still diagnose the missing `jmp_buf` at the point of the 
call.
-// expected-no-diagnostics
+// c-no-diagnostics
 #elif WRONG_JMP_BUF
 typedef long jmp_buf;
-extern int setjmp(char); // expected-warning {{incompatible redeclaration of 
library function 'setjmp'}}
-                         // expected-note@-1 {{'setjmp' is a builtin with type 
'int (jmp_buf)' (aka 'int (long)')}}
+// FIXME: Consider producing a similar warning in C++.
+extern int setjmp(char); // c-warning {{incompatible redeclaration of library 
function 'setjmp'}}
+                         // c-note@-1 {{'setjmp' is a builtin with type 'int 
(jmp_buf)' (aka 'int (long)')}}
 #elif RIGHT_JMP_BUF
 typedef long jmp_buf;
 extern int setjmp(long); // OK, right type.
-// expected-no-diagnostics
 #elif ONLY_JMP_BUF
 typedef int *jmp_buf;
 #endif
 
 void use() {
   setjmp(0);
-  #ifdef NO_SETJMP
-  // expected-warning@-2 {{implicit declaration of function 'setjmp' is 
invalid in C99}}
+  #if NO_SETJMP
+  // cxx-error@-2 {{undeclared identifier 'setjmp'}}
+  // c-warning@-3 {{implicit declaration of function 'setjmp' is invalid in 
C99}}
   #elif ONLY_JMP_BUF
-  // expected-warning@-4 {{implicitly declaring library function 'setjmp' with 
type 'int (jmp_buf)' (aka 'int (int *)')}}
-  // expected-note@-5 {{include the header <setjmp.h> or explicitly provide a 
declaration for 'setjmp'}}
+  // cxx-error@-5 {{undeclared identifier 'setjmp'}}
+  // c-warning@-6 {{implicitly declaring library function 'setjmp' with type 
'int (jmp_buf)' (aka 'int (int *)')}}
+  // c-note@-7 {{include the header <setjmp.h> or explicitly provide a 
declaration for 'setjmp'}}
+  #else
+  // cxx-no-diagnostics
   #endif
 
   #ifdef NO_SETJMP
@@ -37,6 +50,24 @@ void use() {
   #endif
 }
 
-// CHECK: FunctionDecl {{.*}} used setjmp
-// CHECK: BuiltinAttr {{.*}} Implicit
-// CHECK: ReturnsTwiceAttr {{.*}} Implicit
+// CHECK1: FunctionDecl {{.*}} used setjmp
+// CHECK1: BuiltinAttr {{.*}} Implicit
+// CHECK1: ReturnsTwiceAttr {{.*}} Implicit
+
+// mingw declares _setjmp with an unusual signature.
+int _setjmp(void *, void *);
+#if !defined(NO_JMP_BUF) && !defined(NO_SETJMP)
+// c-warning@-2 {{incompatible redeclaration of library function '_setjmp'}}
+// c-note@-3 {{'_setjmp' is a builtin with type 'int (jmp_buf)'}}
+#endif
+void use_mingw() {
+  _setjmp(0, 0);
+}
+
+// CHECK2: FunctionDecl {{.*}} used _setjmp
+// CHECK2: BuiltinAttr {{.*}} Implicit
+// CHECK2: ReturnsTwiceAttr {{.*}} Implicit
+
+#ifdef __cplusplus
+}
+#endif
-- 
2.30.0

++++++ Recognize-setjmp-and-friends-as-builtins-even-if-jmp.patch ++++++
>From 0312bec0d7573b0549a222fb5d0a695fcf819dc3 Mon Sep 17 00:00:00 2001
From: Richard Smith <rich...@metafoo.co.uk>
Date: Tue, 29 Sep 2020 15:20:11 -0700
Subject: [PATCH] Recognize setjmp and friends as builtins even if jmp_buf is
 not declared yet.

This happens in glibc's headers. It's important that we recognize these
functions so that we can mark them as returns_twice.

Differential Revision: https://reviews.llvm.org/D88518
---
 clang/include/clang/Basic/Builtins.def  | 25 +++++++-------
 clang/include/clang/Basic/Builtins.h    |  7 ++++
 clang/lib/Sema/SemaDecl.cpp             | 23 +++++++------
 clang/test/CodeGen/setjmp.c             | 44 +++++++++++++++++++++++++
 clang/test/Sema/builtin-setjmp.c        | 44 +++++++++++++++++++++----
 clang/test/Sema/implicit-builtin-decl.c |  5 ++-
 6 files changed, 116 insertions(+), 32 deletions(-)
 create mode 100644 clang/test/CodeGen/setjmp.c

diff --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 01c28ebab763..dbb5dde20a2b 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -75,6 +75,9 @@
 //  U -> pure
 //  c -> const
 //  t -> signature is meaningless, use custom typechecking
+//  T -> type is not important to semantic analysis and codegen; recognize as
+//       builtin even if type doesn't match signature, and don't warn if we
+//       can't be sure the type is right
 //  F -> this is a libc/libm function with a '__builtin_' prefix added.
 //  f -> this is a libc/libm function without the '__builtin_' prefix. It can
 //       be followed by ':headername:' to state which header this function
@@ -893,7 +896,7 @@ LANGBUILTIN(__va_start,       "vc**.", "nt", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(__fastfail, "vUi",    "nr", ALL_MS_LANGUAGES)
 
 // Microsoft library builtins.
-LIBBUILTIN(_setjmpex, "iJ", "fj",   "setjmpex.h", ALL_MS_LANGUAGES)
+LIBBUILTIN(_setjmpex, "iJ", "fjT", "setjmpex.h", ALL_MS_LANGUAGES)
 
 // C99 library functions
 // C99 stdarg.h
@@ -987,8 +990,8 @@ LIBBUILTIN(wmemmove,"w*w*wC*z", "f", "wchar.h", 
ALL_LANGUAGES)
 // In some systems setjmp is a macro that expands to _setjmp. We undefine
 // it here to avoid having two identical LIBBUILTIN entries.
 #undef setjmp
-LIBBUILTIN(setjmp, "iJ",          "fj",    "setjmp.h", ALL_LANGUAGES)
-LIBBUILTIN(longjmp, "vJi",        "fr",    "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(setjmp, "iJ",          "fjT",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(longjmp, "vJi",        "frT",   "setjmp.h", ALL_LANGUAGES)
 
 // Non-C library functions, active in GNU mode only.
 // Functions with (returns_twice) attribute (marked as "j") are still active in
@@ -1015,21 +1018,21 @@ LIBBUILTIN(strcasecmp, "icC*cC*", "f",     "strings.h", 
ALL_GNU_LANGUAGES)
 LIBBUILTIN(strncasecmp, "icC*cC*z", "f",   "strings.h", ALL_GNU_LANGUAGES)
 // POSIX unistd.h
 LIBBUILTIN(_exit, "vi",           "fr",    "unistd.h", ALL_GNU_LANGUAGES)
-LIBBUILTIN(vfork, "p",            "fj",    "unistd.h", ALL_LANGUAGES)
+LIBBUILTIN(vfork, "p",            "fjT",   "unistd.h", ALL_LANGUAGES)
 // POSIX pthread.h
 // FIXME: Should specify argument types.
 LIBBUILTIN(pthread_create, "",  "fC<2,3>", "pthread.h", ALL_GNU_LANGUAGES)
 
 // POSIX setjmp.h
 
-LIBBUILTIN(_setjmp, "iJ",         "fj",   "setjmp.h", ALL_LANGUAGES)
-LIBBUILTIN(__sigsetjmp, "iSJi",   "fj",   "setjmp.h", ALL_LANGUAGES)
-LIBBUILTIN(sigsetjmp, "iSJi",     "fj",   "setjmp.h", ALL_LANGUAGES)
-LIBBUILTIN(savectx, "iJ",         "fj",   "setjmp.h", ALL_LANGUAGES)
-LIBBUILTIN(getcontext, "iK*",     "fj",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(_setjmp, "iJ",         "fjT",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(__sigsetjmp, "iSJi",   "fjT",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(sigsetjmp, "iSJi",     "fjT",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(savectx, "iJ",         "fjT",   "setjmp.h", ALL_LANGUAGES)
+LIBBUILTIN(getcontext, "iK*",     "fjT",   "setjmp.h", ALL_LANGUAGES)
 
-LIBBUILTIN(_longjmp, "vJi",       "fr",    "setjmp.h", ALL_GNU_LANGUAGES)
-LIBBUILTIN(siglongjmp, "vSJi",    "fr",    "setjmp.h", ALL_GNU_LANGUAGES)
+LIBBUILTIN(_longjmp, "vJi",       "frT",   "setjmp.h", ALL_GNU_LANGUAGES)
+LIBBUILTIN(siglongjmp, "vSJi",    "frT",   "setjmp.h", ALL_GNU_LANGUAGES)
 // non-standard but very common
 LIBBUILTIN(strlcpy, "zc*cC*z",    "f",     "string.h", ALL_GNU_LANGUAGES)
 LIBBUILTIN(strlcat, "zc*cC*z",    "f",     "string.h", ALL_GNU_LANGUAGES)
diff --git a/clang/include/clang/Basic/Builtins.h 
b/clang/include/clang/Basic/Builtins.h
index e4ed482d9068..15bfcf797917 100644
--- a/clang/include/clang/Basic/Builtins.h
+++ b/clang/include/clang/Basic/Builtins.h
@@ -158,6 +158,13 @@ public:
     return strchr(getRecord(ID).Attributes, 't') != nullptr;
   }
 
+  /// Determines whether a declaration of this builtin should be recognized
+  /// even if the type doesn't match the specified signature.
+  bool allowTypeMismatch(unsigned ID) const {
+    return strchr(getRecord(ID).Attributes, 'T') != nullptr ||
+           hasCustomTypechecking(ID);
+  }
+
   /// Determines whether this builtin has a result or any arguments which
   /// are pointer types.
   bool hasPtrArgsOrResult(unsigned ID) const {
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 82c78e3003f0..5b0417fa8859 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2107,7 +2107,8 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, 
unsigned ID,
 
     // If we have a builtin without an associated type we should not emit a
     // warning when we were not able to find a type for it.
-    if (Error == ASTContext::GE_Missing_type)
+    if (Error == ASTContext::GE_Missing_type ||
+        Context.BuiltinInfo.allowTypeMismatch(ID))
       return nullptr;
 
     // If we could not find a type for setjmp it is because the jmp_buf type 
was
@@ -2131,11 +2132,9 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, 
unsigned ID,
        Context.BuiltinInfo.isHeaderDependentFunction(ID))) {
     Diag(Loc, diag::ext_implicit_lib_function_decl)
         << Context.BuiltinInfo.getName(ID) << R;
-    if (Context.BuiltinInfo.getHeaderName(ID) &&
-        !Diags.isIgnored(diag::ext_implicit_lib_function_decl, Loc))
+    if (const char *Header = Context.BuiltinInfo.getHeaderName(ID))
       Diag(Loc, diag::note_include_header_or_declare)
-          << Context.BuiltinInfo.getHeaderName(ID)
-          << Context.BuiltinInfo.getName(ID);
+          << Header << Context.BuiltinInfo.getName(ID);
   }
 
   if (R.isNull())
@@ -9630,16 +9629,16 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
     }
   }
 
-  // In C builtins get merged with implicitly lazily created declarations.
-  // In C++ we need to check if it's a builtin and add the BuiltinAttr here.
-  if (getLangOpts().CPlusPlus) {
+  // If this is the first declaration of a library builtin function, add
+  // attributes as appropriate.
+  if (!D.isRedeclaration() &&
+      NewFD->getDeclContext()->getRedeclContext()->isFileContext()) {
     if (IdentifierInfo *II = Previous.getLookupName().getAsIdentifierInfo()) {
       if (unsigned BuiltinID = II->getBuiltinID()) {
         if (NewFD->getLanguageLinkage() == CLanguageLinkage) {
-          // Declarations for builtins with custom typechecking by definition
-          // don't make sense. Don't attempt typechecking and simply add the
-          // attribute.
-          if (Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) {
+          // Validate the type matches unless this builtin is specified as
+          // matching regardless of its declared type.
+          if (Context.BuiltinInfo.allowTypeMismatch(BuiltinID)) {
             NewFD->addAttr(BuiltinAttr::CreateImplicit(Context, BuiltinID));
           } else {
             ASTContext::GetBuiltinTypeError Error;
diff --git a/clang/test/CodeGen/setjmp.c b/clang/test/CodeGen/setjmp.c
new file mode 100644
index 000000000000..4ca360d8584c
--- /dev/null
+++ b/clang/test/CodeGen/setjmp.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -x c %s -triple x86_64-linux-gnu -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 -x c++ %s -triple x86_64-linux-gnu -emit-llvm -o - | 
FileCheck %s
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct __jmp_buf_tag { int n; };
+int setjmp(struct __jmp_buf_tag*);
+int sigsetjmp(struct __jmp_buf_tag*, int);
+int _setjmp(struct __jmp_buf_tag*);
+int __sigsetjmp(struct __jmp_buf_tag*, int);
+
+typedef struct __jmp_buf_tag jmp_buf[1];
+typedef struct __jmp_buf_tag sigjmp_buf[1];
+
+#ifdef __cplusplus
+}
+#endif
+
+void f() {
+  jmp_buf jb;
+  // CHECK: call {{.*}}@setjmp(
+  setjmp(jb);
+  // CHECK: call {{.*}}@sigsetjmp(
+  sigsetjmp(jb, 0);
+  // CHECK: call {{.*}}@_setjmp(
+  _setjmp(jb);
+  // CHECK: call {{.*}}@__sigsetjmp(
+  __sigsetjmp(jb, 0);
+}
+
+// CHECK: ; Function Attrs: returns_twice
+// CHECK-NEXT: declare {{.*}} @setjmp(
+
+// CHECK: ; Function Attrs: returns_twice
+// CHECK-NEXT: declare {{.*}} @sigsetjmp(
+
+// CHECK: ; Function Attrs: returns_twice
+// CHECK-NEXT: declare {{.*}} @_setjmp(
+
+// CHECK: ; Function Attrs: returns_twice
+// CHECK-NEXT: declare {{.*}} @__sigsetjmp(
+
diff --git a/clang/test/Sema/builtin-setjmp.c b/clang/test/Sema/builtin-setjmp.c
index f8770d88e731..6a114fad05d9 100644
--- a/clang/test/Sema/builtin-setjmp.c
+++ b/clang/test/Sema/builtin-setjmp.c
@@ -1,10 +1,42 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DNO_JMP_BUF %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DNO_JMP_BUF %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DWRONG_JMP_BUF %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DRIGHT_JMP_BUF %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DONLY_JMP_BUF %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify 
-DNO_SETJMP %s -ast-dump 2>&1 | FileCheck %s
 
 #ifdef NO_JMP_BUF
-extern long setjmp(long *);   // expected-warning {{declaration of built-in 
function 'setjmp' requires the declaration of the 'jmp_buf' type, commonly 
provided in the header <setjmp.h>.}}
-#else
+// This happens in some versions of glibc: the declaration of __sigsetjmp
+// precedes the declaration of sigjmp_buf.
+extern long setjmp(long *); // Can't check, so we trust that this is the right 
type
+// FIXME: We could still diagnose the missing `jmp_buf` at the point of the 
call.
+// expected-no-diagnostics
+#elif WRONG_JMP_BUF
 typedef long jmp_buf;
-extern int setjmp(char);      // expected-warning@8 {{incompatible 
redeclaration of library function 'setjmp'}}
-                              // expected-note@8    {{'setjmp' is a builtin 
with type 'int (jmp_buf)' (aka 'int (long)')}}
+extern int setjmp(char); // expected-warning {{incompatible redeclaration of 
library function 'setjmp'}}
+                         // expected-note@-1 {{'setjmp' is a builtin with type 
'int (jmp_buf)' (aka 'int (long)')}}
+#elif RIGHT_JMP_BUF
+typedef long jmp_buf;
+extern int setjmp(long); // OK, right type.
+// expected-no-diagnostics
+#elif ONLY_JMP_BUF
+typedef int *jmp_buf;
 #endif
+
+void use() {
+  setjmp(0);
+  #ifdef NO_SETJMP
+  // expected-warning@-2 {{implicit declaration of function 'setjmp' is 
invalid in C99}}
+  #elif ONLY_JMP_BUF
+  // expected-warning@-4 {{implicitly declaring library function 'setjmp' with 
type 'int (jmp_buf)' (aka 'int (int *)')}}
+  // expected-note@-5 {{include the header <setjmp.h> or explicitly provide a 
declaration for 'setjmp'}}
+  #endif
+
+  #ifdef NO_SETJMP
+  // In this case, the regular AST dump doesn't dump the implicit declaration 
of 'setjmp'.
+  #pragma clang __debug dump setjmp
+  #endif
+}
+
+// CHECK: FunctionDecl {{.*}} used setjmp
+// CHECK: BuiltinAttr {{.*}} Implicit
+// CHECK: ReturnsTwiceAttr {{.*}} Implicit
diff --git a/clang/test/Sema/implicit-builtin-decl.c 
b/clang/test/Sema/implicit-builtin-decl.c
index b25e86bc03a3..9434b507a3af 100644
--- a/clang/test/Sema/implicit-builtin-decl.c
+++ b/clang/test/Sema/implicit-builtin-decl.c
@@ -54,13 +54,12 @@ main(int argc, char *argv[])
 
 void snprintf() { }
 
-// PR8316 & PR40692
-void longjmp(); // expected-warning{{declaration of built-in function 
'longjmp' requires the declaration of the 'jmp_buf' type, commonly provided in 
the header <setjmp.h>.}}
+void longjmp();
 
 extern float fmaxf(float, float);
 
 struct __jmp_buf_tag {};
-void sigsetjmp(struct __jmp_buf_tag[1], int); // expected-warning{{declaration 
of built-in function 'sigsetjmp' requires the declaration of the 'jmp_buf' 
type, commonly provided in the header <setjmp.h>.}}
+void sigsetjmp(struct __jmp_buf_tag[1], int);
 
 // PR40692
 void pthread_create(); // no warning expected
-- 
2.30.0

++++++ Sema-Handle-objc_super-special-lookup-when-checking-.patch ++++++
>From fdab756331f322a9818c1bdf14d23d9cd6036c81 Mon Sep 17 00:00:00 2001
From: Raul Tambre <raul.tam...@cleveron.com>
Date: Fri, 18 Sep 2020 20:07:05 +0300
Subject: [PATCH] [Sema] Handle objc_super special lookup when checking builtin
 compatibility

objc_super is special and needs LookupPredefedObjCSuperType() called before 
performing builtin type comparisons.
This fixes an error when compiling macOS headers. A test is added.

Differential Revision: https://reviews.llvm.org/D87917
---
 clang/lib/Sema/SemaDecl.cpp                | 1 +
 clang/test/SemaObjCXX/builtin-objcsuper.mm | 8 ++++++++
 2 files changed, 9 insertions(+)
 create mode 100644 clang/test/SemaObjCXX/builtin-objcsuper.mm

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 2703d9876f85..82c78e3003f0 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9643,6 +9643,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
             NewFD->addAttr(BuiltinAttr::CreateImplicit(Context, BuiltinID));
           } else {
             ASTContext::GetBuiltinTypeError Error;
+            LookupPredefedObjCSuperType(*this, S, NewFD->getIdentifier());
             QualType BuiltinType = Context.GetBuiltinType(BuiltinID, Error);
 
             if (!Error && !BuiltinType.isNull() &&
diff --git a/clang/test/SemaObjCXX/builtin-objcsuper.mm 
b/clang/test/SemaObjCXX/builtin-objcsuper.mm
new file mode 100644
index 000000000000..a6baf3c5165a
--- /dev/null
+++ b/clang/test/SemaObjCXX/builtin-objcsuper.mm
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify %s
+// expected-no-diagnostics
+
+// objc_super has special lookup rules for compatibility with macOS headers, so
+// the following should compile.
+struct objc_super {};
+extern "C" id objc_msgSendSuper(struct objc_super *super, SEL op, ...);
+extern "C" void objc_msgSendSuper_stret(struct objc_super *super, SEL op, ...);
-- 
2.30.0

++++++ Sema-Introduce-BuiltinAttr-per-declaration-builtin-n.patch ++++++
++++ 900 lines (skipped)

Reply via email to