]> granicus.if.org Git - clang/commitdiff
[c++1z] Include "noexcept" in builtin function types where appropriate. Fixes
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 18 Oct 2016 07:13:55 +0000 (07:13 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 18 Oct 2016 07:13:55 +0000 (07:13 +0000)
an assertion failure looking up a matching ::operator delete for
__builtin_operator_delete.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284458 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/Analysis/cfg.cpp
test/CodeGenCXX/cxx1z-noexcept-function-type.cpp [new file with mode: 0644]

index d2f01c0c12d3517e5a34103c4adf3a77b490b0c9..318523eed91df58f52311d3d50a798d47b48ac93 100644 (file)
@@ -8671,6 +8671,9 @@ QualType ASTContext::GetBuiltinType(unsigned Id,
   FunctionProtoType::ExtProtoInfo EPI;
   EPI.ExtInfo = EI;
   EPI.Variadic = Variadic;
+  if (getLangOpts().CPlusPlus && BuiltinInfo.isNoThrow(Id))
+    EPI.ExceptionSpec.Type =
+        getLangOpts().CPlusPlus11 ? EST_BasicNoexcept : EST_DynamicNone;
 
   return getFunctionType(ResType, ArgTypes, EPI);
 }
index f35a1fcc1c3c784a9911394df372892dfa315daa..4fa7f1d1b538f8a0b7a71405995e0add8b8629c4 100644 (file)
@@ -92,7 +92,7 @@ void F(EmptyE e) {
 // CHECK-NEXT: Succs (1): B1
 // CHECK: [B1]
 // CHECK-NEXT:   1: __builtin_object_size
-// CHECK-NEXT:   2: [B1.1] (ImplicitCastExpr, BuiltinFnToFnPtr, unsigned long (*)(const void *, int))
+// CHECK-NEXT:   2: [B1.1] (ImplicitCastExpr, BuiltinFnToFnPtr, unsigned long (*)(const void *, int) noexcept)
 // CHECK-NEXT:   3: [B1.2](dummy(), 0)
 // CHECK-NEXT:   4: (void)[B1.3] (CStyleCastExpr, ToVoid, void)
 // CHECK-NEXT:   Preds (1): B2
diff --git a/test/CodeGenCXX/cxx1z-noexcept-function-type.cpp b/test/CodeGenCXX/cxx1z-noexcept-function-type.cpp
new file mode 100644 (file)
index 0000000..d2d06fb
--- /dev/null
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -std=c++1z -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
+
+// CHECK-LABEL: define {{.*}} @_Z11builtin_newm(
+// CHECK: call {{.*}} @_Znwm(
+void *builtin_new(unsigned long n) { return __builtin_operator_new(n); }
+
+// CHECK-LABEL: define {{.*}} @_Z14builtin_deletePv(
+// CHECK: call {{.*}} @_ZdlPv(
+void builtin_delete(void *p) { return __builtin_operator_delete(p); }