From b2b39c5d455b950c6fffcc902924516fe7f8ec9f Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 18 Jul 2020 21:01:41 -0700 Subject: [PATCH] [Driver] --print-search-dirs: print -B options and COMPILER_PATH --- clang/lib/Driver/Driver.cpp | 7 +++++++ clang/test/Driver/immediate-options.c | 4 ---- clang/test/Driver/print-search-dirs.c | 6 ++++++ 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 clang/test/Driver/print-search-dirs.c diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 7d52882..317098e 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1748,6 +1748,13 @@ bool Driver::HandleImmediateArgs(const Compilation &C) { if (C.getArgs().hasArg(options::OPT_print_search_dirs)) { llvm::outs() << "programs: ="; bool separator = false; + // Print -B and COMPILER_PATH. + for (const std::string &Path : PrefixDirs) { + if (separator) + llvm::outs() << llvm::sys::EnvPathSeparator; + llvm::outs() << Path; + separator = true; + } for (const std::string &Path : TC.getProgramPaths()) { if (separator) llvm::outs() << llvm::sys::EnvPathSeparator; diff --git a/clang/test/Driver/immediate-options.c b/clang/test/Driver/immediate-options.c index 71494ee..d7cd6be 100644 --- a/clang/test/Driver/immediate-options.c +++ b/clang/test/Driver/immediate-options.c @@ -9,10 +9,6 @@ // RUN: %clang -dumpversion | FileCheck %s -check-prefix=DUMPVERSION // DUMPVERSION: {{[0-9]+\.[0-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 diff --git a/clang/test/Driver/print-search-dirs.c b/clang/test/Driver/print-search-dirs.c new file mode 100644 index 0000000..0ac1312 --- /dev/null +++ b/clang/test/Driver/print-search-dirs.c @@ -0,0 +1,6 @@ +// UNSUPPORTED: system-windows + +// RUN: env COMPILER_PATH=cpath1:cpath2 %clang %s -target x86_64-pc-freebsd --sysroot=%S/Inputs/basic_freebsd64_tree \ +// RUN: -B b1 -B b2 -print-search-dirs | FileCheck %s +// CHECK: programs: =b1:b2:cpath1:cpath2:{{.*}} +// CHECK-NEXT: libraries: ={{.*}}Inputs/basic_freebsd64_tree/usr/lib -- 2.7.4