Last active
January 21, 2025 09:37
-
-
Save sivakov512/79d778a13c34be32074639752f7a897e to your computer and use it in GitHub Desktop.
clang-tidy & clang-config Google styleguide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
BasedOnStyle: Google | |
# We keep 2-space indentation, 80-column limit, attached braces, etc. | |
IndentWidth: 2 | |
TabWidth: 2 | |
UseTab: Never | |
ColumnLimit: 80 | |
BreakBeforeBraces: Attach | |
# Keep namespaces unindented in Google style. | |
NamespaceIndentation: None | |
# Google style typically aligns access specifiers (public, private, etc.) | |
AccessModifierOffset: -2 | |
# Avoid single-line if/else, loops, and function bodies in Google style. | |
AllowShortIfStatementsOnASingleLine: false | |
AllowShortLoopsOnASingleLine: false | |
AllowShortFunctionsOnASingleLine: Empty | |
# No spaces inside parentheses or angle brackets. | |
SpacesInParentheses: false | |
SpacesInAngles: false | |
# Some additional fine-tuning. | |
SpaceAfterCStyleCast: true | |
SpaceBeforeAssignmentOperators: true | |
PenaltyReturnTypeOnItsOwnLine: 200 | |
# -- Include sorting settings -- | |
# | |
# SortIncludes: true -> clang-format will sort #includes. | |
# IncludeBlocks: Preserve -> clang-format will NOT merge or split #include | |
# blocks, but will reorder includes *within* each block. That way you can have | |
# separate blocks for system headers, library headers, local headers, etc., and | |
# clang-format won't reorder across those blank-line boundaries. | |
SortIncludes: true | |
IncludeBlocks: Preserve |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# In this section, we define which checks we want to run or disable. | |
# We enable most checks, including Google style checks, readability, | |
# modernize, performance, and so on. Then we explicitly disable | |
# certain checks that conflict with our style preferences. | |
Checks: clang-diagnostic-* | |
clang-analyzer-* | |
google-* | |
readability-* | |
modernize-* | |
performance-* | |
readability-identifier-naming | |
-google-runtime-references | |
-google-readability-todo | |
-modernize-use-trailing-return-type | |
# Turn all warnings into errors. | |
WarningsAsErrors: "*" | |
HeaderFilterRegex: ".*" | |
AnalyzeTemporaryDtors: false | |
CheckOptions: | |
# ======================== | |
# == Identifier Naming == | |
# ======================== | |
# | |
# The following keys configure the naming style in line with | |
# a typical Google C++ Style approach, adjusting prefixes, suffixes, | |
# and case for classes, functions, variables, etc. | |
- key: readability-identifier-naming.ClassCase | |
value: CamelCase | |
- key: readability-identifier-naming.StructCase | |
value: CamelCase | |
- key: readability-identifier-naming.ClassAbstractCase | |
value: CamelCase | |
- key: readability-identifier-naming.EnumCase | |
value: CamelCase | |
- key: readability-identifier-naming.EnumConstantCase | |
value: CamelCase | |
- key: readability-identifier-naming.EnumConstantPrefix | |
value: "k" | |
- key: readability-identifier-naming.ConstantCase | |
value: CamelCase | |
- key: readability-identifier-naming.ConstantPrefix | |
value: "k" | |
- key: readability-identifier-naming.FunctionCase | |
value: CamelCase | |
- key: readability-identifier-naming.MethodCase | |
value: CamelCase | |
- key: readability-identifier-naming.PrivateMethodCase | |
value: CamelCase | |
- key: readability-identifier-naming.ParameterCase | |
value: lower_case | |
- key: readability-identifier-naming.LocalVariableCase | |
value: lower_case | |
- key: readability-identifier-naming.GlobalVariableCase | |
value: snake_case | |
- key: readability-identifier-naming.GlobalVariablePrefix | |
value: "g_" | |
- key: readability-identifier-naming.MemberCase | |
value: lower_case | |
- key: readability-identifier-naming.MemberSuffix | |
value: "_" | |
- key: readability-identifier-naming.ClassConstantCase | |
value: CamelCase | |
- key: readability-identifier-naming.ClassConstantPrefix | |
value: "k" | |
- key: readability-identifier-naming.ClassMemberCase | |
value: lower_case | |
- key: readability-identifier-naming.ClassMemberSuffix | |
value: "_" | |
# ================================== | |
# == Additional Google / Modernize == | |
# ================================== | |
# | |
# Here are some extra checks aligned with Google style. | |
# We can also configure their behavior. | |
- key: google-build-using-namespace.ShortNamespaceLines | |
value: "1" | |
- key: google-readability-braces-around-statements.ShortStatementLines | |
value: "1" | |
- key: google-runtime-int.IncludeStyle | |
value: "uint16" | |
- key: google-explicit-constructor.StrictMode | |
value: "false" | |
- key: modernize-use-override.IgnoreDestructors | |
value: "true" | |
- key: modernize-use-nullptr.NullMacros | |
value: "NULL" | |
- key: performance-for-range-copy.AllowedTypes | |
value: "std::initializer_list" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment