[PATCH] D80079: [clang-format] [NFC] isCpp() is inconsistently used to mean both C++ and Objective C, add language specific isXXX() functions

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun May 17 05:19:10 PDT 2020


MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: krasimir, JakeMerdichAMD, mitchell-stellar, klimek, owenpan, sammccall, curdeius.
MyDeveloperDay added projects: clang, clang-format.
MyDeveloperDay updated this revision to Diff 264485.
MyDeveloperDay added a comment.

Missed some cases


This revision puts the `Style.Lanauge==LK_????` behind convenience functions to begin to avoid potential issues regarding the use of `Style.isCpp()`

It's unclear in a number of places what people really mean when using isCpp() as such I have introduced a `isCppOnly()` to help identify those places where people where not checking both languages

Ideally I'd make `isCpp()` mean only C/C++ and use `isCpp() || isObjectiveC()` but so many of those places overlap I can see why we'd have one function, but perhaps a better name for `isCpp()` is `isCStyleLanguages()` then let `isCppOnly()` be renamed to `isCpp()` but I'm not comfortable doing that in one go.

Regardless I feel introducing `isObjectiveC(),isJava(),JavaScript(),isProtoBuf(),isTextProtoBuf and isTableGen()` helps the code read a little better


https://reviews.llvm.org/D80079

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/BreakableToken.cpp
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80079.264485.patch
Type: text/x-patch
Size: 72225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200517/af88c20a/attachment-0001.bin>


More information about the cfe-commits mailing list