[cfe-commits] r90577 - in /cfe/trunk: include/clang/Driver/Options.td lib/Driver/Tools.cpp tools/driver/driver.cpp

Rafael Espindola rafael.espindola at gmail.com
Fri Dec 4 11:31:58 PST 2009


Author: rafael
Date: Fri Dec  4 13:31:58 2009
New Revision: 90577

URL: http://llvm.org/viewvc/llvm-project?rev=90577&view=rev
Log:
Add gcc's -no-canonical-prefixes option to clang.


Modified:
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=90577&r1=90576&r2=90577&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Dec  4 13:31:58 2009
@@ -375,6 +375,8 @@
 def mwarn_nonportable_cfstrings : Flag<"-mwarn-nonportable-cfstrings">, Group<m_Group>;
 def m_Separate : Separate<"-m">, Group<m_Group>;
 def m_Joined : Joined<"-m">, Group<m_Group>;
+def no_canonical_prefixes : Flag<"-no-canonical-prefixes">, Flags<[DriverOption]>,
+  HelpText<"Do not resolve symbolic links, turn relative paths into absolute ones, or do anything else to identify the executable">;
 def no_cpp_precomp : Flag<"-no-cpp-precomp">;
 def no_integrated_cpp : Flag<"-no-integrated-cpp">, Flags<[DriverOption]>;
 def no__dead__strip__inits__and__terms : Flag<"-no_dead_strip_inits_and_terms">;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=90577&r1=90576&r2=90577&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Dec  4 13:31:58 2009
@@ -1104,6 +1104,9 @@
   // care to warn the user about.
   Args.ClaimAllArgs(options::OPT_clang_ignored_f_Group);
   Args.ClaimAllArgs(options::OPT_clang_ignored_m_Group);
+
+  // -no-canonical-prefixes is used very early in main.
+  Args.ClaimAllArgs(options::OPT_no_canonical_prefixes);
 }
 
 void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,

Modified: cfe/trunk/tools/driver/driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=90577&r1=90576&r2=90577&view=diff

==============================================================================
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Fri Dec  4 13:31:58 2009
@@ -60,7 +60,10 @@
   OS << '\n';
 }
 
-llvm::sys::Path GetExecutablePath(const char *Argv0) {
+llvm::sys::Path GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) {
+  if (!CanonicalPrefixes)
+    return llvm::sys::Path(Argv0);
+
   // This just needs to be some symbol in the binary; C++ doesn't
   // allow taking the address of ::main however.
   void *P = (void*) (intptr_t) GetExecutablePath;
@@ -190,7 +193,16 @@
     return cc1_main(argv+2, argv+argc, argv[0],
                     (void*) (intptr_t) GetExecutablePath);
 
-  llvm::sys::Path Path = GetExecutablePath(argv[0]);
+  bool CanonicalPrefixes = true;
+  for (int i = 1; i < argc; ++i) {
+    if (llvm::StringRef(argv[i]) == "-no-canonical-prefixes") {
+      CanonicalPrefixes = false;
+      break;
+    }
+  }
+
+  llvm::sys::Path Path = GetExecutablePath(argv[0], CanonicalPrefixes);
+
   DriverDiagnosticPrinter DiagClient(Path.getBasename(), llvm::errs());
 
   Diagnostic Diags(&DiagClient);
@@ -264,4 +276,3 @@
 
   return Res;
 }
-





More information about the cfe-commits mailing list