[Lldb-commits] [lldb] r332126 - Yet another follow-up to r332111. This also handles the case where an

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Fri May 11 12:29:26 PDT 2018


Author: adrian
Date: Fri May 11 12:29:25 2018
New Revision: 332126

URL: http://llvm.org/viewvc/llvm-project?rev=332126&view=rev
Log:
Yet another follow-up to r332111. This also handles the case where an
LLDB.framework is built inside the LLDB build directory (but not
inside an Xcode installation).

Modified:
    lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm
    lldb/trunk/unittests/Host/HostInfoTest.cpp

Modified: lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm?rev=332126&r1=332125&r2=332126&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm (original)
+++ lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm Fri May 11 12:29:25 2018
@@ -268,10 +268,11 @@ bool HostInfoMacOSX::ComputeClangDirecto
   // same Clang module cache.
   llvm::SmallString<256> clang_path;
   const char *swift_clang_resource_dir = "usr/lib/swift/clang";
-  ++rev_it;
-  if (rev_it != r_end && *rev_it == "SharedFrameworks") {
+  auto parent = std::next(rev_it);
+  if (parent != r_end && *parent == "SharedFrameworks") {
     // This is the top-level LLDB in the Xcode.app bundle.
-    raw_path.resize(rev_it - r_end);
+    // e.g., "Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A"
+    raw_path.resize(parent - r_end);
     llvm::sys::path::append(clang_path, raw_path,
                             "Developer/Toolchains/XcodeDefault.xctoolchain",
                             swift_clang_resource_dir);
@@ -279,10 +280,14 @@ bool HostInfoMacOSX::ComputeClangDirecto
       file_spec.SetFile(clang_path.c_str(), true);
       return true;
     }
-  } else if (rev_it != r_end && *rev_it == "PrivateFrameworks" &&
-             ++rev_it != r_end && ++rev_it != r_end) {
+  } else if (parent != r_end && *parent == "PrivateFrameworks" &&
+             std::distance(parent, r_end) > 2) {
     // This is LLDB inside an Xcode toolchain.
-    raw_path.resize(rev_it - r_end);
+    // e.g., "Xcode.app/Contents/Developer/Toolchains/" \
+    //       "My.xctoolchain/System/Library/PrivateFrameworks/LLDB.framework"
+    ++parent;
+    ++parent;
+    raw_path.resize(parent - r_end);
     llvm::sys::path::append(clang_path, raw_path, swift_clang_resource_dir);
     if (!verify || VerifyClangPath(clang_path)) {
       file_spec.SetFile(clang_path.c_str(), true);
@@ -293,7 +298,7 @@ bool HostInfoMacOSX::ComputeClangDirecto
   }
 
   // Fall back to the Clang resource directory inside the framework.
-  raw_path.append("/Resources/Clang");
+  raw_path.append("LLDB.framework/Resources/Clang");
   file_spec.SetFile(raw_path.c_str(), true);
   return true;
 }

Modified: lldb/trunk/unittests/Host/HostInfoTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/HostInfoTest.cpp?rev=332126&r1=332125&r2=332126&view=diff
==============================================================================
--- lldb/trunk/unittests/Host/HostInfoTest.cpp (original)
+++ lldb/trunk/unittests/Host/HostInfoTest.cpp Fri May 11 12:29:25 2018
@@ -63,11 +63,11 @@ TEST_F(HostInfoTest, MacOSX) {
   std::string posix = "/usr/lib/liblldb.dylib";
   EXPECT_FALSE(HostInfoMacOSXTest::ComputeClangDir(posix).empty());
 
-  std::string framework =
-    "/SharedFrameworks/LLDB.framework";
-  std::string framework_clang =
-    "/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang";
-  EXPECT_EQ(HostInfoMacOSXTest::ComputeClangDir(framework), framework_clang);
+  std::string build =
+    "/lldb-macosx-x86_64/Library/Frameworks/LLDB.framework/Versions/A";
+  std::string build_clang =
+    "/lldb-macosx-x86_64/Library/Frameworks/LLDB.framework/Resources/Clang";
+  EXPECT_EQ(HostInfoMacOSXTest::ComputeClangDir(build), build_clang);
 
   std::string xcode =
     "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A";




More information about the lldb-commits mailing list