Skip to content

[Format] Regression in clang-format - -dump_config < path/to/objc_file.m (now outputs Language: Cpp) #79023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bhamiltoncx opened this issue Jan 22, 2024 · 1 comment · Fixed by #79051

Comments

@bhamiltoncx
Copy link
Contributor

bhamiltoncx commented Jan 22, 2024

clang-format - -dump_config < path/to/objc_file.m no longer works as of 3791b3f (it now outputs Language: Cpp instead of Language: ObjC):

% cat /tmp/objc_file.m
#import <Foundation/Foundation.h>

@interface Foo : NSObject
- (void)doStuff;
@end;

@implementation Foo
@end

% ./build/bin/clang-format --version
clang-format version 18.0.0git (https://github.com/llvm/llvm-project.git 3791b3fca6eac5e403b91550ed0f774866cf3ede)

% ./build/bin/clang-format - -dump-config < /tmp/objc_file.m | grep -e '^Language'
Language:        Cpp

This should say Language: ObjC.

The issue does not reproduce if I locally revert that change or go to its parent 9810fe1:

% ./build/bin/clang-format --version
clang-format version 18.0.0git (https://github.com/llvm/llvm-project.git 9810fe1a91eb9ce18246fb1528232a539dbd37fc)
% ./build/bin/clang-format - -dump-config < /tmp/objc_file.m | grep -e '^Language'
Language:        ObjC
@bhamiltoncx
Copy link
Contributor Author

Work in progress fix (very slowly building and running the tests):

https://github.com/llvm/llvm-project/compare/main...bhamiltoncx:llvm-project:issue-79023?expand=1

bhamiltoncx added a commit that referenced this issue Jan 23, 2024
The code cleanup in #74794 accidentally broke detection of languages by
reading file content from stdin, e.g. via `clang-format -dump-config - <
/path/to/filename`.

This PR adds unit and integration tests to reproduce the issue and adds
a fix.

Fixes: #79023
@owenca owenca removed their assignment Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants