Skip to content

Commit 6fb021a

Browse files
authored
Merge pull request github#11164 from github/redsun82/swift-print-unextracted
Swift: print unextracted entities
2 parents 2bef82b + d325a42 commit 6fb021a

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

.github/workflows/swift.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ jobs:
5151
- uses: actions/checkout@v3
5252
- uses: ./swift/actions/create-extractor-pack
5353
- uses: ./swift/actions/run-quick-tests
54+
- uses: ./swift/actions/print-unextracted
5455
build-and-test-linux:
5556
runs-on: ubuntu-20.04
5657
steps:
5758
- uses: actions/checkout@v3
5859
- uses: ./swift/actions/create-extractor-pack
5960
- uses: ./swift/actions/run-quick-tests
61+
- uses: ./swift/actions/print-unextracted
6062
qltests-linux:
6163
needs: build-and-test-linux
6264
runs-on: ubuntu-latest
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Print unextracted entities
2+
description: Prints all AST and Type entities that we do not extract yet. Must be run after `setup-env`
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Print unextracted entities
7+
shell: bash
8+
run: |
9+
bazel run //swift/extractor/print_unextracted
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
load("//swift:rules.bzl", "swift_cc_binary")
2+
3+
swift_cc_binary(
4+
name = "print_unextracted",
5+
srcs = glob(["*.cpp"]),
6+
deps = ["//swift/extractor/translators"],
7+
)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include <iostream>
2+
3+
#include "swift/extractor/translators/DeclTranslator.h"
4+
#include "swift/extractor/translators/ExprTranslator.h"
5+
#include "swift/extractor/translators/StmtTranslator.h"
6+
#include "swift/extractor/translators/TypeTranslator.h"
7+
#include "swift/extractor/translators/PatternTranslator.h"
8+
9+
using namespace codeql;
10+
11+
#define CHECK_CLASS(KIND, CLASS, PARENT) \
12+
if (!detail::HasTranslate##CLASS##KIND<KIND##Translator>::value && \
13+
!detail::HasTranslate##PARENT<KIND##Translator>::value) { \
14+
std::cout << " " #CLASS #KIND "\n"; \
15+
}
16+
17+
int main() {
18+
std::cout << "Unextracted Decls:\n";
19+
20+
#define DECL(CLASS, PARENT) CHECK_CLASS(Decl, CLASS, PARENT)
21+
#include "swift/AST/DeclNodes.def"
22+
23+
std::cout << "\nUnextracted Stmts:\n";
24+
25+
#define STMT(CLASS, PARENT) CHECK_CLASS(Stmt, CLASS, PARENT)
26+
#include "swift/AST/StmtNodes.def"
27+
28+
std::cout << "\nUnextracted Exprs:\n";
29+
30+
#define EXPR(CLASS, PARENT) CHECK_CLASS(Expr, CLASS, PARENT)
31+
#include "swift/AST/ExprNodes.def"
32+
33+
std::cout << "\nUnextracted Patterns:\n";
34+
35+
#define PATTERN(CLASS, PARENT) CHECK_CLASS(Pattern, CLASS, PARENT)
36+
#include "swift/AST/PatternNodes.def"
37+
38+
std::cout << "\nUnextracted Types:\n";
39+
40+
#define TYPE(CLASS, PARENT) CHECK_CLASS(Type, CLASS, PARENT)
41+
#include "swift/AST/TypeNodes.def"
42+
43+
return 0;
44+
}

0 commit comments

Comments
 (0)