.clang-format 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # Defines the Chromium style for automatic reformatting.
  2. # http://clang.llvm.org/docs/ClangFormatStyleOptions.html
  3. BasedOnStyle: Chromium
  4. # This defaults to 'Auto'. Explicitly set it for a while, so that
  5. # 'vector<vector<int> >' in existing files gets formatted to
  6. # 'vector<vector<int>>'. ('Auto' means that clang-format will only use
  7. # 'int>>' if the file already contains at least one such instance.)
  8. Standard: Cpp11
  9. # TODO(crbug.com/1392808): Remove when InsertBraces has been upstreamed into
  10. # the Chromium style (is implied by BasedOnStyle: Chromium).
  11. InsertBraces: true
  12. InsertNewlineAtEOF: true
  13. # Sort #includes by following
  14. # https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes
  15. #
  16. # ref: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#includeblocks
  17. IncludeBlocks: Regroup
  18. # ref: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#includecategories
  19. IncludeCategories:
  20. # The win32 api has all sorts of implicit include order dependencies :-/
  21. # Give a few headers special priorities that make sure they appear before
  22. # all other headers.
  23. # Sync this with SerializeIncludes in tools/add_header.py.
  24. # TODO(crbug.com/329138753): remove include sorting from tools/add_header.py
  25. # after confirming clang-format sort works well.
  26. # LINT.IfChange(winheader)
  27. - Regex: '^<objbase\.h>' # This has to be before initguid.h.
  28. Priority: 1
  29. - Regex: '^<(atlbase|initguid|mmdeviceapi|ocidl|ole2|shobjidl|tchar|unknwn|windows|winsock2|winternl|ws2tcpip)\.h>'
  30. Priority: 2
  31. # LINT.ThenChange(/tools/add_header.py:winheader)
  32. # UIAutomation*.h needs to be after base/win/atl.h.
  33. # Note the low priority number.
  34. - Regex: '^<UIAutomation.*\.h>'
  35. Priority: 6
  36. # Other C system headers.
  37. - Regex: '^<.*\.h>'
  38. Priority: 3
  39. # C++ standard library headers.
  40. - Regex: '^<.*>'
  41. Priority: 4
  42. # windows_h_disallowed.h should appear last. Note the low priority number.
  43. - Regex: '"(.*/)?windows_h_disallowed\.h"'
  44. Priority: 7
  45. # Other libraries.
  46. - Regex: '.*'
  47. Priority: 5
  48. # ref: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#includeismainregex
  49. IncludeIsMainRegex: "\
  50. (_(32|64|android|apple|chromeos|freebsd|fuchsia|fuzzer|ios|linux|mac|nacl|openbsd|posix|stubs?|win))?\
  51. (_(unit|browser|perf)?tests?)?$"
  52. # Make sure code like:
  53. # IPC_BEGIN_MESSAGE_MAP()
  54. # IPC_MESSAGE_HANDLER(WidgetHostViewHost_Update, OnUpdate)
  55. # IPC_END_MESSAGE_MAP()
  56. # gets correctly indented.
  57. MacroBlockBegin: "^\
  58. BEGIN_MSG_MAP|\
  59. BEGIN_MSG_MAP_EX|\
  60. BEGIN_SAFE_MSG_MAP_EX|\
  61. CR_BEGIN_MSG_MAP_EX|\
  62. IPC_BEGIN_MESSAGE_MAP|\
  63. IPC_BEGIN_MESSAGE_MAP_WITH_PARAM|\
  64. IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN|\
  65. IPC_STRUCT_BEGIN|\
  66. IPC_STRUCT_BEGIN_WITH_PARENT|\
  67. IPC_STRUCT_TRAITS_BEGIN|\
  68. POLPARAMS_BEGIN|\
  69. PPAPI_BEGIN_MESSAGE_MAP$"
  70. MacroBlockEnd: "^\
  71. CR_END_MSG_MAP|\
  72. END_MSG_MAP|\
  73. IPC_END_MESSAGE_MAP|\
  74. IPC_PROTOBUF_MESSAGE_TRAITS_END|\
  75. IPC_STRUCT_END|\
  76. IPC_STRUCT_TRAITS_END|\
  77. POLPARAMS_END|\
  78. PPAPI_END_MESSAGE_MAP$"