clang-format: Fix whitespaces in include directives.
Before (clang-format wouldn't change):
#include "a.h"
#include<a>
After:
#include "a.h"
#include <a>
This fixes llvm.org/PR16151.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193683 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp
index 68b440d..c1f448b 100644
--- a/lib/Format/ContinuationIndenter.cpp
+++ b/lib/Format/ContinuationIndenter.cpp
@@ -202,7 +202,11 @@
unsigned ExtraSpaces) {
const FormatToken &Current = *State.NextToken;
- if (State.Stack.size() == 0 || Current.Type == TT_ImplicitStringLiteral) {
+ if (State.Stack.size() == 0 ||
+ (Current.Type == TT_ImplicitStringLiteral &&
+ (Current.Previous->Tok.getIdentifierInfo() == NULL ||
+ Current.Previous->Tok.getIdentifierInfo()->getPPKeywordID() ==
+ tok::pp_not_keyword))) {
// FIXME: Is this correct?
int WhitespaceLength = SourceMgr.getSpellingColumnNumber(
State.NextToken->WhitespaceRange.getEnd()) -
@@ -700,6 +704,10 @@
if (Current.Type != TT_BlockComment && Current.IsMultiline)
return addMultilineToken(Current, State);
+ // Don't break implicit string literals.
+ if (Current.Type == TT_ImplicitStringLiteral)
+ return 0;
+
if (!Current.isOneOf(tok::string_literal, tok::wide_string_literal,
tok::utf8_string_literal, tok::utf16_string_literal,
tok::utf32_string_literal, tok::comment))