File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -497,7 +497,6 @@ class AnnotatingParser {
497
497
}
498
498
499
499
void parseIncludeDirective () {
500
- next ();
501
500
if (CurrentToken && CurrentToken->is (tok::less)) {
502
501
next ();
503
502
while (CurrentToken) {
@@ -554,6 +553,7 @@ class AnnotatingParser {
554
553
switch (CurrentToken->Tok .getIdentifierInfo ()->getPPKeywordID ()) {
555
554
case tok::pp_include:
556
555
case tok::pp_import:
556
+ next ();
557
557
parseIncludeDirective ();
558
558
break ;
559
559
case tok::pp_error:
@@ -587,8 +587,18 @@ class AnnotatingParser {
587
587
// should not break the line).
588
588
IdentifierInfo *Info = CurrentToken->Tok .getIdentifierInfo ();
589
589
if (Info && Info->getPPKeywordID () == tok::pp_import &&
590
- CurrentToken->Next && CurrentToken->Next ->is (tok::string_literal))
590
+ CurrentToken->Next && CurrentToken->Next ->is (tok::string_literal)) {
591
+ next ();
591
592
parseIncludeDirective ();
593
+ return LT_Other;
594
+ }
595
+
596
+ // If this line starts and ends in '<' and '>', respectively, it is likely
597
+ // part of "#define <a/b.h>".
598
+ if (CurrentToken->is (tok::less) && Line.Last ->is (tok::greater)) {
599
+ parseIncludeDirective ();
600
+ return LT_Other;
601
+ }
592
602
593
603
while (CurrentToken) {
594
604
if (CurrentToken->is (tok::kw_virtual))
Original file line number Diff line number Diff line change @@ -5234,6 +5234,8 @@ TEST_F(FormatTest, HandlesIncludeDirectives) {
5234
5234
" #include <strstream>\n "
5235
5235
" #endif" );
5236
5236
5237
+ verifyFormat (" #define MY_IMPORT <a/b>" );
5238
+
5237
5239
// Protocol buffer definition or missing "#".
5238
5240
verifyFormat (" import \" aaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaa\" ;" ,
5239
5241
getLLVMStyleWithColumns (30 ));
You can’t perform that action at this time.
0 commit comments