[Lldb-commits] [lldb] r331172 - Fixup r331049 (FileSpec auto-normalization)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 30 05:59:15 PDT 2018


Author: labath
Date: Mon Apr 30 05:59:14 2018
New Revision: 331172

URL: http://llvm.org/viewvc/llvm-project?rev=331172&view=rev
Log:
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.

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
    lldb/trunk/source/Utility/FileSpec.cpp

Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py?rev=331172&r1=331171&r2=331172&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py Mon Apr 30 05:59:14 2018
@@ -117,7 +117,7 @@ class MiStartupOptionsTestCase(lldbmi_te
         """Test that 'lldb-mi --interpreter %s' fails on executable file which is specified via unknown path."""
 
         # Prepare path to executable
-        path = "unknown_dir/%s" % self.myexe
+        path = "unknown_dir" + self.myexe
 
         self.spawnLldbMi(args="%s" % path)
 

Modified: lldb/trunk/source/Utility/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/FileSpec.cpp?rev=331172&r1=331171&r2=331172&view=diff
==============================================================================
--- lldb/trunk/source/Utility/FileSpec.cpp (original)
+++ lldb/trunk/source/Utility/FileSpec.cpp Mon Apr 30 05:59:14 2018
@@ -69,7 +69,6 @@ LLVMPathSyntax(FileSpec::PathSyntax lldb
       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::
 /// @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 p
   }
 
   // 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());




More information about the lldb-commits mailing list