mirror of
https://github.com/github/codeql.git
synced 2026-06-03 04:40:14 +02:00
This checks in the trapgen script generating trap entries in C++. The codegen suite has been slightly reorganized, moving the templates directory up one level and chopping everything into smaller bazel packages. Running tests is now done via ``` bazel run //swift/codegen/test ``` With respect to the PoC, the nested `codeql::trap` namespace has been dropped in favour of a `Trap` prefix (or suffix in case of entries) within the `codeql` namespace. Also, generated C++ code is not checked in in git any more, and generated during build. Finally, labels get printed in hex in the trap file. `TrapLabel` is for the moment only default-constructible, so only one single label is possible. `TrapArena`, that is responsible for creating disjoint labels will come in a later commit.
36 lines
777 B
Plaintext
36 lines
777 B
Plaintext
// generated by {{generator}}
|
|
// clang-format off
|
|
#ifndef SWIFT_EXTRACTOR_TRAP_{{guard}}
|
|
#define SWIFT_EXTRACTOR_TRAP_{{guard}}
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
#include "swift/extractor/trap/TrapLabel.h"
|
|
#include "swift/extractor/trap/TrapTags.h"
|
|
|
|
namespace codeql {
|
|
{{#traps}}
|
|
|
|
// {{table_name}}
|
|
struct {{name}}Trap {
|
|
static constexpr bool is_binding = {{#id}}true{{/id}}{{^id}}false{{/id}};
|
|
{{#id}}
|
|
{{type}} getBoundLabel() const { return {{cpp_name}}; }
|
|
{{/id}}
|
|
|
|
{{#fields}}
|
|
{{type}} {{cpp_name}}{};
|
|
{{/fields}}
|
|
};
|
|
|
|
inline std::ostream &operator<<(std::ostream &out, const {{name}}Trap &e) {
|
|
out << "{{table_name}}("{{#fields}}{{^first}} << ", "{{/first}}
|
|
<< {{#stream}}e.{{cpp_name}}{{/stream}}{{/fields}} << ")";
|
|
return out;
|
|
}
|
|
{{/traps}}
|
|
|
|
}
|
|
#endif
|