Skip to content

Running clang-format once produces different output from running it twice, on some inputs #58202

@bzbarsky-apple

Description

@bzbarsky-apple

Consider this minimal Objective-C header:

#import <Foundation/Foundation.h>

@interface Foo : NSObject

/**
  */- (void)foo;

@end

If I run clang-format on it once, I get this diff against the original file:

@@ -3,6 +3,7 @@
 @interface Foo : NSObject
 
 /**
-  */- (void)foo;
+ */
+-(void)foo;
 
 @end

If I now run it again, I get this diff against the output of the first run:

@@ -4,6 +4,6 @@
 
 /**
  */
--(void)foo;
+- (void)foo;
 
 @end

Ideally, running clang-format would be idempotent, so that CI that runs clang-format on the tree and fails on any observed changes can work correctly.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions