mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-02 10:16:06 +00:00
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
This commit is contained in:
parent
5fea974b6b
commit
47ef6ddece
@ -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;
|
||||
|
@ -4657,6 +4657,10 @@ TEST_F(FormatTest, HandlesIncludeDirectives) {
|
||||
verifyFormat("#if __has_include(<strstream>)\n"
|
||||
"#include <strstream>\n"
|
||||
"#endif");
|
||||
|
||||
// Protocol buffer definition or missing "#".
|
||||
verifyFormat("import \"aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaa\";",
|
||||
getLLVMStyleWithColumns(30));
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
Loading…
x
Reference in New Issue
Block a user