On Friday 11 of April 2014, Eric Christopher wrote:
> There's no guarantee that the option will continue to exist at all so
> I'd really prefer that you not use it. Any time you have to use
> -Xclang to set something then it's not an exposed option that you
> should be using.
>
> That said, if we can come up with a structured set of uses for this
> sort of compilation strategy rather than piecemeal then we should
> discuss it and how it'll fit into the driver.

 So how about this patch?

 As said elsewhere, something like

 cd /output ; clang -c -g -gsplit-dwarf /source/a.cpp

 may need to be turned by a distributed build system into something like

 cd / ; clang -c -x c - -g -gsplit-dwarf -o /tmp/fhqtewdsg.o

 These options allow getting the same .o as with the first command by adding

 -fmain-file-name /source/a.cpp -fdebug-compilation-dir /output 
-fsplit-dwarf-file /output/a.dwo

> >> On Fri, Apr 4, 2014 at 5:02 AM, Lubos Lunak <[email protected]> wrote:
> >> >  The handling of -main-file-name in CGDebugInfo::CreateCompileUnit()
> >> > can result in incorrect DW_AT_name in somewhat special cases:
> >> >
> >> > 1)
> >> > $ touch /tmp/a.cpp
> >> > $
> >> > clang++ -Wall -c /tmp/a.cpp -g -o /tmp/a.o -Xclang -main-file-name
> >> > -Xclang /new/path/a.cpp $ readelf -wi /tmp/a.o | grep DW_AT_name
> >> >     <12>   DW_AT_name        : (indirect string, offset:
> >> > 0x15): /tmp/new/path/a.cpp
> >> >
> >> > 2)
> >> > $ touch /tmp/a.cpp
> >> > $ cd /
> >> > $ cat /tmp/a.cpp | clang++ -Wall -x
> >> > c++ -c - -g -o /tmp/a.o -Xclang -main-file-name -Xclang a.cpp
> >> > $ readelf -wi /tmp/a.o | grep DW_AT_name
> >> >     <12>   DW_AT_name        : (indirect string, offset: 0x15): /a.cpp
> >> >
> >> >  The attached patch fixes those. Ok to commit?

-- 
 Lubos Lunak
From 3344ee849a65b05b3506809bf794e08f4783f575 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= <[email protected]>
Date: Fri, 4 Apr 2014 13:51:49 +0200
Subject: [PATCH] allow -fmain-file-name also in driver

This allows overriding the name in special cases such as getting the input
from stdin. Also, fix:
- if the name passed is an absolute path, do not try to prepend anything
- do not prepend "/" if source comes from stdin and the current dir is /
  (the directory for <stdin> will be originally considered to be "." too,
   but caching in file handling will replace it with equal "/")
---
 include/clang/Driver/CC1AsOptions.td          |  2 +-
 include/clang/Driver/CC1Options.td            |  2 --
 include/clang/Driver/Options.td               |  3 +++
 lib/CodeGen/CGDebugInfo.cpp                   | 25 +++++++++++++------------
 lib/Driver/Driver.cpp                         |  6 +++---
 lib/Driver/Tools.cpp                          | 14 ++++++++++----
 lib/Frontend/CompilerInvocation.cpp           |  2 +-
 test/Driver/debug-main-file.S                 |  2 +-
 test/Driver/debug-main-file.c                 |  6 ++++++
 test/Driver/no-integrated-as-win.c            |  2 +-
 test/Profile/c-captured.c                     |  4 ++--
 test/Profile/c-counter-overflows.c            |  2 +-
 test/Profile/c-general.c                      |  4 ++--
 test/Profile/c-linkage-available_externally.c |  2 +-
 test/Profile/c-linkage.c                      |  2 +-
 test/Profile/c-outdated-data.c                |  2 +-
 test/Profile/c-unprofiled-blocks.c            |  2 +-
 test/Profile/cxx-implicit.cpp                 |  2 +-
 test/Profile/cxx-lambda.cpp                   |  4 ++--
 test/Profile/cxx-linkage.cpp                  |  2 +-
 test/Profile/cxx-templates.cpp                |  4 ++--
 test/Profile/objc-general.m                   |  4 ++--
 tools/driver/cc1as_main.cpp                   |  2 +-
 23 files changed, 57 insertions(+), 43 deletions(-)
 create mode 100644 test/Driver/debug-main-file.c

