cpp-best-practices / gui_starter_template

A template CMake project to get you started with C++ and tooling

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Regex broken in clang format

jpc0 opened this issue · comments

https://github.com/cpp-best-practices/cpp_starter_project/blob/2b9c3c9d25ae4df32b4b79abed6c08c09a52df54/.clang-format#L60

This specific line seems to be broken in the clang format file, it seems that the trailing / is not meant to be there.

Am closing this issue since it wasn't the cause of the issue I was chasing, somehow my indentation broke in the file, however this / and the / on line 62 is kind of sketchy, is this something clang-format specific?

Am closing this issue since it wasn't the cause of the issue I was chasing, somehow my indentation broke in the file, however this / and the / on line 62 is kind of sketchy, is this something clang-format specific?

It is valid, but strange. This is more readable:

Claus-iMac:cpp_starter_project clausklein$ clang-format --dump-config
---
Language:        Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: DontAlign
AlignArrayOfStructures: None
AlignConsecutiveMacros: None
AlignConsecutiveAssignments: None
# ...
IncludeBlocks:   Preserve
IncludeCategories:
  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
    Priority:        2
    SortPriority:    0
    CaseSensitive:   false
  - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
    Priority:        3
    SortPriority:    0
    CaseSensitive:   false
  - Regex:           '.*'
    Priority:        1
    SortPriority:    0
    CaseSensitive:   false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires:  false
IndentWidth:     2
IndentWrappedFunctionNames: true
InsertTrailingCommas: None
# ...

I agree that does look a little more reasonable, because of the differing standards in regex it may also be worth escaping the / characters in those lines. Something along the lines of:

IncludeCategories:
  - Regex:           '^"(llvm|llvm-c|clang|clang-c)\/'
    Priority:        2
    SortPriority:    0
    CaseSensitive:   false
  - Regex:           '^(<|"(gtest|gmock|isl|json)\/)'
    Priority:        3
    SortPriority:    0
    CaseSensitive:   false
  - Regex:           '.*'
    Priority:        1
    SortPriority:    0
    CaseSensitive:   false

I can probably open a pull request for that.

I would say yes.