diff options
-rw-r--r-- | lib/Frontend/PrintPreprocessedOutput.cpp | 4 | ||||
-rw-r--r-- | test/Preprocessor/print_line_empty_file.c | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp index d0aef2918c..00ab3c3176 100644 --- a/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/lib/Frontend/PrintPreprocessedOutput.cpp @@ -164,11 +164,11 @@ void PrintPPOutputPPCallbacks::WriteLineInfo(unsigned LineNo, // Emit #line directives or GNU line markers depending on what mode we're in. if (UseLineDirective) { OS << "#line" << ' ' << LineNo << ' ' << '"'; - OS.write(&CurFilename[0], CurFilename.size()); + OS.write(CurFilename.data(), CurFilename.size()); OS << '"'; } else { OS << '#' << ' ' << LineNo << ' ' << '"'; - OS.write(&CurFilename[0], CurFilename.size()); + OS.write(CurFilename.data(), CurFilename.size()); OS << '"'; if (ExtraLen) diff --git a/test/Preprocessor/print_line_empty_file.c b/test/Preprocessor/print_line_empty_file.c new file mode 100644 index 0000000000..333896ee43 --- /dev/null +++ b/test/Preprocessor/print_line_empty_file.c @@ -0,0 +1,12 @@ +// RUN: %clang -E %s | FileCheck %s + +#line 21 "" +int foo() { return 42; } + +#line 4 "bug.c" +int bar() { return 21; } + +// CHECK: # 21 "" +// CHECK: int foo() { return 42; } +// CHECK: # 4 "bug.c" +// CHECK: int bar() { return 21; } |