[Mesa-dev] Cut down false positives when running the Clang Analyzer.

Submitted by John Kåre Alsaker on April 25, 2014, 1:07 a.m.

Details

Message ID 1398388062-10181-1-git-send-email-john.kare.alsaker@gmail.com
State New
Headers show

Not browsing as part of any series.

Commit Message

John Kåre Alsaker April 25, 2014, 1:07 a.m.
---
 src/mapi/glapi/gen/gl_table.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/mapi/glapi/gen/gl_table.py b/src/mapi/glapi/gen/gl_table.py
index fd38468..d4075ff 100644
--- a/src/mapi/glapi/gen/gl_table.py
+++ b/src/mapi/glapi/gen/gl_table.py
@@ -101,10 +101,22 @@  class PrintRemapTable(gl_XML.gl_print_base):
         return
 
     def printBody(self, api):
+        print '#ifndef __has_feature'
+        print '#define __has_feature(x) 0'
+        print '#endif'
+        print ''
+        print '#if __has_feature(attribute_analyzer_noreturn)'
+        print 'static inline _glapi_proc gl_table_null() __attribute__((analyzer_noreturn));'
+        print '#endif'
+        print ''
+        print 'static inline _glapi_proc gl_table_null() {'
+        print '   return NULL;'
+        print '}'
+        print ''
         print '#define CALL_by_offset(disp, cast, offset, parameters) \\'
         print '    (*(cast (GET_by_offset(disp, offset)))) parameters'
         print '#define GET_by_offset(disp, offset) \\'
-        print '    (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL'
+        print '    (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : gl_table_null()'
         print '#define SET_by_offset(disp, offset, fn) \\'
         print '    do { \\'
         print '        if ( (offset) < 0 ) { \\'