[PATCH] make helper function static

David Blaikie dblaikie at gmail.com
Tue Dec 3 00:02:16 PST 2013


The LLVM coding conventions do suggest using "static" for TU-local
functions and only using anonymous namespaces around classes for this
(readibility) reason, I believe. You might want to reduce the scope of
the anonymous namespace so it just wraps the class(es) and not the
functions, then.

On Mon, Dec 2, 2013 at 11:58 PM, Bas van den Berg
<b.van.den.berg.nl at gmail.com> wrote:
> I did not measure it. The main reason was to narrow the scope so
> reading/analysing the code
> is easier.
>
>
> On Tue, Dec 3, 2013 at 8:55 AM, Alp Toker <alp at nuanti.com> wrote:
>>
>>
>> On 03/12/2013 07:44, Bas van den Berg wrote:
>>>
>>> CheckImplicitConversion() can be static to allow more compiler
>>> optimizations.
>>>
>>> ---
>>>   lib/Sema/SemaChecking.cpp |    2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
>>> index 0b95c48..830936d 100644
>>> --- a/lib/Sema/SemaChecking.cpp
>>> +++ b/lib/Sema/SemaChecking.cpp
>>> @@ -5210,7 +5210,7 @@ void CheckImplicitArgumentConversions(Sema &S,
>>> CallExpr *TheCall,
>>>     }
>>>   }
>>>   -void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
>>> +static void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
>>>                                SourceLocation CC, bool *ICContext = 0) {
>>>     if (E->isTypeDependent() || E->isValueDependent()) return;
>>>
>>
>>
>> These functions are in an anonymous namespace so should get the same
>> optimisations as 'static'.
>>
>> Did you see a difference in generated code / performance or was this just
>> a speculative change?
>>
>> Alp.
>>
>>
>> --
>> http://www.nuanti.com
>> the browser experts
>>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>



More information about the cfe-commits mailing list