]> granicus.if.org Git - clang/commitdiff
[Driver] Add option to print the resource directory
authorMeador Inge <meadori@codesourcery.com>
Tue, 4 Apr 2017 21:46:50 +0000 (21:46 +0000)
committerMeador Inge <meadori@codesourcery.com>
Tue, 4 Apr 2017 21:46:50 +0000 (21:46 +0000)
This patch adds the option -print-resource-dir. It simply
prints the resource directory. This information will eventually
be used in compiler-rt to setup COMPILER_RT_LIBRARY_INSTALL_DIR.

Patch by Catherine Moore!

Differential Revision: https://reviews.llvm.org/D31447

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299473 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Options.td
lib/Driver/Driver.cpp
test/Driver/immediate-options.c

index 12b7ca21fc6c98d91794150a054933b5e4f64555..da1dd361ede222f1047c7e637bcda8c3b965d90a 100644 (file)
@@ -2091,6 +2091,8 @@ def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
   Flags<[Unsupported]>;
 def print_prog_name_EQ : Joined<["-", "--"], "print-prog-name=">,
   HelpText<"Print the full program path of <name>">, MetaVarName<"<name>">;
+def print_resource_dir : Flag<["-", "--"], "print-resource-dir">,
+  HelpText<"Print the resource directory pathname">;
 def print_search_dirs : Flag<["-", "--"], "print-search-dirs">,
   HelpText<"Print the paths used for finding libraries and programs">;
 def private__bundle : Flag<["-"], "private_bundle">;
index 1633082fb07b640207f8411edbf6e8168f9965a2..adba98a93edd369f9d9d0566a9663768e5e3a25c 100644 (file)
@@ -1169,6 +1169,11 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
   if (C.getArgs().hasArg(options::OPT_v))
     TC.printVerboseInfo(llvm::errs());
 
+  if (C.getArgs().hasArg(options::OPT_print_resource_dir)) {
+    llvm::outs() << ResourceDir;
+    return false;
+  }
+
   if (C.getArgs().hasArg(options::OPT_print_search_dirs)) {
     llvm::outs() << "programs: =";
     bool separator = false;
index f50ccae642175eb1e2151fc371e5816e84492f30..935c948321f55436a99bb0a0604304f8482a0b76 100644 (file)
@@ -12,3 +12,8 @@
 // RUN: %clang -print-search-dirs | FileCheck %s -check-prefix=PRINT-SEARCH-DIRS
 // PRINT-SEARCH-DIRS: programs: ={{.*}}
 // PRINT-SEARCH-DIRS: libraries: ={{.*}}
+
+// Test if the -print-resource-dir option is accepted without error.
+// Allow unspecified output because the value of CLANG_RESOURCE_DIR is unknown.
+// RUN: %clang -print-resource-dir | FileCheck %s -check-prefix=PRINT-RESOURCE-DIR
+// PRINT-RESOURCE-DIR: {{.+}}