From f57fa8e1d4cb815ab145f01770565f4e4441ca1b Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 12 Dec 2016 12:42:29 +0000 Subject: 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289428 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/clang-format/ClangFormat.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tools/clang-format/ClangFormat.cpp') diff --git a/tools/clang-format/ClangFormat.cpp b/tools/clang-format/ClangFormat.cpp index c09723928b..6c50daf538 100644 --- a/tools/clang-format/ClangFormat.cpp +++ b/tools/clang-format/ClangFormat.cpp @@ -249,7 +249,8 @@ static bool format(StringRef FileName) { if (fillRanges(Code.get(), Ranges)) return true; StringRef AssumedFileName = (FileName == "-") ? AssumeFileName : FileName; - FormatStyle FormatStyle = getStyle(Style, AssumedFileName, FallbackStyle); + FormatStyle FormatStyle = + getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer()); if (SortIncludes.getNumOccurrences() != 0) FormatStyle.SortIncludes = SortIncludes; unsigned CursorPosition = Cursor; -- cgit v1.2.3