This is an archive of the discontinued LLVM Phabricator instance.

Add arbitrary file/path support to clang-format style file selection
Needs ReviewPublic

Authored by dciliske on Jun 15 2017, 3:11 PM.

Details

Summary

The Format library has no way to specify a specific file to be used as the style source. It climbs the path looking for ‘.clang_format’. This patch adds the ability to specify a specific file to use for clang Format utilities.

This patch is in direct response to https://bugs.llvm.org//show_bug.cgi?id=28107 (along with my own personal need).

New style argument feature:

Use -style=file,<filename> to load style
configuration from an explicitly defined file.

Diff Detail

Event Timeline

dciliske created this revision.Jun 15 2017, 3:11 PM
ioeric edited edge metadata.Jun 16 2017, 1:26 AM

Hi Dan, thanks for the patch! D33560, which adds the same feature, is already under review :)

So... how should I get something added? That patch has been sitting for a couple weeks.

Should I work on that patch? If so, how do I work on it? This is the first time I'm working on a large OSS project.

alexfh edited reviewers, added: krasimir; removed: alexfh.Mar 14 2018, 7:46 AM

I recently hit this issue where I was clang-formatting generated code out of a source tree, which was then copied into a source tree. This failed my post build clang-format validation check and I couldn't understand why. it was only later I realised that unless I have the same .clang-format file locally when I clang-format the generated files or if I only clang-format them after I've copied them in will this work.

A patch like this (and this isn't the only one I've seen like this that lets me point clang-format to a specifc .clang-format file would have helped here.) are you interested in this patch or something like this still? (I realize its a long time since you got a response)

I think we can abandon this revision now we support --style=file:<filename>