[clang-format] New API guessLanguage()
authorBen Hamilton <benhamilton@google.com>
Wed, 21 Feb 2018 15:54:31 +0000 (15:54 +0000)
committerBen Hamilton <benhamilton@google.com>
Wed, 21 Feb 2018 15:54:31 +0000 (15:54 +0000)
commit3b345c3677b361433caf292de01b31cfc0835ba1
treefec3849a6d67189c843e86865654c5aeff15d68a
parentf3a9ab07aa0e1a12bb523d795d18ca4dac2c438b
[clang-format] New API guessLanguage()

Summary:
For clients which don't have a filesystem, calling getStyle() doesn't
make much sense (there's no .clang-format files to search for).

In this diff, I hoist out the language-guessing logic from getStyle()
and move it into a new API guessLanguage().

I also added support for guessing the language of files which have no
extension (they could be C++ or ObjC).

Test Plan: New tests added. Ran tests with:
  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: jolesiak, krasimir

Reviewed By: jolesiak, krasimir

Subscribers: klimek, cfe-commits, sammccall

Differential Revision: https://reviews.llvm.org/D43522

llvm-svn: 325691
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp