[PATCH] D114834: [clang]Fix assertion failure when passing bool as the type of next parameter

2021-11-30 Thread Lucas Wang via Phabricator via cfe-commits
Lucas created this revision.
Lucas requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114834

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/varargs.cpp


Index: clang/test/SemaCXX/varargs.cpp
===
--- clang/test/SemaCXX/varargs.cpp
+++ clang/test/SemaCXX/varargs.cpp
@@ -53,6 +53,8 @@
 
   // Ensure that signed vs unsigned doesn't matter either.
   (void)__builtin_va_arg(ap, unsigned int);
+
+  (void)__builtin_va_arg(ap, bool); // expected-warning {{second argument to 
'va_arg' is of promotable type 'bool'; this va_arg has undefined behavior 
because arguments will be promoted to 'int'}}
 }
 
 #if __cplusplus >= 201103L
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15902,9 +15902,10 @@
 
   // If the types are still not compatible, we need to test whether the
   // promoted type and the underlying type are the same except for
-  // signedness. Ask the AST for the correctly corresponding type and see
-  // if that's compatible.
+  // signedness except for boolean. Ask the AST for the correctly 
corresponding
+  // type and see if that's compatible.
   if (!PromoteType.isNull() &&
+  !UnderlyingType->isBooleanType() &&
   PromoteType->isUnsignedIntegerType() !=
   UnderlyingType->isUnsignedIntegerType()) {
 UnderlyingType =


Index: clang/test/SemaCXX/varargs.cpp
===
--- clang/test/SemaCXX/varargs.cpp
+++ clang/test/SemaCXX/varargs.cpp
@@ -53,6 +53,8 @@
 
   // Ensure that signed vs unsigned doesn't matter either.
   (void)__builtin_va_arg(ap, unsigned int);
+
+  (void)__builtin_va_arg(ap, bool); // expected-warning {{second argument to 'va_arg' is of promotable type 'bool'; this va_arg has undefined behavior because arguments will be promoted to 'int'}}
 }
 
 #if __cplusplus >= 201103L
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15902,9 +15902,10 @@
 
   // If the types are still not compatible, we need to test whether the
   // promoted type and the underlying type are the same except for