diff --git a/include/clang/Driver/CC1AsOptions.td b/include/clang/Driver/CC1AsOptions.td
index 3e130d0..687a180 100644
--- a/include/clang/Driver/CC1AsOptions.td
+++ b/include/clang/Driver/CC1AsOptions.td
@@ -37,7 +37,7 @@ def msave_temp_labels : Flag<["-"], "msave-temp-labels">,
   HelpText<"Save temporary labels in the symbol table. "
            "Note this may change .s semantics, it should almost never be used "
            "on compiler generated code!">;
-def main_file_name : Separate<["-"], "main-file-name">,
+def fmain_file_name : Separate<["-"], "fmain-file-name">,
   HelpText<"Main file name to use for debug info">;
 
 //===----------------------------------------------------------------------===//
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index 3f85c00..b1260f8 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -401,8 +401,6 @@ def fblocks_runtime_optional : Flag<["-"], "fblocks-runtime-optional">,
   HelpText<"Weakly link in the blocks runtime">;
 def fsjlj_exceptions : Flag<["-"], "fsjlj-exceptions">,
   HelpText<"Use SjLj style exceptions">;
-def main_file_name : Separate<["-"], "main-file-name">,
-  HelpText<"Main file name to use for debug info">;
 def fno_wchar : Flag<["-"], "fno-wchar">,
   HelpText<"Disable C++ builtin type wchar_t">;
 def fconstant_string_class : Separate<["-"], "fconstant-string-class">,
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index 1477f3d..edec272 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -916,6 +916,9 @@ def fsplit_dwarf_file : Separate<["-"], "fsplit-dwarf-file">, Group<f_Group>,
 def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">, Group<f_Group>,
   Flags<[CC1Option]>,
   HelpText<"The compilation directory to embed in the debug info.">;
