Commit 513b950a authored by Paul Robinson's avatar Paul Robinson
Browse files

Make -frewrite-includes handle -include correctly

The `-include "file"` option implicitly adds a leading #include
to the main source; however, there's no explicit #include, which
left -frewrite-includes emitting an unmatched #endif at the end
of the included text.

This corrects a bug in 4a16b51f.
parent 4c600bd1
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -444,8 +444,11 @@ void InclusionRewriter::Process(FileID FileId,
              if (Mod)
                OS << "#pragma clang module end /*"
                   << Mod->getFullModuleName(true) << "*/\n";
              // There's no #include, therefore no #if, for -include files.
              if (FromFile != PredefinesBuffer) {
                OS << "#endif /* " << getIncludedFileName(Inc)
                   << " expanded by -frewrite-includes */" << LocalEOL;
              }

              // Add line marker to indicate we're returning from an included
              // file.
+0 −1
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@ main_file_line
// CHECK: {{^}}# 1 "<built-in>"{{$}}
// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|\\\\)}}rewrite-includes2.h" 1{{$}}
// CHECK-NEXT: {{^}}int included_line2;{{$}}
// CHECK-NEXT: {{^}}#endif /* rewrite-includes2.h expanded by -frewrite-includes */{{$}}
// CHECK-NEXT: {{^}}# 1 "<built-in>" 2{{$}}
// CHECK-NEXT: {{^}}# 1 "{{.*}}rewrite-includes-cli-include.c"{{$}}
// CHECK-NEXT: FileCheck