[PATCH] [2/6] Convert non-printing characters to their octal sequence before emitting #line directive or __FILE__ macro

Yunzhong Gao Yunzhong_Gao at playstation.sony.com
Wed Sep 11 13:07:12 PDT 2013


  Hi Eli,
  Thanks for the hint. Looks like you already fixed #line directive in r189557. So what is left to fix is just the __FILE__ macro. I have updated my patch here.
  - Gao.

http://llvm-reviews.chandlerc.com/D1291

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D1291?vs=3212&id=4207#toc

Files:
  lib/Lex/PPMacroExpansion.cpp
  test/Preprocessor/line-directive-output.c

Index: lib/Lex/PPMacroExpansion.cpp
===================================================================
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -1317,8 +1317,9 @@
     SmallString<128> FN;
     if (PLoc.isValid()) {
       FN += PLoc.getFilename();
-      Lexer::Stringify(FN);
-      OS << '"' << FN.str() << '"';
+      OS << '"';
+      OS.write_escaped(FN);
+      OS << '"';
     }
     Tok.setKind(tok::string_literal);
   } else if (II == Ident__DATE__) {
Index: test/Preprocessor/line-directive-output.c
===================================================================
--- test/Preprocessor/line-directive-output.c
+++ test/Preprocessor/line-directive-output.c
@@ -76,3 +76,8 @@
 
 // CHECK: # 50 "a\n.c"
 # 50 "a\012.c"
+
+// CHECK: # 100 "\202\261\202\361\202\311\202\277\202\315.c"
+// CHECK: filename = "\202\261\202\361\202\311\202\277\202\315.c";
+# 100 "\202\261\202\361\202\311\202\277\202\315.c"
+const char *filename = __FILE__;
\ No newline at end of file
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1291.3.patch
Type: text/x-patch
Size: 1007 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130911/5e903348/attachment.bin>


More information about the cfe-commits mailing list