+def fmain_file_name : Separate<["-"], "fmain-file-name">, Group<f_Group>,
+  Flags<[CC1Option]>,
+  HelpText<"Main file name to use for debug info">;
 def g_Flag : Flag<["-"], "g">, Group<g_Group>,
   HelpText<"Generate source level debug information">, Flags<[CC1Option]>;
 def gline_tables_only : Flag<["-"], "gline-tables-only">, Group<g_Group>,
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index f41fac8..87fdb5f 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -322,18 +322,19 @@ void CGDebugInfo::CreateCompileUnit() {
   std::string MainFileName = CGM.getCodeGenOpts().MainFileName;
   if (MainFileName.empty())
     MainFileName = "<unknown>";
-
-  // The main file name provided via the "-main-file-name" option contains just
-  // the file name itself with no path information. This file name may have had
-  // a relative path, so we look into the actual file entry for the main
-  // file to determine the real absolute path for the file.
-  std::string MainFileDir;
-  if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
-    MainFileDir = MainFile->getDir()->getName();
-    if (MainFileDir != ".") {
-      llvm::SmallString<1024> MainFileDirSS(MainFileDir);
-      llvm::sys::path::append(MainFileDirSS, MainFileName);
-      MainFileName = MainFileDirSS.str();
+  else if (!llvm::sys::path::is_absolute(MainFileName)) {
+    // The main file name provided via the "-fmain-file-name" option contains just
+    // the file name itself with no path information. This file name may have had
+    // a relative path, so we look into the actual file entry for the main
+    // file to determine the real absolute path for the file.
+    std::string MainFileDir;
+    if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
+      MainFileDir = MainFile->getDir()->getName();
+      if (MainFileDir != "." && MainFile->getName() != StringRef("<stdin>")) {
+        llvm::SmallString<1024> MainFileDirSS(MainFileDir);
+        llvm::sys::path::append(MainFileDirSS, MainFileName);
+        MainFileName = MainFileDirSS.str();
+      }
     }
   }
 
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index a238e37..6e6d13a 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -531,11 +531,11 @@ void Driver::generateCompilationDiagnostics(Compilation &C,
       } else {
         // Append the new filename with correct preprocessed suffix.
         size_t I, E;
-        I = Cmd.find("-main-file-name ");
-        assert (I != std::string::npos && "Expected to find -main-file-name");
+        I = Cmd.find("-fmain-file-name ");
+        assert (I != std::string::npos && "Expected to find -fmain-file-name");
         I += 16;
         E = Cmd.find(" ", I);
-        assert (E != std::string::npos && "-main-file-name missing argument?");
+        assert (E != std::string::npos && "-fmain-file-name missing argument?");
         StringRef OldFilename = StringRef(Cmd).slice(I, E);
         StringRef NewFilename = llvm::sys::path::filename(*it);
         I = StringRef(Cmd).rfind(OldFilename);
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 2267d15..0d46e2f 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -2303,8 +2303,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
 
   // Set the main file name, so that debug info works even with
   // -save-temps.
-  CmdArgs.push_back("-main-file-name");
-  CmdArgs.push_back(getBaseInputName(Args, Inputs));
+  CmdArgs.push_back("-fmain-file-name");
+  if (Arg *A = Args.getLastArg(options::OPT_fmain_file_name))
+    CmdArgs.push_back(Args.MakeArgString(A->getValue()));
+  else
+    CmdArgs.push_back(getBaseInputName(Args, Inputs));
 
   // Some flags which affect the language (via preprocessor
   // defines).
@@ -4349,8 +4352,11 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
 
   // Set the main file name, so that debug info works even with
   // -save-temps or preprocessed assembly.
-  CmdArgs.push_back("-main-file-name");
-  CmdArgs.push_back(Clang::getBaseInputName(Args, Inputs));
+  CmdArgs.push_back("-fmain-file-name");
+  if (Arg *A = Args.getLastArg(options::OPT_fmain_file_name))
+    CmdArgs.push_back(Args.MakeArgString(A->getValue()));
+  else
+    CmdArgs.push_back(Clang::getBaseInputName(Args, Inputs));
 
   // Add the target cpu
   const llvm::Triple &Triple = getToolChain().getTriple();
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 3fb2eb6..7d98cfa 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -419,7 +419,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
   Opts.VectorizeLoop = Args.hasArg(OPT_vectorize_loops);
   Opts.VectorizeSLP = Args.hasArg(OPT_vectorize_slp);
 
-  Opts.MainFileName = Args.getLastArgValue(OPT_main_file_name);
+  Opts.MainFileName = Args.getLastArgValue(OPT_fmain_file_name);
   Opts.VerifyModule = !Args.hasArg(OPT_disable_llvm_verifier);
   Opts.SanitizeRecover = !Args.hasArg(OPT_fno_sanitize_recover);
 
diff --git a/test/Driver/debug-main-file.S b/test/Driver/debug-main-file.S
index 9127df0..cb298fb 100644
--- a/test/Driver/debug-main-file.S
+++ b/test/Driver/debug-main-file.S
@@ -1,7 +1,7 @@
 // RUN: %clang -### -c -save-temps -integrated-as -g %s 2>&1 \
 // RUN:   | FileCheck %s
 
-// CHECK: main-file-name
+// CHECK: fmain-file-name
 
 #ifdef(1)
 foo:
diff --git a/test/Driver/debug-main-file.c b/test/Driver/debug-main-file.c
new file mode 100644
index 0000000..daaa9fd
--- /dev/null
+++ b/test/Driver/debug-main-file.c
@@ -0,0 +1,6 @@
+// RUN: %clang -### -c -g %s 2>&1 | FileCheck -check-prefix=CHECK-NORMAL %s
+// RUN: %clang -### -c -g %s -fmain-file-name /tmp/file.c 2>&1 | FileCheck -check-prefix=CHECK-OPTION %s
+
+// CHECK-NORMAL: "-fmain-file-name" "debug-main-file.c"
+// CHECK-OPTION: "-fmain-file-name" "/tmp/file.c"
+// CHECK-OPTION-NOT: "-fmain-file-name" "debug-main-file.c"
diff --git a/test/Driver/no-integrated-as-win.c b/test/Driver/no-integrated-as-win.c
index 8f590a0..4b55d9c 100644
--- a/test/Driver/no-integrated-as-win.c
+++ b/test/Driver/no-integrated-as-win.c
@@ -5,7 +5,7 @@
 // the compile step.
 // RUN: %clang -target i686-pc-mingw32 -### -no-integrated-as %s -c 2>&1 | FileCheck -check-prefix=MINGW %s
 // MINGW: "-cc1"
-// MINGW: "-main-file-name" "no-integrated-as-win.c"
+// MINGW: "-fmain-file-name" "no-integrated-as-win.c"
 // MINGW: "-x" "c" "{{.*}}no-integrated-as-win.c"
 // The assembler goes here, but its name depends on PATH.
 // MINGW-NOT: no-integrated-as-win.c
diff --git a/test/Profile/c-captured.c b/test/Profile/c-captured.c
index 47b1bbc..071fea3 100644
--- a/test/Profile/c-captured.c
+++ b/test/Profile/c-captured.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-captured.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck -check-prefix=PGOGEN -check-prefix=PGOALL %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -fmain-file-name c-captured.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck -check-prefix=PGOGEN -check-prefix=PGOALL %s
 
 // RUN: llvm-profdata merge %S/Inputs/c-captured.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-captured.c %s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE -check-prefix=PGOALL %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -fmain-file-name c-captured.c %s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE -check-prefix=PGOALL %s
 
 // PGOGEN: @[[DCC:__llvm_profile_counters_debug_captured]] = global [3 x i64] zeroinitializer
 // PGOGEN: @[[CSC:__llvm_profile_counters___captured_stmt]] = internal global [2 x i64] zeroinitializer
diff --git a/test/Profile/c-counter-overflows.c b/test/Profile/c-counter-overflows.c
index f6f8f73..8be6132 100644
--- a/test/Profile/c-counter-overflows.c
+++ b/test/Profile/c-counter-overflows.c
@@ -2,7 +2,7 @@
 // truncated.
 
 // RUN: llvm-profdata merge %S/Inputs/c-counter-overflows.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-counter-overflows.c %s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -fmain-file-name c-counter-overflows.c %s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck %s
 
 typedef unsigned long long uint64_t;
 
diff --git a/test/Profile/c-general.c b/test/Profile/c-general.c
index 21ba005..d8e7a75 100644
--- a/test/Profile/c-general.c
+++ b/test/Profile/c-general.c
@@ -1,9 +1,9 @@
 // Test instrumentation of general constructs in C.
 
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck -check-prefix=PGOGEN %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -fmain-file-name c-general.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck -check-prefix=PGOGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/c-general.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -fmain-file-name c-general.c %s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s
 
 // PGOGEN: @[[SLC:__llvm_profile_counters_simple_loops]] = global [4 x i64] zeroinitializer
 // PGOGEN: @[[IFC:__llvm_profile_counters_conditionals]] = global [11 x i64] zeroinitializer
diff --git a/test/Profile/c-linkage-available_externally.c b/test/Profile/c-linkage-available_externally.c
index adc1e6e..2cac5d2 100644
--- a/test/Profile/c-linkage-available_externally.c
+++ b/test/Profile/c-linkage-available_externally.c
@@ -1,6 +1,6 @@
 // Make sure instrementation data from available_externally functions doesn't
 // get thrown out.
-// RUN: %clang_cc1 -O2 -triple x86_64-apple-macosx10.9 -main-file-name c-linkage-available_externally.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck %s
+// RUN: %clang_cc1 -O2 -triple x86_64-apple-macosx10.9 -fmain-file-name c-linkage-available_externally.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck %s
 
 // CHECK: @__llvm_profile_counters_foo = linkonce_odr global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
 // CHECK: @__llvm_profile_name_foo = linkonce_odr constant [3 x i8] c"foo", section "__DATA,__llvm_prf_names", align 1
diff --git a/test/Profile/c-linkage.c b/test/Profile/c-linkage.c
index 482e8da..70df574 100644
--- a/test/Profile/c-linkage.c
+++ b/test/Profile/c-linkage.c
@@ -1,5 +1,5 @@
 // Check the data structures emitted by instrumentation.
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-linkage.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -fmain-file-name c-linkage.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck %s
 
 // CHECK: @__llvm_profile_runtime = external global i32
 // CHECK: @__llvm_profile_counters_foo = global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
diff --git a/test/Profile/c-outdated-data.c b/test/Profile/c-outdated-data.c
index d0503ac..642258f 100644
--- a/test/Profile/c-outdated-data.c
+++ b/test/Profile/c-outdated-data.c
@@ -4,7 +4,7 @@
 // doesn't play well with warnings that have no line number.
 
 // RUN: llvm-profdata merge %S/Inputs/c-outdated-data.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -fprofile-instr-use=%t.profdata -Wprofile-instr-dropped 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -fmain-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -fprofile-instr-use=%t.profdata -Wprofile-instr-dropped 2>&1 | FileCheck %s
 // CHECK: warning: profile data may be out of date: of 3 functions, 1 has no data and 1 has mismatched data that will be ignored
 
 void no_usable_data() {
diff --git a/test/Profile/c-unprofiled-blocks.c b/test/Profile/c-unprofiled-blocks.c
index 58bef9e..6e4ca5e 100644
--- a/test/Profile/c-unprofiled-blocks.c
+++ b/test/Profile/c-unprofiled-blocks.c
@@ -2,7 +2,7 @@
 // runs) shouldn't have any branch weight metadata added.
 
 // RUN: llvm-profdata merge %S/Inputs/c-unprofiled-blocks.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-unprofiled-blocks.c %s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -fmain-file-name c-unprofiled-blocks.c %s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s
 
 // PGOUSE-LABEL: @never_called(i32 %i)
 int never_called(int i) {
diff --git a/test/Profile/cxx-implicit.cpp b/test/Profile/cxx-implicit.cpp
index 79840ad..be14447 100644
--- a/test/Profile/cxx-implicit.cpp
+++ b/test/Profile/cxx-implicit.cpp
@@ -1,6 +1,6 @@
 // Ensure that implicit methods aren't instrumented.
 
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-implicit.cpp -o - -emit-llvm -fprofile-instr-generate | FileCheck %s
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -fmain-file-name cxx-implicit.cpp -o - -emit-llvm -fprofile-instr-generate | FileCheck %s
 
 // An implicit constructor is generated for Base. We should not emit counters
 // for it.
diff --git a/test/Profile/cxx-lambda.cpp b/test/Profile/cxx-lambda.cpp
index 923a432..11a5e18 100644
--- a/test/Profile/cxx-lambda.cpp
+++ b/test/Profile/cxx-lambda.cpp
@@ -1,11 +1,11 @@
 // Tests for instrumentation of C++11 lambdas
 
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-generate > %tgen
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -fmain-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-generate > %tgen
 // RUN: FileCheck --input-file=%tgen -check-prefix=PGOGEN %s
 // RUN: FileCheck --input-file=%tgen -check-prefix=LMBGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-lambda.proftext -o %t.profdata
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -fmain-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse
 // RUN: FileCheck --input-file=%tuse -check-prefix=PGOUSE %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=LMBUSE %s
 
diff --git a/test/Profile/cxx-linkage.cpp b/test/Profile/cxx-linkage.cpp
index 92dfed9..452c485 100644
--- a/test/Profile/cxx-linkage.cpp
+++ b/test/Profile/cxx-linkage.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9.0 -emit-llvm -main-file-name cxx-linkage.cpp %s -o - -fprofile-instr-generate | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9.0 -emit-llvm -fmain-file-name cxx-linkage.cpp %s -o - -fprofile-instr-generate | FileCheck %s
 
 // CHECK: @__llvm_profile_runtime = external global i32
 // CHECK: @__llvm_profile_counters__Z3foov = global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
diff --git a/test/Profile/cxx-templates.cpp b/test/Profile/cxx-templates.cpp
index 5f99b99..b888182 100644
--- a/test/Profile/cxx-templates.cpp
+++ b/test/Profile/cxx-templates.cpp
@@ -1,12 +1,12 @@
 // Tests for instrumentation of templated code. Each instantiation of a template
 // should be instrumented separately.
 
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-generate > %tgen
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -fmain-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-generate > %tgen
 // RUN: FileCheck --input-file=%tgen -check-prefix=T0GEN -check-prefix=ALL %s
 // RUN: FileCheck --input-file=%tgen -check-prefix=T100GEN -check-prefix=ALL %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-templates.proftext -o %t.profdata
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -fmain-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse
 // RUN: FileCheck --input-file=%tuse -check-prefix=T0USE -check-prefix=ALL %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=T100USE -check-prefix=ALL %s
 
diff --git a/test/Profile/objc-general.m b/test/Profile/objc-general.m
index dc74618..93c5030 100644
--- a/test/Profile/objc-general.m
+++ b/test/Profile/objc-general.m
@@ -1,9 +1,9 @@
 // Test instrumentation of general constructs in objective C.
 
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instr-generate | FileCheck -check-prefix=PGOGEN %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -fmain-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instr-generate | FileCheck -check-prefix=PGOGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/objc-general.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -fmain-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s
 
 #ifdef HAVE_FOUNDATION
 
diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp
index 68efc19..8dee97a 100644
--- a/tools/driver/cc1as_main.cpp
+++ b/tools/driver/cc1as_main.cpp
@@ -192,7 +192,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
   Opts.DwarfDebugFlags = Args->getLastArgValue(OPT_dwarf_debug_flags);
   Opts.DwarfDebugProducer = Args->getLastArgValue(OPT_dwarf_debug_producer);
   Opts.DebugCompilationDir = Args->getLastArgValue(OPT_fdebug_compilation_dir);
-  Opts.MainFileName = Args->getLastArgValue(OPT_main_file_name);
+  Opts.MainFileName = Args->getLastArgValue(OPT_fmain_file_name);
 
   // Frontend Options
   if (Args->hasArg(OPT_INPUT)) {
-- 
1.8.4.5

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to