-  // signedness. Ask the AST for the correctly corresponding type and see
-  // if that's compatible.
+  // signedness except for boolean. Ask the AST for the correctly corresponding
+  // type and see if that's compatible.
   if (!PromoteType.isNull() &&
+  !UnderlyingType->isBooleanType() &&
   PromoteType->isUnsignedIntegerType() !=
   UnderlyingType->isUnsignedIntegerType()) {
 UnderlyingType =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114839: Reformat code style

2021-11-30 Thread Lucas Wang via Phabricator via cfe-commits
Lucas created this revision.
Lucas requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114839

Files:
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15902,10 +15902,9 @@
 
   // If the types are still not compatible, we need to test whether the
   // promoted type and the underlying type are the same except for
-  // signedness except for boolean. Ask the AST for the correctly 
corresponding
-  // type and see if that's compatible.
-  if (!PromoteType.isNull() &&
-  !UnderlyingType->isBooleanType() &&
+  // signedness except for boolean. Ask the AST for the correctly
+  // corresponding type and see if that's compatible.
+  if (!PromoteType.isNull() && !UnderlyingType->isBooleanType() &&
   PromoteType->isUnsignedIntegerType() !=
   UnderlyingType->isUnsignedIntegerType()) {
 UnderlyingType =


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15902,10 +15902,9 @@
 
   // If the types are still not compatible, we need to test whether the
   // promoted type and the underlying type are the same except for
-  // signedness except for boolean. Ask the AST for the correctly corresponding
-  // type and see if that's compatible.
-  if (!PromoteType.isNull() &&
-  !UnderlyingType->isBooleanType() &&
+  // signedness except for boolean. Ask the AST for the correctly
+  // corresponding type and see if that's compatible.
+  if (!PromoteType.isNull() && !UnderlyingType->isBooleanType() &&
   PromoteType->isUnsignedIntegerType() !=
   UnderlyingType->isUnsignedIntegerType()) {
 UnderlyingType =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114834: [clang][PR52088]Fix assertion failure when passing bool as the type of next parameter

2021-11-30 Thread Lucas Wang via Phabricator via cfe-commits
Lucas updated this revision to Diff 390886.
Lucas added a comment.

Checking with clang-format.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114834/new/

https://reviews.llvm.org/D114834

Files:
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15902,10 +15902,9 @@
 
   // If the types are still not compatible, we need to test whether the
   // promoted type and the underlying type are the same except for
-  // signedness except for boolean. Ask the AST for the correctly 
corresponding
-  // type and see if that's compatible.
-  if (!PromoteType.isNull() &&
-  !UnderlyingType->isBooleanType() &&
+  // signedness except for boolean. Ask the AST for the correctly
+  // corresponding type and see if that's compatible.
+  if (!PromoteType.isNull() && !UnderlyingType->isBooleanType() &&
   PromoteType->isUnsignedIntegerType() !=
   UnderlyingType->isUnsignedIntegerType()) {
 UnderlyingType =


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15902,10 +15902,9 @@
 
   // If the types are still not compatible, we need to test whether the
   // promoted type and the underlying type are the same except for
-  // signedness except for boolean. Ask the AST for the correctly corresponding
-  // type and see if that's compatible.
-  if (!PromoteType.isNull() &&
-  !UnderlyingType->isBooleanType() &&
+  // signedness except for boolean. Ask the AST for the correctly
+  // corresponding type and see if that's compatible.
+  if (!PromoteType.isNull() && !UnderlyingType->isBooleanType() &&
   PromoteType->isUnsignedIntegerType() !=
   UnderlyingType->isUnsignedIntegerType()) {
 UnderlyingType =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114834: [clang][PR52088]Fix assertion failure when passing bool as the type of next parameter

2021-11-30 Thread Lucas Wang via Phabricator via cfe-commits
Lucas updated this revision to Diff 390889.
Lucas added a comment.

Include all local changes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114834/new/

https://reviews.llvm.org/D114834

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/varargs.cpp


Index: clang/test/SemaCXX/varargs.cpp
===
--- clang/test/SemaCXX/varargs.cpp
+++ clang/test/SemaCXX/varargs.cpp
@@ -53,6 +53,8 @@
 
   // Ensure that signed vs unsigned doesn't matter either.
   (void)__builtin_va_arg(ap, unsigned int);
+
+  (void)__builtin_va_arg(ap, bool); // expected-warning {{second argument to 
'va_arg' is of promotable type 'bool'; this va_arg has undefined behavior 
because arguments will be promoted to 'int'}}
 }
 
 #if __cplusplus >= 201103L
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15902,9 +15902,9 @@
 
   // If the types are still not compatible, we need to test whether the
   // promoted type and the underlying type are the same except for
-  // signedness. Ask the AST for the correctly corresponding type and see
-  // if that's compatible.
-  if (!PromoteType.isNull() &&
+  // signedness except for boolean. Ask the AST for the correctly
+  // corresponding type and see if that's compatible.
+  if (!PromoteType.isNull() && !UnderlyingType->isBooleanType() &&
   PromoteType->isUnsignedIntegerType() !=
   UnderlyingType->isUnsignedIntegerType()) {
 UnderlyingType =


Index: clang/test/SemaCXX/varargs.cpp
===
--- clang/test/SemaCXX/varargs.cpp
+++ clang/test/SemaCXX/varargs.cpp
@@ -53,6 +53,8 @@
 
   // Ensure that signed vs unsigned doesn't matter either.
   (void)__builtin_va_arg(ap, unsigned int);
+
+  (void)__builtin_va_arg(ap, bool); // expected-warning {{second argument to 'va_arg' is of promotable type 'bool'; this va_arg has undefined behavior because arguments will be promoted to 'int'}}
 }
 
 #if __cplusplus >= 201103L
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15902,9 +15902,9 @@
 
   // If the types are still not compatible, we need to test whether the
   // promoted type and the underlying type are the same except for
-  // signedness. Ask the AST for the correctly corresponding type and see
-  // if that's compatible.
-  if (!PromoteType.isNull() &&
+  // signedness except for boolean. Ask the AST for the correctly
+  // corresponding type and see if that's compatible.
+  if (!PromoteType.isNull() && !UnderlyingType->isBooleanType() &&
   PromoteType->isUnsignedIntegerType() !=
   UnderlyingType->isUnsignedIntegerType()) {
 UnderlyingType =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits