<div dir="ltr">Nice, that seems like a reasonable expedient compromise. :)</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Feb 21, 2015 at 10:36 PM, Larisse Voufo <span dir="ltr"><<a href="mailto:lvoufo@google.com" target="_blank">lvoufo@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: lvoufo<br>
Date: Sun Feb 22 00:36:53 2015<br>
New Revision: 230160<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=230160&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=230160&view=rev</a><br>
Log:<br>
Relax the requirement on sized deallocation a bit: Default on unsized delete if sized delete is not provided in global scope, and -fdefine-sized-deallocation option is disabled.<br>
<br>
Modified:<br>
    cfe/trunk/lib/Sema/SemaExprCXX.cpp<br>
    cfe/trunk/test/CodeGenCXX/cxx1y-sized-deallocation.cpp<br>
    cfe/trunk/test/CodeGenCXX/implicit-allocation-functions.cpp<br>
    cfe/trunk/test/SemaCXX/cxx1y-sized-deallocation.cpp<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=230160&r1=230159&r2=230160&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=230160&r1=230159&r2=230160&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sun Feb 22 00:36:53 2015<br>
@@ -2089,6 +2089,15 @@ void Sema::DeclareGlobalAllocationFuncti<br>
       }<br>
     }<br>
   }<br>
+<br>
+  // If the function is sized operator delete and has not already been<br>
+  // declared, and weak definitions have been disabled, do not declare<br>
+  // it implicitly. Instead, let deallocation function lookup pick up<br>
+  // unsized delete.<br>
+  // FIXME: We should remove this guard once backward compatibility is<br>
+  // no longer an issue<br>
+  if (NumParams == 2 && !getLangOpts().DefineSizedDeallocation)<br>
+    return;<br>
<br>
   FunctionProtoType::ExtProtoInfo EPI;<br>
<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/cxx1y-sized-deallocation.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx1y-sized-deallocation.cpp?rev=230160&r1=230159&r2=230160&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx1y-sized-deallocation.cpp?rev=230160&r1=230159&r2=230160&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/cxx1y-sized-deallocation.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/cxx1y-sized-deallocation.cpp Sun Feb 22 00:36:53 2015<br>
@@ -1,6 +1,8 @@<br>
-// RUN: %clang_cc1 -std=c++1y %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKUND<br>
+// RUN: %clang_cc1 -std=c++1y %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK-UNSIZED<br>
+// RUN: %clang_cc1 -std=c++1y %s -emit-llvm -triple x86_64-linux-gnu -o - -DINLIB | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKUND<br>
 // RUN: %clang_cc1 -std=c++1y %s -emit-llvm -triple x86_64-linux-gnu -fdefine-sized-deallocation -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKDEF<br>
-// RUN: %clang_cc1 -std=c++11 -fsized-deallocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKUND<br>
+// RUN: %clang_cc1 -std=c++11 -fsized-deallocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK-UNSIZED<br>
+// RUN: %clang_cc1 -std=c++11 -fsized-deallocation %s -emit-llvm -triple x86_64-linux-gnu -o - -DINLIB | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKUND<br>
 // RUN: %clang_cc1 -std=c++11 -fsized-deallocation -fdefine-sized-deallocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECKDEF<br>
 // RUN: %clang_cc1 -std=c++11 %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK-UNSIZED<br>
 // RUN: %clang_cc1 -std=c++1y %s -emit-llvm -triple x86_64-linux-gnu -fno-sized-deallocation -o - | FileCheck %s --check-prefix=CHECK-UNSIZED<br>
@@ -10,6 +12,11 @@<br>
<br>
 typedef decltype(sizeof(0)) size_t;<br>
<br>
+#ifdef INLIB<br>
+void operator delete(void *, size_t) noexcept;<br>
+void operator delete[](void *, size_t) noexcept;<br>
+#endif<br>
+<br>
 typedef int A;<br>
 struct B { int n; };<br>
 struct C { ~C() {} };<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/implicit-allocation-functions.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/implicit-allocation-functions.cpp?rev=230160&r1=230159&r2=230160&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/implicit-allocation-functions.cpp?rev=230160&r1=230159&r2=230160&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/implicit-allocation-functions.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/implicit-allocation-functions.cpp Sun Feb 22 00:36:53 2015<br>
