Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit057c684

Browse files
committed
Add mad generator for the C++ Standard Library
This repurposes the existing module generator to instead generate a madfile for the C++ standard library. It makes the following changes: * Omits names outside the `std` namespace (as they cannot be distinguished from system headers). * Removes the macro query, and adds member variable and type models instead. * Move to a new generator directory. * Update the script to generate a mad file instead of a .qll file.
1 parent1554d78 commit057c684

19 files changed

+5352
-147
lines changed

‎.codeqlmanifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"cpp/*/test/qlpack.yml",
55
"c/*/src/qlpack.yml",
66
"c/*/test/qlpack.yml",
7-
"scripts/generate_modules/queries/qlpack.yml"
7+
"scripts/generate_standard_library_models/cpp/queries/qlpack.yml"
88
]
99
}

‎cpp/common/src/ext/stdcpp14.generated.names.model.yml‎

Lines changed: 5197 additions & 0 deletions
Large diffs are not rendered by default.

‎scripts/generate_modules/generate_modules.py‎

Lines changed: 0 additions & 52 deletions
This file was deleted.

‎scripts/generate_modules/queries/cxx14-stdlib-functions.ql‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎scripts/generate_modules/queries/cxx14-stdlib-macros.ql‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎scripts/generate_modules/queries/cxx14-stdlib-objects.ql‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎scripts/generate_modules/templates/Naming.qll.template‎

Lines changed: 0 additions & 60 deletions
This file was deleted.

‎scripts/generate_modules/Makefile‎renamed to ‎scripts/generate_standard_library_models/cpp/Makefile‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
CODEQL=codeql
2-
SEARCH_PATH?=$(PWD)/../../codeql_modules/codeql
32
.PHONY: all clean
4-
all:cxx14-stdlib-macros.jsoncxx14-stdlib-objects.jsoncxx14-stdlib-functions.json
3+
all:libraryFunctionModel.jsonlibraryObjectModel.jsonlibraryMemberVariableModel.json libraryTypeModel.json
54

65
%.json:%.bqrs
76
$(CODEQL) bqrs decode --format=json -o$@$<
87
%.bqrs: queries/%.ql cxx14-stdlib-db
9-
$(CODEQL) query run --search-path=$(SEARCH_PATH) -d cxx14-stdlib-db -o$@$<
8+
$(CODEQL) query run -d cxx14-stdlib-db -o$@$<
109
cxx14-stdlib-db:
1110
$(CODEQL) database create -l cpp -ssource -c"make clean all"$@
1211

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
##Generating C++ Standard Library models
2+
3+
This directory contains a script for generating a models-as-data file based on a sample C++ codebase that includes every standard library header.
4+
5+
###How to use
6+
7+
1. Run`make` from this directory to build the CodeQL database for the sample codebase, and run the queries over it.
8+
2. Copy each page individually into a text file (avoiding copying headers and footers).
9+
3. Run`python3 generate_cpp_standard_library_models.py` to generate the models-as-data file.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
importjson
2+
frompathlibimportPath
3+
importyaml
4+
5+
generate_modules_home=Path(__file__).resolve().parent
6+
common_codingstandards_ext_output=generate_modules_home.parent.parent.joinpath(
7+
'cpp','common','src','ext','stdcpp14.generated.names.model.yml')
8+
9+
queries= ["libraryTypeModel","libraryFunctionModel","libraryObjectModel","libraryMemberVariableModel"]
10+
defload_spec(spec_file):
11+
withspec_file.open()asf:
12+
returnjson.load(f)
13+
14+
yaml_output= {
15+
"extensions" : []
16+
}
17+
18+
forqueryinqueries:
19+
yaml_output["extensions"].append({
20+
"addsTo": {
21+
"pack" :"codeql/common-cpp-coding-standards",
22+
"extensible" :query
23+
},
24+
"data" :load_spec(generate_modules_home.joinpath(f"{query}.json"))["#select"]["tuples"]
25+
26+
})
27+
28+
withopen(common_codingstandards_ext_output,'w')asfile:
29+
yaml.dump(yaml_output,file,default_flow_style=None,width=3000)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp