diff --git a/lldb/source/Host/macosx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/HostInfoMacOSX.mm index 161182616cd0..07219968e096 100644 --- a/lldb/source/Host/macosx/HostInfoMacOSX.mm +++ b/lldb/source/Host/macosx/HostInfoMacOSX.mm @@ -253,7 +253,13 @@ bool HostInfoMacOSX::ComputeClangDirectory(FileSpec &lldb_shlib_spec, auto r_end = llvm::sys::path::rend(raw_path); // Check for a Posix-style build of LLDB. - if (rev_it == r_end || *rev_it != "LLDB.framework") + while (rev_it != r_end) { + if (*rev_it == "LLDB.framework") + break; + ++rev_it; + } + + if (rev_it == r_end) return HostInfoPosix::ComputeClangDirectory(file_spec); // Inside Xcode and in Xcode toolchains LLDB is always in lockstep diff --git a/lldb/unittests/Host/HostInfoTest.cpp b/lldb/unittests/Host/HostInfoTest.cpp index 4205ce36125f..d18a6a5b2f67 100644 --- a/lldb/unittests/Host/HostInfoTest.cpp +++ b/lldb/unittests/Host/HostInfoTest.cpp @@ -63,8 +63,14 @@ 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 xcode = - "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework"; + "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A"; std::string xcode_clang = "/Applications/Xcode.app/Contents/Developer/Toolchains/" "XcodeDefault.xctoolchain/usr/lib/swift/clang";