[clang] [llvm] [NFC] Use fold expressions to replace discarded initializer_lists (PR #83693)

2024-03-02 Thread via cfe-commits

https://github.com/MagentaTreehouse created 
https://github.com/llvm/llvm-project/pull/83693

None

>From 7c5498a5844cd5000c31ebef7d9295c98d94f75e Mon Sep 17 00:00:00 2001
From: Mingyi Chen 
Date: Sat, 2 Mar 2024 16:06:39 -0500
Subject: [PATCH] [NFC] Use fold expressions to replace discarded
 initializer_lists

---
 clang/lib/AST/Interp/ByteCodeEmitter.cpp| 5 +
 llvm/lib/Target/AArch64/AArch64SLSHardening.cpp | 9 ++---
 llvm/lib/Target/ARM/ARMSLSHardening.cpp | 9 ++---
 llvm/lib/Target/X86/X86IndirectThunks.cpp   | 9 ++---
 4 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/clang/lib/AST/Interp/ByteCodeEmitter.cpp 
b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
index e1b954fcc68486..4fbfc0930fbaa1 100644
--- a/clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -302,10 +302,7 @@ bool ByteCodeEmitter::emitOp(Opcode Op, const Tys &... 
Args, const SourceInfo &S
   if (SI)
 SrcMap.emplace_back(Code.size(), SI);
 
-  // The initializer list forces the expression to be evaluated
-  // for each argument in the variadic template, in order.
-  (void)std::initializer_list{(emit(P, Code, Args, Success), 0)...};
-
+  (..., emit(P, Code, Args, Success));
   return Success;
 }
 
diff --git a/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp 
b/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
index 76dd5a2d713ebb..ce3bc0b1837558 100644
--- a/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
+++ b/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
@@ -412,20 +412,15 @@ class AArch64IndirectThunks : public MachineFunctionPass {
 private:
   std::tuple TIs;
 
-  // FIXME: When LLVM moves to C++17, these can become folds
   template 
   static void initTIs(Module &M,
   std::tuple &ThunkInserters) {
-(void)std::initializer_list{
-(std::get(ThunkInserters).init(M), 0)...};
+(..., std::get(ThunkInserters).init(M));
   }
   template 
   static bool runTIs(MachineModuleInfo &MMI, MachineFunction &MF,
  std::tuple &ThunkInserters) {
-bool Modified = false;
-(void)std::initializer_list{
-Modified |= std::get(ThunkInserters).run(MMI, MF)...};
-return Modified;
+return (0 | ... | std::get(ThunkInserters).run(MMI, MF));
   }
 };
 
diff --git a/llvm/lib/Target/ARM/ARMSLSHardening.cpp 
b/llvm/lib/Target/ARM/ARMSLSHardening.cpp
index 23d72b34902d0e..d9ff14ead60e27 100644
--- a/llvm/lib/Target/ARM/ARMSLSHardening.cpp
+++ b/llvm/lib/Target/ARM/ARMSLSHardening.cpp
@@ -404,20 +404,15 @@ class ARMIndirectThunks : public MachineFunctionPass {
 private:
   std::tuple TIs;
 
-  // FIXME: When LLVM moves to C++17, these can become folds
   template 
   static void initTIs(Module &M,
   std::tuple &ThunkInserters) {
-(void)std::initializer_list{
-(std::get(ThunkInserters).init(M), 0)...};
+(..., std::get(ThunkInserters).init(M));
   }
   template 
   static bool runTIs(MachineModuleInfo &MMI, MachineFunction &MF,
  std::tuple &ThunkInserters) {
-bool Modified = false;
-(void)std::initializer_list{
-Modified |= std::get(ThunkInserters).run(MMI, MF)...};
-return Modified;
+return (0 | ... | std::get(ThunkInserters).run(MMI, MF));
   }
 };
 
diff --git a/llvm/lib/Target/X86/X86IndirectThunks.cpp 
b/llvm/lib/Target/X86/X86IndirectThunks.cpp
index 9db667900bffb3..ecc52600f75933 100644
--- a/llvm/lib/Target/X86/X86IndirectThunks.cpp
+++ b/llvm/lib/Target/X86/X86IndirectThunks.cpp
@@ -118,20 +118,15 @@ class X86IndirectThunks : public MachineFunctionPass {
 private:
   std::tuple TIs;
 
-  // FIXME: When LLVM moves to C++17, these can become folds
   template 
   static void initTIs(Module &M,
   std::tuple &ThunkInserters) {
-(void)std::initializer_list{
-(std::get(ThunkInserters).init(M), 0)...};
+(..., std::get(ThunkInserters).init(M));
   }
   template 
   static bool runTIs(MachineModuleInfo &MMI, MachineFunction &MF,
  std::tuple &ThunkInserters) {
-bool Modified = false;
-(void)std::initializer_list{
-Modified |= std::get(ThunkInserters).run(MMI, MF)...};
-return Modified;
+return (0 | ... | std::get(ThunkInserters).run(MMI, MF));
   }
 };
 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [NFC] Use fold expressions to replace discarded initializer_lists (PR #83693)

2024-03-02 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

https://github.com/llvm/llvm-project/pull/83693
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [NFC] Use fold expressions to replace discarded initializer_lists (PR #83693)

2024-03-02 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-backend-aarch64
@llvm/pr-subscribers-backend-x86

@llvm/pr-subscribers-clang

Author: None (MagentaTreehouse)


Changes



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


4 Files Affected:

- (modified) clang/lib/AST/Interp/ByteCodeEmitter.cpp (+1-4) 
- (modified) llvm/lib/Target/AArch64/AArch64SLSHardening.cpp (+2-7) 
- (modified) llvm/lib/Target/ARM/ARMSLSHardening.cpp (+2-7) 
- (modified) llvm/lib/Target/X86/X86IndirectThunks.cpp (+2-7) 


``diff
diff --git a/clang/lib/AST/Interp/ByteCodeEmitter.cpp 
b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
index e1b954fcc68486..4fbfc0930fbaa1 100644
--- a/clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -302,10 +302,7 @@ bool ByteCodeEmitter::emitOp(Opcode Op, const Tys &... 
Args, const SourceInfo &S
   if (SI)
 SrcMap.emplace_back(Code.size(), SI);
 
-  // The initializer list forces the expression to be evaluated
-  // for each argument in the variadic template, in order.
-  (void)std::initializer_list{(emit(P, Code, Args, Success), 0)...};
-
+  (..., emit(P, Code, Args, Success));
   return Success;
 }
 
diff --git a/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp 
b/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
index 76dd5a2d713ebb..ce3bc0b1837558 100644
--- a/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
+++ b/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
@@ -412,20 +412,15 @@ class AArch64IndirectThunks : public MachineFunctionPass {
 private:
   std::tuple TIs;
 
-  // FIXME: When LLVM moves to C++17, these can become folds
   template 
   static void initTIs(Module &M,
   std::tuple &ThunkInserters) {
-(void)std::initializer_list{
-(std::get(ThunkInserters).init(M), 0)...};
+(..., std::get(ThunkInserters).init(M));
   }
   template 
   static bool runTIs(MachineModuleInfo &MMI, MachineFunction &MF,
  std::tuple &ThunkInserters) {
-bool Modified = false;
-(void)std::initializer_list{
-Modified |= std::get(ThunkInserters).run(MMI, MF)...};
-return Modified;
+return (0 | ... | std::get(ThunkInserters).run(MMI, MF));
   }
 };
 
diff --git a/llvm/lib/Target/ARM/ARMSLSHardening.cpp 
b/llvm/lib/Target/ARM/ARMSLSHardening.cpp
index 23d72b34902d0e..d9ff14ead60e27 100644
--- a/llvm/lib/Target/ARM/ARMSLSHardening.cpp
+++ b/llvm/lib/Target/ARM/ARMSLSHardening.cpp
@@ -404,20 +404,15 @@ class ARMIndirectThunks : public MachineFunctionPass {
 private:
   std::tuple TIs;
 
-  // FIXME: When LLVM moves to C++17, these can become folds
   template 
   static void initTIs(Module &M,
   std::tuple &ThunkInserters) {
-(void)std::initializer_list{
-(std::get(ThunkInserters).init(M), 0)...};
+(..., std::get(ThunkInserters).init(M));
   }
   template 
   static bool runTIs(MachineModuleInfo &MMI, MachineFunction &MF,
  std::tuple &ThunkInserters) {
-bool Modified = false;
-(void)std::initializer_list{
-Modified |= std::get(ThunkInserters).run(MMI, MF)...};
-return Modified;
+return (0 | ... | std::get(ThunkInserters).run(MMI, MF));
   }
 };
 
diff --git a/llvm/lib/Target/X86/X86IndirectThunks.cpp 
b/llvm/lib/Target/X86/X86IndirectThunks.cpp
index 9db667900bffb3..ecc52600f75933 100644
--- a/llvm/lib/Target/X86/X86IndirectThunks.cpp
+++ b/llvm/lib/Target/X86/X86IndirectThunks.cpp
@@ -118,20 +118,15 @@ class X86IndirectThunks : public MachineFunctionPass {
 private:
   std::tuple TIs;
 
-  // FIXME: When LLVM moves to C++17, these can become folds
   template 
   static void initTIs(Module &M,
   std::tuple &ThunkInserters) {
-(void)std::initializer_list{
-(std::get(ThunkInserters).init(M), 0)...};
+(..., std::get(ThunkInserters).init(M));
   }
   template 
   static bool runTIs(MachineModuleInfo &MMI, MachineFunction &MF,
  std::tuple &ThunkInserters) {
-bool Modified = false;
-(void)std::initializer_list{
-Modified |= std::get(ThunkInserters).run(MMI, MF)...};
-return Modified;
+return (0 | ... | std::get(ThunkInserters).run(MMI, MF));
   }
 };
 

``




https://github.com/llvm/llvm-project/pull/83693
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [NFC] Use fold expressions to replace discarded initializer_lists (PR #83693)

2024-03-02 Thread via cfe-commits

Sirraide wrote:

LGTM. This seems like a straight-forward change, so I don’t see anything that 
could really go wrong here.

https://github.com/llvm/llvm-project/pull/83693
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [NFC] Use fold expressions to replace discarded initializer_lists (PR #83693)

2024-03-02 Thread via cfe-commits

https://github.com/Sirraide approved this pull request.


https://github.com/llvm/llvm-project/pull/83693
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [NFC] Use fold expressions to replace discarded initializer_lists (PR #83693)

2024-03-02 Thread via cfe-commits

Sirraide wrote:

Hmm, CI seems to be failing on some flang tests, but other prs seem to be 
experiencing similar issues, so I don’t think this pr broke anything.

https://github.com/llvm/llvm-project/pull/83693
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [NFC] Use fold expressions to replace discarded initializer_lists (PR #83693)

2024-03-02 Thread via cfe-commits

Sirraide wrote:

Just saw that another pr was merged earlier that also ran into this issue, so 
I’m just going to assume that this is fine; it’s just Flang on Windows that 
seems to be a bit broken atm.

https://github.com/llvm/llvm-project/pull/83693
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [NFC] Use fold expressions to replace discarded initializer_lists (PR #83693)

2024-03-02 Thread via cfe-commits

https://github.com/Sirraide closed 
https://github.com/llvm/llvm-project/pull/83693
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [NFC] Use fold expressions to replace discarded initializer_lists (PR #83693)

2024-03-02 Thread via cfe-commits

github-actions[bot] wrote:



@MagentaTreehouse Congratulations on having your first Pull Request (PR) merged 
into the LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested
by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with 
a build, you may recieve a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself.
This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


https://github.com/llvm/llvm-project/pull/83693
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits