mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Merge pull request #9796 from github/redsun82/swift-codegen-skip-cpp-pragma
Swift: allow skipping fields in cppgen
This commit is contained in:
@@ -65,7 +65,7 @@ class Processor:
|
||||
return cpp.Class(
|
||||
name=name,
|
||||
bases=[self._get_class(b) for b in cls.bases],
|
||||
fields=[_get_field(cls, p) for p in cls.properties],
|
||||
fields=[_get_field(cls, p) for p in cls.properties if "cpp_skip" not in p.pragmas],
|
||||
final=not cls.derived,
|
||||
trap_name=trap_name,
|
||||
)
|
||||
|
||||
@@ -13,14 +13,18 @@ _directories:
|
||||
stmt: Stmt$
|
||||
|
||||
Element:
|
||||
is_unknown: predicate
|
||||
is_unknown:
|
||||
type: predicate
|
||||
_pragma: cpp_skip # this is emitted using trap entries directly
|
||||
_pragma: qltest_skip
|
||||
|
||||
File:
|
||||
name: string
|
||||
|
||||
Locatable:
|
||||
location: Location?
|
||||
location:
|
||||
type: Location?
|
||||
_pragma: cpp_skip # this is emitted using trap entries directly
|
||||
_pragma: qltest_skip
|
||||
|
||||
Location:
|
||||
|
||||
@@ -165,5 +165,18 @@ def test_classes_with_dirs(generate_grouped):
|
||||
}
|
||||
|
||||
|
||||
def test_cpp_skip_pragma(generate):
|
||||
assert generate([
|
||||
schema.Class(name="A", properties=[
|
||||
schema.SingleProperty("x", "foo"),
|
||||
schema.SingleProperty("y", "bar", pragmas=["x", "cpp_skip", "y"]),
|
||||
])
|
||||
]) == [
|
||||
cpp.Class(name="A", final=True, trap_name="As", fields=[
|
||||
cpp.Field("x", "foo"),
|
||||
]),
|
||||
]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(pytest.main([__file__] + sys.argv[1:]))
|
||||
|
||||
Reference in New Issue
Block a user