Skip to content

Commit 26abf5d

Browse files
Force LF for basically everything.
1 parent aa267c8 commit 26abf5d

File tree

64 files changed

+2313
-2298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2313
-2298
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
[*.{ql,qll,qlref,dbscheme,qhelp,html,js,mjs,ts,json,yml,c,cpp,h,hpp}]
1+
[*]
22
end_of_line = lf

.gitattributes

+13
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,25 @@
1616
*.dbscheme eol=lf
1717
*.qhelp eol=lf
1818
*.html eol=lf
19+
*.htm eol=lf
20+
*.xhtml eol=lf
21+
*.xhtm eol=lf
1922
*.js eol=lf
2023
*.mjs eol=lf
2124
*.ts eol=lf
2225
*.json eol=lf
2326
*.yml eol=lf
27+
*.yaml eol=lf
2428
*.c eol=lf
2529
*.cpp eol=lf
2630
*.h eol=lf
2731
*.hpp eol=lf
32+
*.md eol=lf
33+
*.stats eol=lf
34+
*.xml eol=lf
35+
*.sh eol=lf
36+
*.pl eol=lf
37+
*.java eol=lf
38+
*.cs eol=lf
39+
*.py eol=lf
40+
*.lua eol=lf

change-notes/1.19/analysis-cpp.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
# Improvements to C/C++ analysis
2-
3-
## General improvements
4-
5-
## New queries
6-
7-
| **Query** | **Tags** | **Purpose** |
8-
|-----------------------------|-----------|--------------------------------------------------------------------|
9-
| *@name of query (Query ID)* | *Tags* |*Aim of the new query and whether it is enabled by default or not* |
10-
11-
## Changes to existing queries
12-
13-
| **Query** | **Expected impact** | **Change** |
14-
|----------------------------|------------------------|------------------------------------------------------------------|
15-
| Resource not released in destructor | Fewer false positive results | Placement new is now excluded from the query. |
16-
17-
18-
## Changes to QL libraries
19-
20-
* Added a hash consing library for structural comparison of expressions.
1+
# Improvements to C/C++ analysis
2+
3+
## General improvements
4+
5+
## New queries
6+
7+
| **Query** | **Tags** | **Purpose** |
8+
|-----------------------------|-----------|--------------------------------------------------------------------|
9+
| *@name of query (Query ID)* | *Tags* |*Aim of the new query and whether it is enabled by default or not* |
10+
11+
## Changes to existing queries
12+
13+
| **Query** | **Expected impact** | **Change** |
14+
|----------------------------|------------------------|------------------------------------------------------------------|
15+
| Resource not released in destructor | Fewer false positive results | Placement new is now excluded from the query. |
16+
17+
18+
## Changes to QL libraries
19+
20+
* Added a hash consing library for structural comparison of expressions.

