[Patch] Removing static initializers from Signals.inc

Chris Bieneman beanz at apple.com
Thu Aug 28 17:05:20 PDT 2014


Makes sense. How does this look?

-Chris



On Aug 28, 2014, at 4:48 PM, Chandler Carruth <chandlerc at google.com> wrote:

> @@ -106,8 +104,8 @@ static void RegisterHandlers() {
>    // If the handlers are already registered, we're done.
>    if (NumRegisteredSignals != 0) return;
>  
> -  std::for_each(IntSigs, IntSigsEnd, RegisterHandler);
> -  std::for_each(KillSigs, KillSigsEnd, RegisterHandler);
> +  std::for_each(IntSigs, std::end(IntSigs), RegisterHandler);
> +  std::for_each(KillSigs, std::end(KillSigs), RegisterHandler);
> 
> Just use a range based for loop?
> 
> for (auto S : IntSigs) RegisterHandler(S);
> 
> seems cleaner than the existing code...
> 
> 
>  }
>  
>  static void UnregisterHandlers() {
> @@ -166,7 +164,8 @@ static RETSIGTYPE SignalHandler(int Sig) {
>    {
>      unique_lock<SmartMutex<true>> Guard(SignalsMutex);
>      RemoveFilesToRemove();
> -
> +    const int *const IntSigsEnd = std::end(IntSigs);
> +    
>      if (std::find(IntSigs, IntSigsEnd, Sig) != IntSigsEnd) {
> 
> I would rewrite all of this to just use 'std::begin' and 'std::end' directly rather than the variable.
> 
>        if (InterruptFunction) {
>          void (*IF)() = InterruptFunction;
> 
> 
> On Thu, Aug 28, 2014 at 3:31 PM, Chris Bieneman <beanz at apple.com> wrote:
> This patch has some small code cleanup to remove static initializers from Signals.inc.
> 
> Thanks,
> -Chris
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140828/f76db64c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Signals-static-inits.diff
Type: application/octet-stream
Size: 1534 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140828/f76db64c/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140828/f76db64c/attachment-0001.html>


More information about the llvm-commits mailing list