[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 22 01:52:01 PST 2023


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 74cdb8e6f8c88b97204f540601a553b412d1cd56 1d70b7726e7d1f11622a6d5c8246b0737e024c8d -- clang/test/C/C2x/n3018.c clang/test/Parser/c23-constexpr.c clang/test/Sema/constexpr.c clang/lib/AST/Decl.cpp clang/lib/AST/ExprConstant.cpp clang/lib/Parse/ParseDecl.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaOverload.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 1f74d937bf..277a9023b9 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8621,7 +8621,8 @@ static bool checkForConflictWithNonVisibleExternC(Sema &S, const T *ND,
 }
 
 static bool CheckC23ConstexprVarTypeQualifiers(Sema &SemaRef,
-                                            SourceLocation VarLoc, QualType T) {
+                                               SourceLocation VarLoc,
+                                               QualType T) {
   if (const auto *A = SemaRef.Context.getAsArrayType(T)) {
     T = A->getElementType();
   }
@@ -14297,20 +14298,20 @@ static ImplicitConversionKind getConversionKind(QualType FromType,
                                                 QualType ToType) {
   if (ToType->isIntegerType()) {
     if (FromType->isComplexType())
-     return ICK_Complex_Real;
+      return ICK_Complex_Real;
     if (FromType->isFloatingType())
-     return ICK_Floating_Integral;
+      return ICK_Floating_Integral;
     if (FromType->isIntegerType())
-     return ICK_Integral_Conversion;
+      return ICK_Integral_Conversion;
   }
 
   if (ToType->isFloatingType()) {
     if (FromType->isComplexType())
-     return ICK_Complex_Real;
+      return ICK_Complex_Real;
     if (FromType->isFloatingType())
-     return ICK_Floating_Conversion;
+      return ICK_Floating_Conversion;
     if (FromType->isIntegerType())
-     return ICK_Floating_Integral;
+      return ICK_Floating_Integral;
   }
 
   return ICK_Identity;
@@ -14350,7 +14351,6 @@ static bool checkC23ConstexprInitConversion(Sema &S, const Expr *Init) {
   case NK_Variable_Narrowing:
   case NK_Not_Narrowing:
     return false;
-
   }
   llvm_unreachable("unhandled case in switch");
 }
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index dfb1dfc00c..0d3a9701b9 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -412,8 +412,7 @@ NarrowingKind StandardConversionSequence::getNarrowingKind(
         return NK_Dependent_Narrowing;
 
       Expr::EvalResult R;
-      if ((Ctx.getLangOpts().C23 &&
-           Initializer->EvaluateAsRValue(R, Ctx)) ||
+      if ((Ctx.getLangOpts().C23 && Initializer->EvaluateAsRValue(R, Ctx)) ||
           Initializer->isCXX11ConstantExpr(Ctx, &ConstantValue)) {
         // Constant!
         if (Ctx.getLangOpts().C23)
@@ -423,9 +422,9 @@ NarrowingKind StandardConversionSequence::getNarrowingKind(
         // Convert the source value into the target type.
         bool ignored;
         llvm::APFloat Converted = FloatVal;
-        llvm::APFloat::opStatus ConvertStatus = Converted.convert(
-          Ctx.getFloatTypeSemantics(ToType),
-          llvm::APFloat::rmNearestTiesToEven, &ignored);
+        llvm::APFloat::opStatus ConvertStatus =
+            Converted.convert(Ctx.getFloatTypeSemantics(ToType),
+                              llvm::APFloat::rmNearestTiesToEven, &ignored);
         Converted.convert(Ctx.getFloatTypeSemantics(FromType),
                           llvm::APFloat::rmNearestTiesToEven, &ignored);
         if (Ctx.getLangOpts().C23) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/73099


More information about the cfe-commits mailing list