[petsc-dev] Clang Analyzer

Barry Smith bsmith at mcs.anl.gov
Sun Apr 12 17:20:41 CDT 2015


  Lisandro,

   More code analysis is always good. We'll figure something out for this particular beast. Note that petscsys.h already uses #if defined(__has_attribute) so maybe we can use 

#if defined(__has_attribute)
#  if __has_attribute(analyzer_noreturn)

   instead of the #ifdef __clang_analyzer__?

Barry

Of course I couldn't resist playing with the code analyzer on PETSc as soon as I got your email :-)





  
> On Apr 12, 2015, at 9:26 AM, Lisandro Dalcin <dalcinl at gmail.com> wrote:
> 
>> 
>> #ifdef __clang_analyzer__
>> #define PETSC_CLANG_ANALYZER_NORETURN __attribute__((analyzer_noreturn))
>> #else
>> #define PETSC_CLANG_ANALYZER_NORETURN
>> #endif
>> 
>> PETSC_EXTERN PetscErrorCode PetscError(...arglist...)
>> PETSC_CLANG_ANALYZER_NORETURN;
>> 
>> Do you like it?
>> 
> 
> This one is even less verbose, and given that is the only function we
> need this, perhaps you will accept it:?
> 
> #ifdef __clang_analyzer__
> __attribute__((analyzer_noreturn))
> #endif
> PETSC_EXTERN PetscErrorCode PetscError(MPI_Comm,int,const char*,const
> char*,PetscErrorCode,PetscErrorType,const char*,...);
> 
> 
> 
> -- 
> Lisandro Dalcin
> ============
> Research Scientist
> Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
> Numerical Porous Media Center (NumPor)
> King Abdullah University of Science and Technology (KAUST)
> http://numpor.kaust.edu.sa/
> 
> 4700 King Abdullah University of Science and Technology
> al-Khawarizmi Bldg (Bldg 1), Office # 4332
> Thuwal 23955-6900, Kingdom of Saudi Arabia
> http://www.kaust.edu.sa
> 
> Office Phone: +966 12 808-0459




More information about the petsc-dev mailing list