[cfe-commits] r114142 - in /cfe/trunk: lib/Frontend/PrintPreprocessedOutput.cpp test/Preprocessor/print_line_empty_file.c
Ted Kremenek
kremenek at apple.com
Thu Sep 16 17:41:18 PDT 2010
Author: kremenek
Date: Thu Sep 16 19:41:18 2010
New Revision: 114142
URL: http://llvm.org/viewvc/llvm-project?rev=114142&view=rev
Log:
Handle '#line' in '-E' that has an empty file name. Fixes <rdar://problem/8439412>.
Added:
cfe/trunk/test/Preprocessor/print_line_empty_file.c
Modified:
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=114142&r1=114141&r2=114142&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Thu Sep 16 19:41:18 2010
@@ -164,11 +164,11 @@
// 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)
Added: cfe/trunk/test/Preprocessor/print_line_empty_file.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/print_line_empty_file.c?rev=114142&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/print_line_empty_file.c (added)
+++ cfe/trunk/test/Preprocessor/print_line_empty_file.c Thu Sep 16 19:41:18 2010
@@ -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; }
More information about the cfe-commits
mailing list