mirror of https://github.com/opencv/opencv.git
Page:
.clang_format
Pages
.clang_format
2018
2019
2020
2021
2022
2023
2024
Archive
Branches
BuildOpenCV4OpenVINO
CI configuration
CPU optimizations build options
ChangeLog
CiteOpenCV
Coding_Style_Guide
Compact build advice
Contributing to G API: PRs
Custom OpenCV Android SDK and AAR package build
DNN Efficiency
Deep Learning in OpenCV
Documentation improvement plan
Enabling GStreamer source in G API
Enabling oneVPL source in G API
Evolution Proposals
FAQ
G API Ideas towards OpenCV 5.0
G API Python Bindings
GSoC_2017
GSoC_2018
GSoC_2019
GSoC_2020
GSoC_2021
GSoC_2022
GSoC_2023
GSoC_2024
Graph API
Home
HowToUsePerfTests
HowToWritePerfTests
How_to_contribute
Huawei CANN Backend
Intel OpenVINO backend
Linux_contribution_guide
MediaSDK encode decode backend
OE 0. Template
OE 1. Old C API
OE 10. FP16
OE 11. Logging
OE 12. Lapack
OE 13. DNN ONNX Importer
OE 14. DNN FP16
OE 15. Bit Exactness
OE 16. Mini Halide
OE 17. New Filter Engine
OE 18. Module Optflow
OE 19. Module Stereo
OE 2. OpenCV 2
OE 20. Module Calibration
OE 21. Module Tracking
OE 21. Tracking API
OE 22. Module Point Cloud
OE 23. Module GAPI
OE 24. Module HighGUI
OE 25. Fast VideoIO
OE 26. Samples
OE 27. Wide Universal Intrinsics
OE 28. Image Stitching
OE 29. Adding AVX512 Support
OE 3. OpenCV 3
OE 30. Color Calibration
OE 31. Julia Bindings
OE 32. Change OpenCV License to Apache 2
OE 33. 3D Module
OE 34. Named Parameters
OE 35. TFLite support
OE 4. OpenCV 4
OE 5. OpenCV 5
OpenCL optimizations
OpenCV 5
OpenCV Debugging Facilities
OpenCV Platforms
OpenCV RISC V
OpenCVLogo
OpenCV_GSoC
OpenCV_GSoC_Application
Opencv3
Opencv4
Profiling OpenCV Applications
QA_in_OpenCV
Running native OpenCV code with Hardware Address Sanitizer
TIM VX Backend For Running OpenCV On NPU
Template
TensorFlow Object Detection API
TensorFlow text graphs
Using G API with MS ONNX Runtime
Using G API with OpenCV AI Kit (OAK)
Using G API with OpenVINO Toolkit
Using G API with PlaidML backend
Video IO hardware acceleration
Video capture and write benchmark
[Deprecated] Tengine based acceleration
8
.clang_format
Maksim Shabunin edited this page 2024-04-03 01:12:48 +03:00
Table of Contents
Instruction
Note: clang-format 12 is used as a baseline
Installation
Standalone LLVM builds - LLVM GitHub Releases: https://github.com/llvm/llvm-project/releases
For example 16: https://github.com/llvm/llvm-project/releases/tag/llvmorg-16.0.4
Debian/Ubuntu
sudo apt install clang-format
Ubuntu 22.04 - clang-format 14
Windows
One of variants:
- Visual studio component "C++ Clang Tools for Windows"
- Visual Studio extension: https://marketplace.visualstudio.com/items?itemName=LLVMExtensions.ClangFormat
OSX
brew install clang-format
Run
- Run in "check" mode (print formatting issues)
clang-format --style=file:${HOME}/my-clang-format --dry-run --Werror <path-to-src-file>
- Run in "inplace edit" mode (replace file contents with formatted code)
clang-format --style=file:${HOME}/my-clang-format -i <path-to-src-file>
- Run in editor using extension: consult your editor/extension documentation
Links
- (ver. 12) introduction + editor integrations: https://releases.llvm.org/12.0.0/tools/clang/docs/ClangFormat.html
- (ver. 12) configuration reference: https://releases.llvm.org/12.0.0/tools/clang/docs/ClangFormatStyleOptions.html
- (latest) Introduction: https://clang.llvm.org/docs/ClangFormat.html
Future improvements
- Create list of tracked files
- Add cmake targets for check/format modes
- Add CI task to check tracked files (in Documentation builder, for example)
Configuration
# clang-format version 12
# https://releases.llvm.org/12.0.0/tools/clang/docs/ClangFormatStyleOptions.html
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: None
AlignEscapedNewlines: DontAlign
AlignOperands: Align
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: None
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: Both
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
BreakStringLiterals: true
ColumnLimit: 100
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
FixNamespaceComments: true
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentExternBlock: NoIndent
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWrappedFunctionNames: true
InsertTrailingCommas: None
KeepEmptyLinesAtTheStartOfBlocks: false
Language: Cpp
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
PenaltyBreakBeforeFirstCallParameter: 15
PenaltyBreakString: 10
#PenaltyReturnTypeOnItsOwnLine: 15
#PenaltyExcessCharacter: 3
PenaltyIndentedWhitespace: 1
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatementsExceptForEachMacros
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++11
TabWidth: 8
UseTab: Never
#WhitespaceSensitiveMacros: ["CV_Check"]
- Home
- Deep Learning in OpenCV
- Running OpenCV on Various Platforms
- OpenCV 5
- OpenCV 4
- OpenCV 3
- Development process
- OpenCV GSoC
- Archive
© Copyright 2024, OpenCV team