[PATCH] D136940: [clang][Driver] allow tilde in user config dir
Michał Górny via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 16 04:23:45 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb3f94fe1c3c4: [clang][Driver] allow tilde in user config dir (authored by mgorny).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136940/new/
https://reviews.llvm.org/D136940
Files:
clang/lib/Driver/Driver.cpp
clang/test/Driver/config-file3.c
Index: clang/test/Driver/config-file3.c
===================================================================
--- clang/test/Driver/config-file3.c
+++ clang/test/Driver/config-file3.c
@@ -221,3 +221,8 @@
//
// RUN: rm %t/testdmode/clang-g++.cfg
// RUN: %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix NO-CONFIG
+
+//--- Tilde expansion in user configuration file directory
+//
+// RUN: HOME=%S/Inputs/config %clang --config-user-dir=~ -v 2>&1 | FileCheck %s -check-prefix CHECK-TILDE
+// CHECK-TILDE: User configuration file directory: {{.*}}/Inputs/config
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -220,7 +220,11 @@
SystemConfigDir = CLANG_CONFIG_FILE_SYSTEM_DIR;
#endif
#if defined(CLANG_CONFIG_FILE_USER_DIR)
- UserConfigDir = CLANG_CONFIG_FILE_USER_DIR;
+ {
+ SmallString<128> P;
+ llvm::sys::fs::expand_tilde(CLANG_CONFIG_FILE_USER_DIR, P);
+ UserConfigDir = static_cast<std::string>(P);
+ }
#endif
// Compute the path to the resource directory.
@@ -1008,8 +1012,8 @@
}
if (CLOptions->hasArg(options::OPT_config_user_dir_EQ)) {
SmallString<128> CfgDir;
- CfgDir.append(
- CLOptions->getLastArgValue(options::OPT_config_user_dir_EQ));
+ llvm::sys::fs::expand_tilde(
+ CLOptions->getLastArgValue(options::OPT_config_user_dir_EQ), CfgDir);
if (CfgDir.empty() || getVFS().makeAbsolute(CfgDir))
UserConfigDir.clear();
else
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136940.475772.patch
Type: text/x-patch
Size: 1650 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221116/9ccb82ce/attachment.bin>
More information about the cfe-commits
mailing list