[clang] b2b39c5 - [Driver] --print-search-dirs: print -B options and COMPILER_PATH
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 18 21:02:30 PDT 2020
Author: Fangrui Song
Date: 2020-07-18T21:01:41-07:00
New Revision: b2b39c5d455b950c6fffcc902924516fe7f8ec9f
URL: https://github.com/llvm/llvm-project/commit/b2b39c5d455b950c6fffcc902924516fe7f8ec9f
DIFF: https://github.com/llvm/llvm-project/commit/b2b39c5d455b950c6fffcc902924516fe7f8ec9f.diff
LOG: [Driver] --print-search-dirs: print -B options and COMPILER_PATH
Added:
clang/test/Driver/print-search-dirs.c
Modified:
clang/lib/Driver/Driver.cpp
clang/test/Driver/immediate-options.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 7d52882f8532..317098e24823 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 71494eec616f..d7cd6be40801 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 000000000000..0ac13125c9a1
--- /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
More information about the cfe-commits
mailing list