[lldb] Fix bug in fallback logic for finding the resource directory.
authorJonas Devlieghere <jonas@devlieghere.com>
Fri, 2 Oct 2020 16:53:30 +0000 (09:53 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Fri, 2 Oct 2020 16:56:01 +0000 (09:56 -0700)
Both of the if-clauses modify the raw_path variable and only one of them
was resetting the variable for the fallback. Avoid future bugs like that
by always resetting the variable.

Differential revision: https://reviews.llvm.org/D88704

lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp

index 8abb7e4..b76fa6f 100644 (file)
@@ -137,14 +137,12 @@ bool lldb_private::ComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
         FileSystem::Instance().Resolve(file_spec);
         return true;
       }
-      raw_path = lldb_shlib_spec.GetPath();
     }
-    raw_path.resize(rev_it - r_end);
-  } else {
-    raw_path.resize(rev_it - r_end);
   }
 
   // Fall back to the Clang resource directory inside the framework.
+  raw_path = lldb_shlib_spec.GetPath();
+  raw_path.resize(rev_it - r_end);
   raw_path.append("LLDB.framework/Resources/Clang");
   file_spec.GetDirectory().SetString(raw_path.c_str());
   FileSystem::Instance().Resolve(file_spec);