diff options
| author | Daniel Jasper <djasper@google.com> | 2013-10-30 13:54:53 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-10-30 13:54:53 +0000 |
| commit | 9885784d67d7154eb5861130cc2b4b29e4cbf9ea (patch) | |
| tree | 02529507b6211460e06f3e4adad5c26b2c49cd24 /clang/lib/Format | |
| parent | 53fe6c4d564cd3522b167dd23048648c1e7e50f9 (diff) | |
| download | bcm5719-llvm-9885784d67d7154eb5861130cc2b4b29e4cbf9ea.tar.gz bcm5719-llvm-9885784d67d7154eb5861130cc2b4b29e4cbf9ea.zip | |
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.
llvm-svn: 193683
Diffstat (limited to 'clang/lib/Format')
| -rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 68b440dbe3f..c1f448be56b 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -202,7 +202,11 @@ unsigned ContinuationIndenter::addTokenToState(LineState &State, bool Newline, 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 @@ unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current, 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)) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 799e4c11a5c..ac45859a5ae 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1450,7 +1450,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, Left.Previous->Type == TT_CastRParen)) return false; } - + if (Right.Type == TT_ImplicitStringLiteral) + return false; if (Right.isTrailingComment()) // We rely on MustBreakBefore being set correctly here as we should not // change the "binding" behavior of a comment. |

