Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply updated code style #1196

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
93 changes: 10 additions & 83 deletions .clang-format
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mb will we add the formatting script first, and then the new rules?

Original file line number Diff line number Diff line change
@@ -1,86 +1,13 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should keep it?

AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: true
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
ColumnLimit: 160
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
DerivePointerAlignment: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<'
Priority: 1
IndentCaseLabels: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should keep it?

IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: '^TL_[A-Z_]+_FUN$|^REGISTER_MODULE$'
MacroBlockEnd: '^TL_[A-Z_]+_FUN_END$|^REGISTER_MODULE_END$'
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 1100
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep it. IMHO

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes are sorted implicitly by setting base variant on LLVM, I suppose.

SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++17
TabWidth: 2
UseTab: Never
Language: Cpp
BasedOnStyle: LLVM
ColumnLimit: 160
PointerAlignment: Left
ReferenceAlignment: Pointer
Standard: c++20
UseTab: Never
AlwaysBreakTemplateDeclarations: Yes
RequiresClausePosition: OwnLine
IndentRequiresClause: No
...

11 changes: 11 additions & 0 deletions .git-blame-ignore-revs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after squash, there will be another sha commit. .git-blame-ignore-revs should be added after the merge of this MR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's added here so you can test it and make sure that git blame continues working

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is a file that can be used by git-blame to ignore some revisions.
# (git 2.23+, released in August 2019)
#
# Can be configured as follow:
#
# $ git config blame.ignoreRevsFile .git-blame-ignore-revs
#
# For more information you can look at git-blame(1) man page.

# Applied clang-format to runtime, runtime-common, and runtime-light directories
a238ec8da173c0eb00bb60aae90f07c82af387ae
20 changes: 10 additions & 10 deletions runtime-common/core/allocator/runtime-allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
#include "runtime-common/core/memory-resource/unsynchronized_pool_resource.h"

struct RuntimeAllocator final : vk::not_copyable {
static RuntimeAllocator &get() noexcept;
static RuntimeAllocator& get() noexcept;

RuntimeAllocator() = default;
RuntimeAllocator(size_t script_mem_size, size_t oom_handling_mem_size);

void init(void *buffer, size_t script_mem_size, size_t oom_handling_mem_size);
void init(void* buffer, size_t script_mem_size, size_t oom_handling_mem_size);
void free();

void *alloc_script_memory(size_t size) noexcept;
void *alloc0_script_memory(size_t size) noexcept;
void *realloc_script_memory(void *mem, size_t new_size, size_t old_size) noexcept;
void free_script_memory(void *mem, size_t size) noexcept;
void* alloc_script_memory(size_t size) noexcept;
void* alloc0_script_memory(size_t size) noexcept;
void* realloc_script_memory(void* mem, size_t new_size, size_t old_size) noexcept;
void free_script_memory(void* mem, size_t size) noexcept;

void *alloc_global_memory(size_t size) noexcept;
void *alloc0_global_memory(size_t size) noexcept;
void *realloc_global_memory(void *mem, size_t new_size, size_t old_size) noexcept;
void free_global_memory(void *mem, size_t size) noexcept;
void* alloc_global_memory(size_t size) noexcept;
void* alloc0_global_memory(size_t size) noexcept;
void* realloc_global_memory(void* mem, size_t new_size, size_t old_size) noexcept;
void free_global_memory(void* mem, size_t size) noexcept;

memory_resource::unsynchronized_pool_resource memory_resource;
};
18 changes: 6 additions & 12 deletions runtime-common/core/allocator/script-allocator-managed.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,15 @@

class ScriptAllocatorManaged {
public:
static void *operator new(size_t size) noexcept {
return RuntimeAllocator::get().alloc_script_memory(size);
}
static void* operator new(size_t size) noexcept { return RuntimeAllocator::get().alloc_script_memory(size); }

static void *operator new(size_t, void *ptr) noexcept {
return ptr;
}
static void* operator new(size_t, void* ptr) noexcept { return ptr; }

static void operator delete(void *ptr, size_t size) noexcept {
RuntimeAllocator::get().free_script_memory(ptr, size);
}
static void operator delete(void* ptr, size_t size) noexcept { RuntimeAllocator::get().free_script_memory(ptr, size); }

static void *operator new[](size_t count) = delete;
static void operator delete[](void *ptr, size_t sz) = delete;
static void operator delete[](void *ptr) = delete;
static void* operator new[](size_t count) = delete;
static void operator delete[](void* ptr, size_t sz) = delete;
static void operator delete[](void* ptr) = delete;

protected:
~ScriptAllocatorManaged() = default;
Expand Down
11 changes: 5 additions & 6 deletions runtime-common/core/array_access.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "runtime-common/core/class-instance/refcountable-php-classes.h"

#ifndef INCLUDED_FROM_KPHP_CORE
#error "this file must be included only from runtime-core.h"
#error "this file must be included only from runtime-core.h"
#endif

struct C$ArrayAccess : public may_be_mixed_base {
Expand All @@ -17,8 +17,7 @@ struct C$ArrayAccess : public may_be_mixed_base {
~C$ArrayAccess() override __attribute__((always_inline)) = default;
};


bool f$ArrayAccess$$offsetExists(class_instance<C$ArrayAccess> const & /*v$this*/, mixed const & /*v$offset*/) noexcept;
mixed f$ArrayAccess$$offsetGet(class_instance<C$ArrayAccess> const & /*v$this*/, mixed const & /*v$offset*/) noexcept;
void f$ArrayAccess$$offsetSet(class_instance<C$ArrayAccess> const & /*v$this*/, mixed const & /*v$offset*/, mixed const & /*v$value*/) noexcept;
void f$ArrayAccess$$offsetUnset(class_instance<C$ArrayAccess> const & /*v$this*/, mixed const & /*v$offset*/) noexcept;
bool f$ArrayAccess$$offsetExists(class_instance<C$ArrayAccess> const& /*v$this*/, mixed const& /*v$offset*/) noexcept;
mixed f$ArrayAccess$$offsetGet(class_instance<C$ArrayAccess> const& /*v$this*/, mixed const& /*v$offset*/) noexcept;
void f$ArrayAccess$$offsetSet(class_instance<C$ArrayAccess> const& /*v$this*/, mixed const& /*v$offset*/, mixed const& /*v$value*/) noexcept;
void f$ArrayAccess$$offsetUnset(class_instance<C$ArrayAccess> const& /*v$this*/, mixed const& /*v$offset*/) noexcept;
Loading
Loading