summaryrefslogtreecommitdiffstats
path: root/lldb/source/Utility/FileSpec.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2018-04-30 12:59:14 +0000
committerPavel Labath <labath@google.com>2018-04-30 12:59:14 +0000
commit410c5acf27167e482d5cdb83adeda3ea4714426d (patch)
tree65013c76cb2ace072a1d9aeaa6992f1a95083e2c /lldb/source/Utility/FileSpec.cpp
parent4aace8a3e06111500b8ccacf8d4046e5abfb8329 (diff)
downloadbcm5719-llvm-410c5acf27167e482d5cdb83adeda3ea4714426d.tar.gz
bcm5719-llvm-410c5acf27167e482d5cdb83adeda3ea4714426d.zip
Fixup r331049 (FileSpec auto-normalization)
A typo in the patch (using syntax instead of m_syntax) resulted in the normalization not working properly for windows filespecs when the syntax was passed as host-native. This did not affect the unit tests, as all of those pass an explicity syntax, but failed gloriously when running the full test suite. I also fix an expectation in an lldb-mi test, which was now failing because it was expecting a path to be echoed verbatim, but we were now normalizing it. As a drive-by, this also fixes the default-in-fully-covered-switch warning and removes an unused argument from the NeedsNormalization function. llvm-svn: 331172
Diffstat (limited to 'lldb/source/Utility/FileSpec.cpp')
-rw-r--r--lldb/source/Utility/FileSpec.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp
index cf94e63efcf..0a10fcad99c 100644
--- a/lldb/source/Utility/FileSpec.cpp
+++ b/lldb/source/Utility/FileSpec.cpp
@@ -69,7 +69,6 @@ LLVMPathSyntax(FileSpec::PathSyntax lldb_syntax) {
return llvm::sys::path::Style::posix;
case FileSpec::ePathSyntaxWindows:
return llvm::sys::path::Style::windows;
- default:
case FileSpec::ePathSyntaxHostNative:
return llvm::sys::path::Style::native;
};
@@ -236,14 +235,10 @@ inline char safeCharAtIndex(const llvm::StringRef &path, size_t i) {
/// @param[in] path
/// A full, partial, or relative path to a file.
///
-/// @param[in] syntax
-/// The syntax enumeration for the path in \a path.
-///
/// @return
/// Returns \b true if the path needs to be normalized.
//------------------------------------------------------------------
-bool needsNormalization(const llvm::StringRef &path,
- FileSpec::PathSyntax syntax) {
+bool needsNormalization(const llvm::StringRef &path) {
if (path.empty())
return false;
// We strip off leading "." values so these paths need to be normalized
@@ -338,12 +333,11 @@ void FileSpec::SetFile(llvm::StringRef pathname, bool resolve,
}
// Normalize the path by removing ".", ".." and other redundant components.
- if (needsNormalization(llvm::StringRef(resolved.data(), resolved.size()),
- syntax))
- llvm::sys::path::remove_dots(resolved, true, LLVMPathSyntax(syntax));
+ if (needsNormalization(resolved))
+ llvm::sys::path::remove_dots(resolved, true, LLVMPathSyntax(m_syntax));
// Normalize back slashes to forward slashes
- if (syntax == FileSpec::ePathSyntaxWindows)
+ if (m_syntax == FileSpec::ePathSyntaxWindows)
std::replace(resolved.begin(), resolved.end(), '\\', '/');
llvm::StringRef resolve_path_ref(resolved.c_str());
OpenPOWER on IntegriCloud