Objective-C modern translator. Don't put line info
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 18 Mar 2013 19:41:18 +0000 (19:41 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 18 Mar 2013 19:41:18 +0000 (19:41 +0000)
into the pre-preprocessed file to be passed to
modern translator when compiling in no debug mode.
// rdar://13138170

llvm-svn: 177311

clang/lib/Driver/Tools.cpp
clang/test/Rewriter/rewrite-line-directive.m [new file with mode: 0644]

index 97aa315..4db492a 100644 (file)
@@ -1777,8 +1777,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   } else if (isa<PreprocessJobAction>(JA)) {
     if (Output.getType() == types::TY_Dependencies)
       CmdArgs.push_back("-Eonly");
-    else
+    else {
       CmdArgs.push_back("-E");
+      if (Args.hasArg(options::OPT_rewrite_objc) &&
+          !Args.hasArg(options::OPT_g_Group))
+        CmdArgs.push_back("-P");
+    }
   } else if (isa<AssembleJobAction>(JA)) {
     CmdArgs.push_back("-emit-obj");
 
diff --git a/clang/test/Rewriter/rewrite-line-directive.m b/clang/test/Rewriter/rewrite-line-directive.m
new file mode 100644 (file)
index 0000000..5c4e957
--- /dev/null
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang -fms-extensions -rewrite-objc %t.mm -o %t-rw.cpp
+// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
+// RUN: %clang -g -fms-extensions -rewrite-objc %t.mm -o %t-rw.cpp
+// RUN: FileCheck -check-prefix LPG --input-file=%t-rw.cpp %s
+// rdar://13138170
+
+int z();
+
+int x() {
+    id foo;
+    for (id y in foo) {
+        z();
+    }
+    return 0;
+}
+// CHECK-LP-NOT: #line
+// CHECK-LPG: #line