]> granicus.if.org Git - clang/commitdiff
Remove an overly aggressive assert in r298491 and leave a comment
authorChandler Carruth <chandlerc@gmail.com>
Wed, 22 Mar 2017 10:38:07 +0000 (10:38 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 22 Mar 2017 10:38:07 +0000 (10:38 +0000)
explaining why we have to ignore errors here even though in other parts
of codegen we can be more strict with builtins.

Also add a test case based on the code in a TSan test that found this
issue.

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

lib/CodeGen/CGCall.cpp
test/CodeGen/function-attributes.c

index b9090b413c6c2010358e39b73a39bc8c9cb2b9c7..e56fe2c1c1d42b9e5af3c36417a83e4c3d8d19cf 100644 (file)
@@ -1813,7 +1813,11 @@ void CodeGenModule::ConstructAttributeList(
     ASTContext::GetBuiltinTypeError Error;
     getContext().GetBuiltinType(BuiltinID, Error, nullptr,
                                 &OverrideNonnullReturn, &OverrideNonnullArgs);
-    assert(Error == ASTContext::GE_None && "Should not codegen an error");
+    // Note that we can't check the 'Error' here as there may be errors that
+    // have been diagnosed and reported to the programmer as warnings but
+    // repaired in the AST such as for implicit declarations of builtin
+    // functions. None of those impact our usage of this to analyze attributes
+    // for the builtins.
   }
 
   bool HasOptnone = false;
index 2139f6fe65460a45723bae901e657c89c22788d9..49f47bf74d4b2088ca07e3f6853e0007c367941f 100644 (file)
@@ -108,6 +108,20 @@ void f20(void) {
   _setjmp(0);
 }
 
+// Bogus declarations that will end up with bad types when detecting builtins,
+// but that we will still process when considering whether to add attributes.
+struct __jmp_buf_tag;
+extern int __sigsetjmp(struct __jmp_buf_tag *__env, int __savemask);
+
+// CHECK-LABEL: define void @f21()
+// CHECK: {
+// CHECK: call i32 @__sigsetjmp(%{{.*}}* null, i32 0)
+// CHECK: [[RT_CALL]]
+// CHECK: ret void
+void f21(void) {
+  __sigsetjmp(0, 0);
+}
+
 // CHECK: attributes [[NUW]] = { nounwind optsize{{.*}} }
 // CHECK: attributes [[AI]] = { alwaysinline nounwind optsize{{.*}} }
 // CHECK: attributes [[NUW_OS_RN]] = { nounwind optsize readnone{{.*}} }