diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000000..e3845288a2ae --- /dev/null +++ b/.clang-format @@ -0,0 +1 @@ +DisableFormat: true diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 8a04d4741181..ff9cd29e238d 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -73,6 +73,15 @@ jobs: steps: - uses: actions/checkout@v4 - 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: if : ${{ github.event_name == 'pull_request' }} runs-on: ubuntu-latest @@ -82,12 +91,12 @@ jobs: - uses: actions/setup-python@v4 with: 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 with: extra_args: autopep8 --all-files - 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 with: extra_args: swift-codegen --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1a2ed103df68..383bc1103837 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,10 +10,9 @@ repos: exclude: /test/.*$(? - requires(!std::derived_from) void visit(const T* e, swift::Type) { visit(e); } + requires(!std::derived_from) + void visit(const T* e, swift::Type) { + visit(e); + } const swift::SourceManager& sourceManager; SwiftExtractorState& state; diff --git a/swift/extractor/infra/SwiftLocationExtractor.h b/swift/extractor/infra/SwiftLocationExtractor.h index d3892b094a1f..dd015a94c8de 100644 --- a/swift/extractor/infra/SwiftLocationExtractor.h +++ b/swift/extractor/infra/SwiftLocationExtractor.h @@ -17,34 +17,25 @@ class TrapDomain; namespace detail { template -concept HasSourceRange = requires(T e) { - e.getSourceRange(); -}; +concept HasSourceRange = requires(T e) { e.getSourceRange(); }; template concept HasStartAndEndLoc = requires(T e) { e.getStartLoc(); e.getEndLoc(); -} -&&!(HasSourceRange); +} && !(HasSourceRange); template concept HasLAndRParenLoc = requires(T e) { e.getLParenLoc(); e.getRParenLoc(); -} -&&!(HasSourceRange)&&!(HasStartAndEndLoc); +} && !(HasSourceRange)&&!(HasStartAndEndLoc); template -concept HasOneLoc = requires(T e) { - e.getLoc(); -} -&&!(HasSourceRange)&&(!HasStartAndEndLoc); +concept HasOneLoc = requires(T e) { e.getLoc(); } && !(HasSourceRange)&&(!HasStartAndEndLoc); template -concept HasOneLocField = requires(T e) { - e.Loc; -}; +concept HasOneLocField = requires(T e) { e.Loc; }; swift::SourceRange getSourceRange(const HasSourceRange auto& locatable) { return locatable.getSourceRange(); @@ -89,9 +80,7 @@ swift::SourceRange getSourceRange(const llvm::MutableArrayRef& locata } // namespace detail template -concept IsLocatable = requires(E e) { - detail::getSourceRange(e); -}; +concept IsLocatable = requires(E e) { detail::getSourceRange(e); }; class SwiftLocationExtractor { public: diff --git a/swift/extractor/translators/PatternTranslator.cpp b/swift/extractor/translators/PatternTranslator.cpp index 5a89dbbc59e6..08eb3c6abf57 100644 --- a/swift/extractor/translators/PatternTranslator.cpp +++ b/swift/extractor/translators/PatternTranslator.cpp @@ -3,7 +3,6 @@ namespace codeql { codeql::NamedPattern PatternTranslator::translateNamedPattern(const swift::NamedPattern& pattern) { - auto entry = createPatternEntry(pattern); entry.var_decl = dispatcher.fetchLabel(pattern.getDecl()); return entry; diff --git a/swift/extractor/trap/TrapLabel.h b/swift/extractor/trap/TrapLabel.h index e0091a6d5361..d2f5ea879814 100644 --- a/swift/extractor/trap/TrapLabel.h +++ b/swift/extractor/trap/TrapLabel.h @@ -83,8 +83,8 @@ class TrapLabel : public UntypedTrapLabel { static TrapLabel unsafeCreateFromUntyped(UntypedTrapLabel label) { return TrapLabel{label.id_}; } template - requires std::derived_from TrapLabel(const TrapLabel& other) - : UntypedTrapLabel(other) {} + requires std::derived_from + TrapLabel(const TrapLabel& other) : UntypedTrapLabel(other) {} }; // wrapper class to allow directly assigning a vector of TrapLabel to a vector of @@ -96,7 +96,7 @@ struct TrapLabelVectorWrapper { std::vector> data; template - requires std::derived_from + requires std::derived_from operator std::vector>() && { // reinterpret_cast is safe because TrapLabel instances differ only on the type, not the // underlying data diff --git a/swift/integration-tests/.clang-format b/swift/integration-tests/.clang-format new file mode 100644 index 000000000000..e3845288a2ae --- /dev/null +++ b/swift/integration-tests/.clang-format @@ -0,0 +1 @@ +DisableFormat: true diff --git a/swift/logging/SwiftLogging.h b/swift/logging/SwiftLogging.h index 6752de7a15c0..e94ceb0f6f8b 100644 --- a/swift/logging/SwiftLogging.h +++ b/swift/logging/SwiftLogging.h @@ -63,7 +63,7 @@ #define DIAGNOSE_WITH_LEVEL(LEVEL, ID, FORMAT, ...) \ do { \ auto _now = ::binlog::clockNow(); \ - const ::codeql::Diagnostic& _id = ID; \ + const ::codeql::Diagnostic& _id = ID; \ ::codeql::Log::diagnose(_id, std::chrono::nanoseconds{_now}, \ fmt::format(FORMAT __VA_OPT__(, ) __VA_ARGS__)); \ LOG_WITH_LEVEL_AND_TIME(LEVEL, _now, CODEQL_DIAGNOSTIC_LOG_FORMAT_PREFIX FORMAT, \