cpp/ql/src/plugin.xml

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<?eclipse version="3.2"?>
3-
<plugin>
4-
<extension point="com.semmle.plugin.qdt.ui.resources">
5-
<name value="semmlecode-cpp-queries"/>
6-
</extension>
7-
8-
<extension point="com.semmle.plugin.qdt.ui.resources">
9-
<name value="com.semmle.code.cpp.library"/>
10-
</extension>
11-
12-
<extension point="com.semmle.plugin.qdt.ui.resources">
13-
<name value="com.semmle.code.cpp.dbscheme"/>
14-
<path value="/semmlecode.cpp.dbscheme"/>
15-
</extension>
16-
</plugin>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<?eclipse version="3.2"?>
3+
<plugin>
4+
<extension point="com.semmle.plugin.qdt.ui.resources">
5+
<name value="semmlecode-cpp-queries"/>
6+
</extension>
7+
8+
<extension point="com.semmle.plugin.qdt.ui.resources">
9+
<name value="com.semmle.code.cpp.library"/>
10+
</extension>
11+
12+
<extension point="com.semmle.plugin.qdt.ui.resources">
13+
<name value="com.semmle.code.cpp.dbscheme"/>
14+
<path value="/semmlecode.cpp.dbscheme"/>
15+
</extension>
16+
</plugin>
+137-137
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,137 @@
1-
import sys
2-
import os.path
3-
import glob
4-
import re
5-
import json
6-
7-
BEGIN_TEMPLATE = re.compile(r"^/\*template\s*$")
8-
END_TEMPLATE = re.compile(r"^\*/\s*$")
9-
10-
def expand_template_params(args, param_arg_map):
11-
'''Given a list of template arguments that may reference template parameters
12-
of the current template, return a new list of template arguments with each
13-
parameter use replaced with the appropriate fully-qualified argument for
14-
that parameter.'''
15-
result = []
16-
for arg in args:
17-
if arg in param_arg_map:
18-
result.append(param_arg_map[arg])
19-
else:
20-
result.append(arg)
21-
22-
return result
23-
24-
def find_instantiation(module, args, templates):
25-
'''Given a template module and a set of template arguments, find the module
26-
name of the instantiation of that module with those arguments.'''
27-
template = templates[module]
28-
for instantiation in template["template_def"]["instantiations"]:
29-
if instantiation["args"] == args:
30-
return instantiation["name"]
31-
return None
32-
33-
def instantiate_template(template, instantiation, root, templates):
34-
'''Create a single instantiation of a template.'''
35-
template_def = template["template_def"]
36-
output_components = instantiation["name"].split(".")
37-
output_path = root
38-
for component in output_components:
39-
output_path = os.path.join(output_path, component)
40-
output_path = output_path + ".qll"
41-
with open(output_path, "w") as output:
42-
output.write(
43-
"""
44-
/*
45-
* THIS FILE IS AUTOMATICALLY GENERATED FROM '%s'.
46-
* DO NOT EDIT MANUALLY.
47-
*/
48-
49-
""" % (template["name"].replace(".", "/") + ".qllt")
50-
)
51-
param_arg_map = {}
52-
for param_index in range(len(template_def["params"])):
53-
param = template_def["params"][param_index]
54-
arg = instantiation["args"][param_index]
55-
output.write("private import %s as %s // Template parameter\n" % (arg, param))
56-
param_arg_map[param] = arg
57-
for import_record in template_def["imports"]:
58-
if "access" in import_record:
59-
output.write(import_record["access"] + " ")
60-
imported_module = find_instantiation(import_record["module"],
61-
expand_template_params(import_record["args"], param_arg_map), templates)
62-
output.write("import %s // %s<%s>\n" %
63-
(
64-
imported_module,
65-
import_record["module"],
66-
", ".join(import_record["args"])
67-
)
68-
)
69-
70-
output.writelines(template_def["body_lines"])
71-
72-
def generate_instantiations(template, root, templates):
73-
'''Create a .qll source file for each instantiation of the specified template.'''
74-
template_def = template["template_def"]
75-
if "instantiations" in template_def:
76-
for instantiation in template_def["instantiations"]:
77-
instantiate_template(template, instantiation, root, templates)
78-
79-
def read_template(template_path, module_name):
80-
'''Read a .qllt template file from template_path, using module_name as the
81-
fully qualified name of the module.'''
82-
with open(template_path) as input:
83-
in_template = False
84-
template_text = ""
85-
template_def = None
86-
body_lines = []
87-
for line in iter(input):
88-
if in_template:
89-
if END_TEMPLATE.match(line):
90-
template_def = json.loads(template_text)
91-
in_template = False
92-
else:
93-
template_text += line
94-
else:
95-
if BEGIN_TEMPLATE.match(line) and not template_def:
96-
in_template = True
97-
else:
98-
body_lines.append(line)
99-
100-
if template_def:
101-
template_def["body_lines"] = body_lines
102-
103-
result = { "name": module_name }
104-
if template_def:
105-
result["template_def"] = template_def
106-
return result
107-
108-
def module_name_from_path_impl(path):
109-
(head, tail) = os.path.split(path)
110-
if head == "":
111-
return tail
112-
else:
113-
return module_name_from_path(head) + "." + tail
114-
115-
def module_name_from_path(path):
116-
'''Compute the fully qualified name of a module from the path of its .qll[t]
117-
file. The path should be relative to the library root.'''
118-
(module_root, ext) = os.path.splitext(path)
119-
return module_name_from_path_impl(module_root)
120-
121-
def main():
122-
templates = {}
123-
124-
root = sys.argv[1]
125-
for template_path in glob.glob(os.path.join(root, "**\\*.qllt"), recursive = True):
126-
print(template_path)
127-
module_name = module_name_from_path(os.path.relpath(template_path, root))
128-
print(module_name)
129-
template = read_template(template_path, module_name)
130-
templates[template["name"]] = template
131-
132-
for name, template in templates.items():
133-
if "template_def" in template:
134-
generate_instantiations(template, root, templates)
135-
136-
if __name__ == "__main__":
137-
main()
1+
import sys
2+
import os.path
3+
import glob
4+
import re
5+
import json
6+
7+
BEGIN_TEMPLATE = re.compile(r"^/\*template\s*$")
8+
END_TEMPLATE = re.compile(r"^\*/\s*$")
9+
10+
def expand_template_params(args, param_arg_map):
11+
'''Given a list of template arguments that may reference template parameters
12+
of the current template, return a new list of template arguments with each
13+
parameter use replaced with the appropriate fully-qualified argument for
14+
that parameter.'''
15+
result = []
16+
for arg in args:
17+
if arg in param_arg_map:
18+
result.append(param_arg_map[arg])
19+
else:
20+
result.append(arg)
21+
22+
return result
23+
24+
def find_instantiation(module, args, templates):
25+
'''Given a template module and a set of template arguments, find the module
26+
name of the instantiation of that module with those arguments.'''
27+
template = templates[module]
28+
for instantiation in template["template_def"]["instantiations"]:
29+
if instantiation["args"] == args:
30+
return instantiation["name"]
31+
return None
32+
33+
def instantiate_template(template, instantiation, root, templates):
34+
'''Create a single instantiation of a template.'''
35+
template_def = template["template_def"]
36+
output_components = instantiation["name"].split(".")
37+
output_path = root
38+
for component in output_components:
39+
output_path = os.path.join(output_path, component)
40+
output_path = output_path + ".qll"
41+
with open(output_path, "w") as output:
42+
output.write(
43+
"""
44+
/*
45+
* THIS FILE IS AUTOMATICALLY GENERATED FROM '%s'.
46+
* DO NOT EDIT MANUALLY.
47+
*/
48+
49+
""" % (template["name"].replace(".", "/") + ".qllt")
50+
)
51+
param_arg_map = {}
52+
for param_index in range(len(template_def["params"])):
53+
param = template_def["params"][param_index]
54+
arg = instantiation["args"][param_index]
55+
output.write("private import %s as %s // Template parameter\n" % (arg, param))
56+
param_arg_map[param] = arg
57+
for import_record in template_def["imports"]:
58+
if "access" in import_record:
59+
output.write(import_record["access"] + " ")
60+
imported_module = find_instantiation(import_record["module"],
61+
expand_template_params(import_record["args"], param_arg_map), templates)
62+
output.write("import %s // %s<%s>\n" %
63+
(
64+
imported_module,
65+
import_record["module"],
66+
", ".join(import_record["args"])
67+
)
68+
)
69+
70+
output.writelines(template_def["body_lines"])
71+
72+
def generate_instantiations(template, root, templates):
73+
'''Create a .qll source file for each instantiation of the specified template.'''
74+
template_def = template["template_def"]
75+
if "instantiations" in template_def:
76+
for instantiation in template_def["instantiations"]:
77+
instantiate_template(template, instantiation, root, templates)
78+
79+
def read_template(template_path, module_name):
80+
'''Read a .qllt template file from template_path, using module_name as the
81+
fully qualified name of the module.'''
82+
with open(template_path) as input:
83+
in_template = False
84+
template_text = ""
85+
template_def = None
86+
body_lines = []
87+
for line in iter(input):
88+
if in_template:
89+
if END_TEMPLATE.match(line):
90+
template_def = json.loads(template_text)
91+
in_template = False
92+
else:
93+
template_text += line
94+
else:
95+
if BEGIN_TEMPLATE.match(line) and not template_def:
96+
in_template = True
97+
else:
98+
body_lines.append(line)
99+
100+
if template_def:
101+
template_def["body_lines"] = body_lines
102+
103+
result = { "name": module_name }
104+
if template_def:
105+
result["template_def"] = template_def
106+
return result
107+
108+
def module_name_from_path_impl(path):
109+
(head, tail) = os.path.split(path)
110+
if head == "":
111+
return tail
112+
else:
113+
return module_name_from_path(head) + "." + tail
114+
115+
def module_name_from_path(path):
116+
'''Compute the fully qualified name of a module from the path of its .qll[t]
117+
file. The path should be relative to the library root.'''
118+
(module_root, ext) = os.path.splitext(path)
119+
return module_name_from_path_impl(module_root)
120+
121+
def main():
122+
templates = {}
123+
124+
root = sys.argv[1]
125+
for template_path in glob.glob(os.path.join(root, "**\\*.qllt"), recursive = True):
126+
print(template_path)
127+
module_name = module_name_from_path(os.path.relpath(template_path, root))
128+
print(module_name)
129+
template = read_template(template_path, module_name)
130+
templates[template["name"]] = template
131+
132+
for name, template in templates.items():
133+
if "template_def" in template:
134+
generate_instantiations(template, root, templates)
135+
136+
if __name__ == "__main__":
137+
main()

0 commit comments

Comments
 (0)