[llvm-bugs] [Bug 26887] New: clang-format accidentally add space for each toolkit run

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 9 07:58:12 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26887

            Bug ID: 26887
           Summary: clang-format accidentally add space for each toolkit
                    run
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: pavel.odintsov at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org
    Classification: Unclassified

Hello, folks!

I have issues with clang-format from clang 3.8.

I'm trying to reformat this code:
https://www.dropbox.com/s/z9x3n1k3o7kaxi9/fastnetmon_packet_parser_clang_bug_report.h?dl=0

And I have following .clang-format:
---
Language:        Cpp
AccessModifierOffset: 0
AlignAfterOpenBracket: true
AlignConsecutiveAssignments: true
AlignEscapedNewlinesLeft: true
AlignOperands:   true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
ColumnLimit:     120
CommentPragmas:  ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 0
# Of line should be splitted to two lines we are using this additional indent
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat:   false
ExperimentalAutoDetectBinPacking: false
ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
IndentCaseLabels: false
IndentWidth:     4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd:   ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 100
PenaltyBreakComment: 100
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 100
PenaltyExcessCharacter: 1
PenaltyReturnTypeOnItsOwnLine: 20
PointerAlignment: Left
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles:  false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard:        Cpp11
TabWidth:        4
UseTab:          Never
...

I've applied clang-format in place:
/opt/dps/libraries/clang_3_8_0/bin/clang-format -i fastnetmon_packet_parser.h

And I have following changes here:
diff --git a/src/fastnetmon_packet_parser.h b/src/fastnetmon_packet_parser.h
index 0e5d1a5..075a810 100644
--- a/src/fastnetmon_packet_parser.h
+++ b/src/fastnetmon_packet_parser.h
@@ -72,7 +72,7 @@ struct pfring_extended_pkthdr {
                                timestamp from */
 #define PKT_FLAGS_CHECKSUM_OFFLOAD            \
     1 << 0 /* IP/TCP checksum offload enabled \
-                                             */
+                                              */
 #define PKT_FLAGS_CHECKSUM_OK 1 << 1 /* Valid checksum (with IP/TCP checksum
offload enabled) */
 #define PKT_FLAGS_IP_MORE_FRAG 1 << 2 /* IP More fragments flag set */
 #define PKT_FLAGS_IP_FRAG_OFFSET 1 << 3 /* IP fragment offset set (not 0) */

Then I've repeated this command 10 times (I'm running reformatting after each
commit so it's real working case) and got following:
--- a/src/fastnetmon_packet_parser.h
+++ b/src/fastnetmon_packet_parser.h
@@ -72,7 +72,7 @@ struct pfring_extended_pkthdr {
                                timestamp from */
 #define PKT_FLAGS_CHECKSUM_OFFLOAD            \
     1 << 0 /* IP/TCP checksum offload enabled \
-                                             */
+                                                      */
 #define PKT_FLAGS_CHECKSUM_OK 1 << 1 /* Valid checksum (with IP/TCP checksum
offload enabled) */
 #define PKT_FLAGS_IP_MORE_FRAG 1 << 2 /* IP More fragments flag set */
 #define PKT_FLAGS_IP_FRAG_OFFSET 1 << 3 /* IP fragment offset set (not 0) */

As you can see "*/" are moving for one symbol to right side with each call.

Could you fix it?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160309/4f09f191/attachment.html>


More information about the llvm-bugs mailing list