@@ -1,15 +1,20 @@<br>
 // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o - -std=c++11 %s 2>&1 | FileCheck %s -check-prefix=CHECKDEF -check-prefix=CHECK11<br>
 // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o - -std=c++11 -fvisibility hidden %s 2>&1 | FileCheck %s -check-prefix=CHECKHID -check-prefix=CHECK11<br>
-// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o - -std=c++14 -fno-sized-deallocation %s 2>&1 | FileCheck %s -check-prefix=CHECKDEF -check-prefix=CHECK11<br>
-// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o - -std=c++14 %s 2>&1 | FileCheck %s -check-prefix=CHECKDEF -check-prefix=CHECK14 -check-prefix=CHECK14UND<br>
-// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o - -std=c++14 -fvisibility hidden %s 2>&1 | FileCheck %s -check-prefix=CHECKHID -check-prefix=CHECK14 -check-prefix=CHECK14UND<br>
-// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o - -std=c++14 -fdefine-sized-deallocation %s 2>&1 | FileCheck %s -check-prefix=CHECKDEF -check-prefix=CHECK14 -check-prefix=CHECK14DEFCOMDAT<br>
-// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o - -std=c++14 -fdefine-sized-deallocation -fvisibility hidden %s 2>&1 | FileCheck %s -check-prefix=CHECKHID -check-prefix=CHECK14 -check-prefix=CHECK14DEFCOMDAT<br>
-// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-macosx -o - -std=c++14 -fdefine-sized-deallocation %s | FileCheck %s -check-prefix=CHECKDEF -check-prefix=CHECK14 -check-prefix=CHECK14DEFNOCOMDAT<br>
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o - -std=c++14 -DINLIB -fno-sized-deallocation %s 2>&1 | FileCheck %s -check-prefix=CHECKDEF -check-prefix=CHECK11<br>
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o - -std=c++14 -DINLIB %s 2>&1 | FileCheck %s -check-prefix=CHECKDEF -check-prefix=CHECK14 -check-prefix=CHECK14UND<br>
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o - -std=c++14 -DINLIB -fvisibility hidden %s 2>&1 | FileCheck %s -check-prefix=CHECKHID -check-prefix=CHECK14 -check-prefix=CHECK14UND<br>
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o - -std=c++14 -DINLIB -fdefine-sized-deallocation %s 2>&1 | FileCheck %s -check-prefix=CHECKDEF -check-prefix=CHECK14 -check-prefix=CHECK14DEFCOMDAT<br>
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-unknown -o - -std=c++14 -DINLIB -fdefine-sized-deallocation -fvisibility hidden %s 2>&1 | FileCheck %s -check-prefix=CHECKHID -check-prefix=CHECK14 -check-prefix=CHECK14DEFCOMDAT<br>
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-macosx -o - -std=c++14 -DINLIB -fdefine-sized-deallocation %s | FileCheck %s -check-prefix=CHECKDEF -check-prefix=CHECK14 -check-prefix=CHECK14DEFNOCOMDAT<br>
<br>
 // PR22419: Implicit sized deallocation functions always have default visibility.<br>
 //   Generalized to all implicit allocation functions.<br>
<br>
+#ifdef INLIB<br>
+typedef decltype(sizeof(0)) size_t;<br>
+void operator delete(void *, size_t) noexcept;<br>
+void operator delete[](void *, size_t) noexcept;<br>
+#endif<br>
<br>
 // CHECK14-DAG: %struct.A = type { i8 }<br>
 struct A { };<br>
<br>
Modified: cfe/trunk/test/SemaCXX/cxx1y-sized-deallocation.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-sized-deallocation.cpp?rev=230160&r1=230159&r2=230160&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-sized-deallocation.cpp?rev=230160&r1=230159&r2=230160&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/cxx1y-sized-deallocation.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/cxx1y-sized-deallocation.cpp Sun Feb 22 00:36:53 2015<br>
@@ -1,6 +1,8 @@<br>
 // RUN: %clang_cc1 -std=c++1y -verify %s -fsized-deallocation -fexceptions -fcxx-exceptions<br>
<br>
 using size_t = decltype(sizeof(0));<br>
+void operator delete(void *, size_t) noexcept;   // expected-note {{'operator delete' declared here}}<br>
+void operator delete[](void *, size_t) noexcept;<br>
<br>
 void f(void *p, void *q) {<br>
   // OK, implicitly declared.<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>