[cfe-commits] r152279 - in /cfe/trunk: include/clang/Sema/Lookup.h lib/Sema/SemaLookup.cpp

Daniel Dunbar daniel at zuster.org
Thu Mar 8 11:14:48 PST 2012


On Thu, Mar 8, 2012 at 11:08 AM, Matthieu Monrocq
<matthieu.monrocq at gmail.com> wrote:
>
>
> Le 8 mars 2012 02:43, Daniel Dunbar <daniel at zuster.org> a écrit :
>
>> Author: ddunbar
>> Date: Wed Mar  7 19:43:06 2012
>> New Revision: 152279
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=152279&view=rev
>> Log:
>> Sema: Don't emit a gajillion calls to sanity() -- an empty function -- in
>> NDEBUG
>> builds. Sheesh.
>>
>> Modified:
>>    cfe/trunk/include/clang/Sema/Lookup.h
>>    cfe/trunk/lib/Sema/SemaLookup.cpp
>>
>> Modified: cfe/trunk/include/clang/Sema/Lookup.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=152279&r1=152278&r2=152279&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
>> +++ cfe/trunk/include/clang/Sema/Lookup.h Wed Mar  7 19:43:06 2012
>> @@ -600,7 +600,13 @@
>>   void configure();
>>
>>   // Sanity checks.
>> -  void sanity() const;
>> +  void sanityImpl() const;
>> +
>> +  void sanity() const {
>> +#ifndef NDEBUG
>> +    sanityImpl();
>> +#endif
>> +  }
>>
>>   bool sanityCheckUnresolved() const {
>>     for (iterator I = begin(), E = end(); I != E; ++I)
>>
>> Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=152279&r1=152278&r2=152279&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Mar  7 19:43:06 2012
>> @@ -302,7 +302,9 @@
>>   }
>>  }
>>
>> -void LookupResult::sanity() const {
>> +void LookupResult::sanityImpl() const {
>> +  // Note that this function is never called by NDEBUG builds. See
>> +  // LookupResult::sanity().
>>   assert(ResultKind != NotFound || Decls.size() == 0);
>>   assert(ResultKind != Found || Decls.size() == 1);
>>   assert(ResultKind != FoundOverloaded || Decls.size() > 1 ||
>>
>>
> Since sanityImpl is only ever useful in NDEBUG builds, it could be useful to
> #ifdef both its declaration and definition with NDEBUG, would not it ?

I don't like changing the external API based on NDEBUG or not.

 - Daniel

> -- Matthieu
>




More information about the cfe-commits mailing list