Update clang array checker for new clang py api
authorCampbell Barton <ideasman42@gmail.com>
Sat, 29 Mar 2014 00:07:31 +0000 (11:07 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 29 Mar 2014 00:08:24 +0000 (11:08 +1100)
build_files/cmake/clang_array_check.py
build_files/cmake/cmake_static_check_clang_array.py

index f29d3c75608615b89d280035ed2739fad856784a..c1421dfadd32a369f3fa922e50de692a588119ba 100644 (file)
@@ -117,6 +117,7 @@ args = sys.argv[2:]
 
 tu = index.parse(sys.argv[1], args)
 # print('Translation unit: %s' % tu.spelling)
+filepath = tu.spelling
 
 # -----------------------------------------------------------------------------
 
@@ -200,14 +201,12 @@ def function_get_arg_sizes(node):
         for i, node_child in enumerate(node_parms):
 
             # print(node_child.kind, node_child.spelling)
-            #print(node_child.type.kind, node_child.spelling)  # TypeKind.POINTER
-            
-            if node_child.type.kind == TypeKind.POINTER:
+            #print(node_child.type.kind, node_child.spelling)
+            if node_child.type.kind == TypeKind.CONSTANTARRAY:
                 pointee = node_child.type.get_pointee()
-                if pointee.is_pod():
-                    size = parm_size(node_child)
-                    if size != -1:
-                        arg_sizes[i] = size
+                size = parm_size(node_child)
+                if size != -1:
+                    arg_sizes[i] = size
 
     return arg_sizes
 
@@ -292,7 +291,7 @@ def file_check_arg_sizes(tu):
                 if arg.kind in (CursorKind.DECL_REF_EXPR,
                                 CursorKind.UNEXPOSED_EXPR):
 
-                    if arg.type.kind == TypeKind.POINTER:
+                    if arg.type.kind == TypeKind.CONSTANTARRAY:
                         dec = arg.get_definition()
                         if dec:
                             size = parm_size(dec)
@@ -324,7 +323,7 @@ def file_check_arg_sizes(tu):
                                                    location.line,
                                                    location.column,
                                                    i + 1, size, size_def,
-                                                   args[0]  # always the same but useful when running threaded
+                                                   filepath  # always the same but useful when running threaded
                                                    ))
 
     # we dont really care what we are looking at, just scan entire file for
index 17298599bdd49a7e4439cfafaced5da339ffb05d..45b262a13ce289df3599349230157dfe21e9fda0 100644 (file)
@@ -41,6 +41,8 @@ CHECKER_ARGS = [
     os.path.join(os.path.dirname(__file__), "clang_array_check.py"),
     # not sure why this is needed, but it is.
     "-I" + os.path.join(project_source_info.SOURCE_DIR, "extern", "glew", "include"),
+    # stupid but needed
+    "-Dbool=char"
     ]