This is an archive of the discontinued LLVM Phabricator instance.

[Format] Add option to enable coroutines keywords
AbandonedPublic

Authored by modocache on Jul 20 2019, 5:36 PM.

Details

Summary

In a previous change, https://reviews.llvm.org/D65043, I allowed users to
explicitly opt-in to formatting according to the C++20 standard. Should
a user choose to do so, the formatter would treat coroutine keywords
such as co_yield as keywords, whereas under the C++11 standard they
would be treated as identifiers.

However, this excludes a use case in which, for example, a user's codebase
is written using the C++17 standard, but with an explicit opt-in to
-fcoroutines-ts. This commit adds an option to clang-format to allow
formatting under an arbitrary standard, but with co_yield and friends
treated as keywords.

Event Timeline

modocache created this revision.Jul 20 2019, 5:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2019, 5:36 PM
Herald added a subscriber: EricWF. · View Herald Transcript

Do we have real examples of code that gets formatted incorrectly when parsed as c++20 but lives in a codebase that uses coroutines TS?
This seems very niche (and probably short-lived) - do we really need this option?

modocache abandoned this revision.Sep 13 2019, 8:09 AM

I work on a C++17 codebase with coroutines enabled, but yes
just formatting the codebase as if it were C++20 seems fine. Thanks!