diff options
author | Daniel Jasper <djasper@google.com> | 2014-01-17 16:21:39 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-01-17 16:21:39 +0000 |
commit | 47ef6ddece6eee55f3d53e07f484832cece770f9 (patch) | |
tree | 7c5bc6506837f017872b7d85b15a00af81cef352 /clang/lib/Format | |
parent | 5fea974b6ba4992b328d72499d242aaeadd7351e (diff) | |
download | bcm5719-llvm-47ef6ddece6eee55f3d53e07f484832cece770f9.tar.gz bcm5719-llvm-47ef6ddece6eee55f3d53e07f484832cece770f9.zip |
clang-format: Don't break lines starting with "import <string-literal>"
The author might be missing the "#" or these might be protocol buffer
definitions. Either way, we should not break the line or the string.
There don't seem to be other valid use cases.
llvm-svn: 199501
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index b04ccd0ba75..d80e5504949 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -529,6 +529,15 @@ public: parsePreprocessorDirective(); return LT_PreprocessorDirective; } + + // Directly allow to 'import <string-literal>' to support protocol buffer + // definitions (code.google.com/p/protobuf) or missing "#" (either way we + // should not break the line). + IdentifierInfo *Info = CurrentToken->Tok.getIdentifierInfo(); + if (Info && Info->getPPKeywordID() == tok::pp_import && + CurrentToken->Next && CurrentToken->Next->is(tok::string_literal)) + parseIncludeDirective(); + while (CurrentToken != NULL) { if (CurrentToken->is(tok::kw_virtual)) KeywordVirtualFound = true; |