From: Meador Inge Date: Tue, 4 Apr 2017 21:46:50 +0000 (+0000) Subject: [Driver] Add option to print the resource directory X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9ec7bba8d029b29ed4387a0d59a92382aa2ade70;p=clang [Driver] Add option to print the resource directory 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 --- diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 12b7ca21fc..da1dd361ed 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -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 ">, MetaVarName<"">; +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">; diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 1633082fb0..adba98a93e 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -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; diff --git a/test/Driver/immediate-options.c b/test/Driver/immediate-options.c index f50ccae642..935c948321 100644 --- a/test/Driver/immediate-options.c +++ b/test/Driver/immediate-options.c @@ -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: {{.+}}