mirror of
https://github.com/github/codeql.git
synced 2025-12-16 08:43:11 +01:00
Swift: update formatting to clang-format 17.0.6
Also, added a format check in `swift.yml`.
This commit is contained in:
1
.clang-format
Normal file
1
.clang-format
Normal file
@@ -0,0 +1 @@
|
|||||||
|
DisableFormat: true
|
||||||
13
.github/workflows/swift.yml
vendored
13
.github/workflows/swift.yml
vendored
@@ -73,6 +73,15 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: ./swift/actions/run-integration-tests
|
- uses: ./swift/actions/run-integration-tests
|
||||||
|
clang-format:
|
||||||
|
if : ${{ github.event_name == 'pull_request' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507
|
||||||
|
name: Check that python code is properly formatted
|
||||||
|
with:
|
||||||
|
extra_args: clang-format --all-files
|
||||||
codegen:
|
codegen:
|
||||||
if : ${{ github.event_name == 'pull_request' }}
|
if : ${{ github.event_name == 'pull_request' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -82,12 +91,12 @@ jobs:
|
|||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version-file: 'swift/.python-version'
|
python-version-file: 'swift/.python-version'
|
||||||
- uses: pre-commit/action@v3.0.0
|
- uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507
|
||||||
name: Check that python code is properly formatted
|
name: Check that python code is properly formatted
|
||||||
with:
|
with:
|
||||||
extra_args: autopep8 --all-files
|
extra_args: autopep8 --all-files
|
||||||
- uses: ./.github/actions/fetch-codeql
|
- uses: ./.github/actions/fetch-codeql
|
||||||
- uses: pre-commit/action@v3.0.0
|
- uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507
|
||||||
name: Check that QL generated code was checked in
|
name: Check that QL generated code was checked in
|
||||||
with:
|
with:
|
||||||
extra_args: swift-codegen --all-files
|
extra_args: swift-codegen --all-files
|
||||||
|
|||||||
@@ -10,10 +10,9 @@ repos:
|
|||||||
exclude: /test/.*$(?<!\.ql)(?<!\.qll)(?<!\.qlref)|.*\.patch
|
exclude: /test/.*$(?<!\.ql)(?<!\.qll)(?<!\.qlref)|.*\.patch
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
rev: v13.0.1
|
rev: v17.0.6
|
||||||
hooks:
|
hooks:
|
||||||
- id: clang-format
|
- id: clang-format
|
||||||
files: ^swift/.*\.(h|c|cpp)$
|
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-autopep8
|
- repo: https://github.com/pre-commit/mirrors-autopep8
|
||||||
rev: v1.6.0
|
rev: v1.6.0
|
||||||
|
|||||||
@@ -338,7 +338,10 @@ class SwiftDispatcher {
|
|||||||
virtual void visit(const swift::MacroRoleAttr* attr) = 0;
|
virtual void visit(const swift::MacroRoleAttr* attr) = 0;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
requires(!std::derived_from<T, swift::TypeRepr>) void visit(const T* e, swift::Type) { visit(e); }
|
requires(!std::derived_from<T, swift::TypeRepr>)
|
||||||
|
void visit(const T* e, swift::Type) {
|
||||||
|
visit(e);
|
||||||
|
}
|
||||||
|
|
||||||
const swift::SourceManager& sourceManager;
|
const swift::SourceManager& sourceManager;
|
||||||
SwiftExtractorState& state;
|
SwiftExtractorState& state;
|
||||||
|
|||||||
@@ -17,34 +17,25 @@ class TrapDomain;
|
|||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept HasSourceRange = requires(T e) {
|
concept HasSourceRange = requires(T e) { e.getSourceRange(); };
|
||||||
e.getSourceRange();
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept HasStartAndEndLoc = requires(T e) {
|
concept HasStartAndEndLoc = requires(T e) {
|
||||||
e.getStartLoc();
|
e.getStartLoc();
|
||||||
e.getEndLoc();
|
e.getEndLoc();
|
||||||
}
|
} && !(HasSourceRange<T>);
|
||||||
&&!(HasSourceRange<T>);
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept HasLAndRParenLoc = requires(T e) {
|
concept HasLAndRParenLoc = requires(T e) {
|
||||||
e.getLParenLoc();
|
e.getLParenLoc();
|
||||||
e.getRParenLoc();
|
e.getRParenLoc();
|
||||||
}
|
} && !(HasSourceRange<T>)&&!(HasStartAndEndLoc<T>);
|
||||||
&&!(HasSourceRange<T>)&&!(HasStartAndEndLoc<T>);
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept HasOneLoc = requires(T e) {
|
concept HasOneLoc = requires(T e) { e.getLoc(); } && !(HasSourceRange<T>)&&(!HasStartAndEndLoc<T>);
|
||||||
e.getLoc();
|
|
||||||
}
|
|
||||||
&&!(HasSourceRange<T>)&&(!HasStartAndEndLoc<T>);
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept HasOneLocField = requires(T e) {
|
concept HasOneLocField = requires(T e) { e.Loc; };
|
||||||
e.Loc;
|
|
||||||
};
|
|
||||||
|
|
||||||
swift::SourceRange getSourceRange(const HasSourceRange auto& locatable) {
|
swift::SourceRange getSourceRange(const HasSourceRange auto& locatable) {
|
||||||
return locatable.getSourceRange();
|
return locatable.getSourceRange();
|
||||||
@@ -89,9 +80,7 @@ swift::SourceRange getSourceRange(const llvm::MutableArrayRef<Locatable>& locata
|
|||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template <typename E>
|
template <typename E>
|
||||||
concept IsLocatable = requires(E e) {
|
concept IsLocatable = requires(E e) { detail::getSourceRange(e); };
|
||||||
detail::getSourceRange(e);
|
|
||||||
};
|
|
||||||
|
|
||||||
class SwiftLocationExtractor {
|
class SwiftLocationExtractor {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace codeql {
|
namespace codeql {
|
||||||
|
|
||||||
codeql::NamedPattern PatternTranslator::translateNamedPattern(const swift::NamedPattern& pattern) {
|
codeql::NamedPattern PatternTranslator::translateNamedPattern(const swift::NamedPattern& pattern) {
|
||||||
|
|
||||||
auto entry = createPatternEntry(pattern);
|
auto entry = createPatternEntry(pattern);
|
||||||
entry.var_decl = dispatcher.fetchLabel(pattern.getDecl());
|
entry.var_decl = dispatcher.fetchLabel(pattern.getDecl());
|
||||||
return entry;
|
return entry;
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ class TrapLabel : public UntypedTrapLabel {
|
|||||||
static TrapLabel unsafeCreateFromUntyped(UntypedTrapLabel label) { return TrapLabel{label.id_}; }
|
static TrapLabel unsafeCreateFromUntyped(UntypedTrapLabel label) { return TrapLabel{label.id_}; }
|
||||||
|
|
||||||
template <typename SourceTag>
|
template <typename SourceTag>
|
||||||
requires std::derived_from<SourceTag, Tag> TrapLabel(const TrapLabel<SourceTag>& other)
|
requires std::derived_from<SourceTag, Tag>
|
||||||
: UntypedTrapLabel(other) {}
|
TrapLabel(const TrapLabel<SourceTag>& other) : UntypedTrapLabel(other) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// wrapper class to allow directly assigning a vector of TrapLabel<A> to a vector of
|
// wrapper class to allow directly assigning a vector of TrapLabel<A> to a vector of
|
||||||
|
|||||||
1
swift/integration-tests/.clang-format
Normal file
1
swift/integration-tests/.clang-format
Normal file
@@ -0,0 +1 @@
|
|||||||
|
DisableFormat: true
|
||||||
Reference in New Issue
Block a user