diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-06-21 14:00:56 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-06-21 14:00:56 +0000 |
commit | 2e645aa5697838f16ec570eb07c2bee7e13d0e0b (patch) | |
tree | a764184c2fc9486979b074250b013a0937ee64e5 /lib/Format/Format.cpp | |
parent | 798321d8eb5630cd4a8f490a4f25e32ef195fb07 (diff) | |
download | src-test2-2e645aa5697838f16ec570eb07c2bee7e13d0e0b.tar.gz src-test2-2e645aa5697838f16ec570eb07c2bee7e13d0e0b.zip |
Notes
Diffstat (limited to 'lib/Format/Format.cpp')
-rw-r--r-- | lib/Format/Format.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index c725b4bf30ab..0feeaa007f3e 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -174,7 +174,8 @@ template <> struct MappingTraits<FormatStyle> { IO.mapOptional("AlignEscapedNewlinesLeft", Style.AlignEscapedNewlinesLeft); IO.mapOptional("AlignOperands", Style.AlignOperands); IO.mapOptional("AlignTrailingComments", Style.AlignTrailingComments); - IO.mapOptional("AlignConsecutiveAssignments", Style.AlignConsecutiveAssignments); + IO.mapOptional("AlignConsecutiveAssignments", + Style.AlignConsecutiveAssignments); IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine", Style.AllowAllParametersOfDeclarationOnNextLine); IO.mapOptional("AllowShortBlocksOnASingleLine", @@ -785,7 +786,8 @@ private: // Backticks get lexed as tok::unknown tokens. If a template string contains // a comment start, it gets lexed as a tok::comment, or tok::unknown if // unterminated. - if (!EndBacktick->isOneOf(tok::comment, tok::unknown)) + if (!EndBacktick->isOneOf(tok::comment, tok::string_literal, + tok::char_constant, tok::unknown)) return false; size_t CommentBacktickPos = EndBacktick->TokenText.find('`'); // Unknown token that's not actually a backtick, or a comment that doesn't @@ -1122,7 +1124,10 @@ private: Column = FormatTok->LastLineColumnWidth; } - if (std::find(ForEachMacros.begin(), ForEachMacros.end(), + if (!(Tokens.size() > 0 && Tokens.back()->Tok.getIdentifierInfo() && + Tokens.back()->Tok.getIdentifierInfo()->getPPKeywordID() == + tok::pp_define) && + std::find(ForEachMacros.begin(), ForEachMacros.end(), FormatTok->Tok.getIdentifierInfo()) != ForEachMacros.end()) FormatTok->Type = TT_ForEachMacro; @@ -1254,7 +1259,8 @@ public: } tooling::Replacements format(SmallVectorImpl<AnnotatedLine *> &AnnotatedLines, - FormatTokenLexer &Tokens, bool *IncompleteFormat) { + FormatTokenLexer &Tokens, + bool *IncompleteFormat) { TokenAnnotator Annotator(Style, Tokens.getKeywords()); for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) { Annotator.annotate(*AnnotatedLines[i]); @@ -1500,8 +1506,7 @@ tooling::Replacements reformat(const FormatStyle &Style, tooling::Replacements reformat(const FormatStyle &Style, StringRef Code, ArrayRef<tooling::Range> Ranges, - StringRef FileName, - bool *IncompleteFormat) { + StringRef FileName, bool *IncompleteFormat) { if (Style.DisableFormat) return tooling::Replacements(); |