Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -2080,6 +2080,8 @@ 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 full pathname of the resource directory">; 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: lib/Driver/Driver.cpp =================================================================== --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1169,6 +1169,11 @@ if (C.getArgs().hasArg(options::OPT_v)) TC.printVerboseInfo(llvm::errs()); + if (C.getArgs().hasArg(options::OPT_print_resource_dir)) { + llvm::outs() << ResourceDir << "\n"; + return false; + } + if (C.getArgs().hasArg(options::OPT_print_search_dirs)) { llvm::outs() << "programs: ="; bool separator = false; Index: test/Driver/immediate-options.c =================================================================== --- test/Driver/immediate-options.c +++ test/Driver/immediate-options.c @@ -12,3 +12,9 @@ // 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: {{.*}} +