summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/FormatTokenLexer.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2016-12-12 12:42:29 +0000
committerDaniel Jasper <djasper@google.com>2016-12-12 12:42:29 +0000
commit03a04fe95ffbf54ce54957e378c36a520f0b19d3 (patch)
treec31f3b7d87665e954448af4a4c26d53748977200 /clang/lib/Format/FormatTokenLexer.cpp
parentd2396b642514cdfa94de6bafd07f30645910ee73 (diff)
downloadbcm5719-llvm-03a04fe95ffbf54ce54957e378c36a520f0b19d3.tar.gz
bcm5719-llvm-03a04fe95ffbf54ce54957e378c36a520f0b19d3.zip
clang-format: Separate out a language kind for ObjC.
While C(++) and ObjC are generally formatted the same way and can be mixed, people might want to choose different styles based on the language. This patch recognizes .m and .mm files as ObjC and also implements a very crude detection of whether or not a .h file contains ObjC code. This can be improved over time. Also move most of the ObjC tests into their own test file to keep file size maintainable. llvm-svn: 289428
Diffstat (limited to 'clang/lib/Format/FormatTokenLexer.cpp')
-rw-r--r--clang/lib/Format/FormatTokenLexer.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Format/FormatTokenLexer.cpp b/clang/lib/Format/FormatTokenLexer.cpp
index 2aa48e3f491..46a32a917dd 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -558,7 +558,8 @@ FormatToken *FormatTokenLexer::getNextToken() {
Column = FormatTok->LastLineColumnWidth;
}
- if (Style.Language == FormatStyle::LK_Cpp) {
+ if (Style.Language == FormatStyle::LK_Cpp ||
+ Style.Language == FormatStyle::LK_ObjC) {
if (!(Tokens.size() > 0 && Tokens.back()->Tok.getIdentifierInfo() &&
Tokens.back()->Tok.getIdentifierInfo()->getPPKeywordID() ==
tok::pp_define) &&
OpenPOWER on IntegriCloud