зеркало из https://github.com/github/codeql.git
Swift: update formatting to `clang-format` 17.0.6
Also, added a format check in `swift.yml`.
This commit is contained in:
Родитель
01b89508a8
Коммит
33b6ce7365
|
@ -0,0 +1 @@
|
|||
DisableFormat: true
|
|
@ -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
|
||||
|
|
|
@ -10,10 +10,9 @@ repos:
|
|||
exclude: /test/.*$(?<!\.ql)(?<!\.qll)(?<!\.qlref)|.*\.patch
|
||||
|
||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
rev: v13.0.1
|
||||
rev: v17.0.6
|
||||
hooks:
|
||||
- id: clang-format
|
||||
files: ^swift/.*\.(h|c|cpp)$
|
||||
|
||||
- repo: https://github.com/pre-commit/mirrors-autopep8
|
||||
rev: v1.6.0
|
||||
|
|
|
@ -338,7 +338,10 @@ class SwiftDispatcher {
|
|||
virtual void visit(const swift::MacroRoleAttr* attr) = 0;
|
||||
|
||||
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;
|
||||
SwiftExtractorState& state;
|
||||
|
|
|
@ -17,34 +17,25 @@ class TrapDomain;
|
|||
|
||||
namespace detail {
|
||||
template <typename T>
|
||||
concept HasSourceRange = requires(T e) {
|
||||
e.getSourceRange();
|
||||
};
|
||||
concept HasSourceRange = requires(T e) { e.getSourceRange(); };
|
||||
|
||||
template <typename T>
|
||||
concept HasStartAndEndLoc = requires(T e) {
|
||||
e.getStartLoc();
|
||||
e.getEndLoc();
|
||||
}
|
||||
&&!(HasSourceRange<T>);
|
||||
} && !(HasSourceRange<T>);
|
||||
|
||||
template <typename T>
|
||||
concept HasLAndRParenLoc = requires(T e) {
|
||||
e.getLParenLoc();
|
||||
e.getRParenLoc();
|
||||
}
|
||||
&&!(HasSourceRange<T>)&&!(HasStartAndEndLoc<T>);
|
||||
} && !(HasSourceRange<T>)&&!(HasStartAndEndLoc<T>);
|
||||
|
||||
template <typename T>
|
||||
concept HasOneLoc = requires(T e) {
|
||||
e.getLoc();
|
||||
}
|
||||
&&!(HasSourceRange<T>)&&(!HasStartAndEndLoc<T>);
|
||||
concept HasOneLoc = requires(T e) { e.getLoc(); } && !(HasSourceRange<T>)&&(!HasStartAndEndLoc<T>);
|
||||
|
||||
template <typename T>
|
||||
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<Locatable>& locata
|
|||
} // namespace detail
|
||||
|
||||
template <typename E>
|
||||
concept IsLocatable = requires(E e) {
|
||||
detail::getSourceRange(e);
|
||||
};
|
||||
concept IsLocatable = requires(E e) { detail::getSourceRange(e); };
|
||||
|
||||
class SwiftLocationExtractor {
|
||||
public:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -83,8 +83,8 @@ class TrapLabel : public UntypedTrapLabel {
|
|||
static TrapLabel unsafeCreateFromUntyped(UntypedTrapLabel label) { return TrapLabel{label.id_}; }
|
||||
|
||||
template <typename SourceTag>
|
||||
requires std::derived_from<SourceTag, Tag> TrapLabel(const TrapLabel<SourceTag>& other)
|
||||
: UntypedTrapLabel(other) {}
|
||||
requires std::derived_from<SourceTag, Tag>
|
||||
TrapLabel(const TrapLabel<SourceTag>& other) : UntypedTrapLabel(other) {}
|
||||
};
|
||||
|
||||
// wrapper class to allow directly assigning a vector of TrapLabel<A> to a vector of
|
||||
|
@ -96,7 +96,7 @@ struct TrapLabelVectorWrapper {
|
|||
std::vector<TrapLabel<TagParam>> data;
|
||||
|
||||
template <typename DestinationTag>
|
||||
requires std::derived_from<Tag, DestinationTag>
|
||||
requires std::derived_from<Tag, DestinationTag>
|
||||
operator std::vector<TrapLabel<DestinationTag>>() && {
|
||||
// reinterpret_cast is safe because TrapLabel instances differ only on the type, not the
|
||||
// underlying data
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
DisableFormat: true
|
|
@ -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, \
|
||||
|
|
Загрузка…
Ссылка в новой задаче