This is an archive of the discontinued LLVM Phabricator instance.

clang-format: Add option to disable fallback
Needs ReviewPublic

Authored by ono on May 22 2014, 7:17 AM.

Details

Reviewers
djasper
Summary

From command perspective -no-fallback may be used to indicate that file shall
be not re-formatted if no valid style specified by -style was found.

From API perspective added in,out Fallback parameter indicating if fallback is
desired and if it was used when resolving style.

Diff Detail

Event Timeline

ono updated this revision to Diff 9696.May 22 2014, 7:17 AM
ono retitled this revision from to clang-format: Add option to disable fallback.
ono updated this object.
ono edited the test plan for this revision. (Show Details)
ono added a reviewer: djasper.
ono added a subscriber: ono.
djasper added inline comments.May 22 2014, 7:23 AM
include/clang/Format/Format.h
494

I still disagree. Use two parameters instead (or return an std::pair<FormatStyle, bool>).

Or maybe even better. Add a style option (DontFormat) and return a format style that sets it to true. That way, one can even explicitly set that in the .clang-format file meant to disable formatting (only having an empty file implicitly disable formatting seems a bit counter-intuitive and potentially hard to document/discover).

lib/Format/Format.cpp
1989

This should be upper case according to LLVM naming conventions.

tools/clang-format/ClangFormat.cpp
74

In case you go with the DontFormat suggestion above, do you even need this flag then?

djasper added a subscriber: Unknown Object (MLST).May 22 2014, 7:24 AM