Skip to content

[clang] Add zero-initialization for fixed point types #80781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

PiJoules
Copy link
Contributor

@PiJoules PiJoules commented Feb 6, 2024

No description provided.

@PiJoules PiJoules requested review from petrhosek and MaskRay February 6, 2024 01:59
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Feb 6, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 6, 2024

@llvm/pr-subscribers-clang

Author: None (PiJoules)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/80781.diff

2 Files Affected:

  • (modified) clang/lib/AST/ExprConstant.cpp (+4)
  • (added) clang/test/CodeGenCXX/fixed-point-zero-init.cpp (+9)
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 63453890d9879..089bc2094567f 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -11427,6 +11427,10 @@ class FixedPointExprEvaluator
     return true;
   }
 
+  bool ZeroInitialization(const Expr *E) {
+    return Success(0, E);
+  }
+
   //===--------------------------------------------------------------------===//
   //                            Visitor Methods
   //===--------------------------------------------------------------------===//
diff --git a/clang/test/CodeGenCXX/fixed-point-zero-init.cpp b/clang/test/CodeGenCXX/fixed-point-zero-init.cpp
new file mode 100644
index 0000000000000..9a7a6600fe556
--- /dev/null
+++ b/clang/test/CodeGenCXX/fixed-point-zero-init.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: @_ZL1a = internal constant [2 x i32] zeroinitializer
+constexpr _Accum a[2] = {};
+
+void func2(const _Accum *);
+void func() {
+  func2(a);
+}

Copy link

github-actions bot commented Feb 6, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 4d8e849dfbf3ca1301f208a7286b31215d2a94db 3b267b1aeb49aa5ab54920da5f6a1fa7492ae88c -- clang/test/AST/fixed-point-zero-init.cpp clang/lib/AST/ExprConstant.cpp
View the diff from clang-format here.
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 089bc20945..79541ff8ea 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -11427,9 +11427,7 @@ class FixedPointExprEvaluator
     return true;
   }
 
-  bool ZeroInitialization(const Expr *E) {
-    return Success(0, E);
-  }
+  bool ZeroInitialization(const Expr *E) { return Success(0, E); }
 
   //===--------------------------------------------------------------------===//
   //                            Visitor Methods

@PiJoules PiJoules force-pushed the fixed-point-zero-init branch from 916a10f to 3b267b1 Compare February 6, 2024 23:42
@PiJoules PiJoules requested a review from MaskRay February 6, 2024 23:42
@PiJoules PiJoules merged commit 42357df into llvm:main Feb 6, 2024
@PiJoules PiJoules deleted the fixed-point-zero-init branch February 6, 2024 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants