From cb51cf409b45ddaa1bd16b1d88185b918c02bbdd Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 16 Jan 2014 09:11:55 +0000 Subject: clang-format: Enable formatting of lambdas with explicit return type. So clang-format can now format: int c = []()->int { return 2; }(); int c = []()->vector { return { 2 }; }(); llvm-svn: 199368 --- clang/lib/Format/FormatToken.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'clang/lib/Format/FormatToken.cpp') diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp index 0816668b578..c147dbb6b1b 100644 --- a/clang/lib/Format/FormatToken.cpp +++ b/clang/lib/Format/FormatToken.cpp @@ -22,6 +22,36 @@ namespace clang { namespace format { +// FIXME: This is copy&pasted from Sema. Put it in a common place and remove +// duplication. +bool FormatToken::isSimpleTypeSpecifier() const { + switch (Tok.getKind()) { + case tok::kw_short: + case tok::kw_long: + case tok::kw___int64: + case tok::kw___int128: + case tok::kw_signed: + case tok::kw_unsigned: + case tok::kw_void: + case tok::kw_char: + case tok::kw_int: + case tok::kw_half: + case tok::kw_float: + case tok::kw_double: + case tok::kw_wchar_t: + case tok::kw_bool: + case tok::kw___underlying_type: + case tok::annot_typename: + case tok::kw_char16_t: + case tok::kw_char32_t: + case tok::kw_typeof: + case tok::kw_decltype: + return true; + default: + return false; + } +} + TokenRole::~TokenRole() {} void TokenRole::precomputeFormattingInfos(const FormatToken *Token) {} -- cgit v1.2.3