MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / get_includes

Function get_includes

test/scripts/extracttests.py:29–59  ·  view source on GitHub ↗
(code)

Source from the content-addressed store, hash-verified

27
28
29def get_includes(code):
30 includes = (('alloca','alloca.h'),
31 ('NULL','cstddef'),
32 ('size_t','cstddef'),
33 ('free','cstdlib'),
34 ('malloc','cstdlib'),
35 ('realloc','cstdlib'),
36 ('memcpy','cstring'),
37 ('stdin','cstdio'),
38 ('strcat','cstring'),
39 ('strchr','cstring'),
40 ('strcpy','cstring'),
41 ('strlen','cstring'),
42 ('strncat','cstring'),
43 ('strncpy','cstring'),
44 ('std::cout','iostream'),
45 ('std::pair','utility'),
46 ('std::shared_ptr','memory'),
47 ('std::string','string'),
48 ('std::unique_ptr','memory'),
49 ('std::vector','vector'))
50
51 ret = ''
52
53 for i in includes:
54 if i[0] in code:
55 include_header = '#include <%s>' % i[1]
56 if include_header not in ret:
57 ret += include_header + '\n'
58
59 return ret
60
61
62def tweak_expected(expected, start_code):

Callers 1

parseFileMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected