[Patch] Removing static initializers from Signals.inc

Chandler Carruth chandlerc at google.com
Thu Aug 28 17:16:08 PDT 2014


Sure, LGTM. I think clang-format will format the for loops differently, but
I don't care.


On Thu, Aug 28, 2014 at 5:05 PM, Chris Bieneman <beanz at apple.com> wrote:

> 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/b5bbafc6/attachment.html>


More information about the llvm-commits mailing list