[Lldb-commits] [PATCH] D81200: [vscode] set default values for terminateDebuggee for the disconnect request

2020-06-05 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: 
lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py:55
+
+self.process = subprocess.Popen([program, "--attach"],
+universal_newlines=True,

Writing an attach test is tricky because of the yama restrictions on linux. The 
way that we handle that right now is to have the inferior call 
`lldb_enable_attach()` and then create a token file. The test then waits for 
the token file `lldbutil.wait_for_file_on_target` and only then attaches. This 
ensures the attack takes place only when yama is disabled.



Comment at: 
lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py:68
+
+self.disconnect_and_check_no_output()

I'm confused as to why we're not expecting any output here. I was under the 
impression that we want to let the inferior continue in the "attach" case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81200/new/

https://reviews.llvm.org/D81200



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 846909e - [lldb] Fix UBSan regression in GetSLEB128

2020-06-05 Thread Jan Kratochvil via lldb-commits

Author: Jan Kratochvil
Date: 2020-06-05T12:00:44+02:00
New Revision: 846909e2ab0bd279ae2a8ec86074521f59c49eb3

URL: 
https://github.com/llvm/llvm-project/commit/846909e2ab0bd279ae2a8ec86074521f59c49eb3
DIFF: 
https://github.com/llvm/llvm-project/commit/846909e2ab0bd279ae2a8ec86074521f59c49eb3.diff

LOG: [lldb] Fix UBSan regression in GetSLEB128

It regressed recently by my: https://reviews.llvm.org/D81119

Added: 


Modified: 
lldb/source/Utility/DataExtractor.cpp

Removed: 




diff  --git a/lldb/source/Utility/DataExtractor.cpp 
b/lldb/source/Utility/DataExtractor.cpp
index 5f4abb82163e..023190b2ae91 100644
--- a/lldb/source/Utility/DataExtractor.cpp
+++ b/lldb/source/Utility/DataExtractor.cpp
@@ -930,8 +930,10 @@ int64_t DataExtractor::GetSLEB128(offset_t *offset_ptr) 
const {
 }
 
 // Sign bit of byte is 2nd high order bit (0x40)
-if (shift < size && (byte & 0x40))
-  result |= -(static_cast(1) << shift);
+if (shift < size && (byte & 0x40)) {
+  // -(static_cast(1) << 63) errors on the negation with UBSan.
+  result |= -(static_cast(1) << shift);
+}
 
 *offset_ptr += bytecount;
 return result;



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 2af2140 - [lldb] Handle new BFloat16 type

2020-06-05 Thread Kadir Cetinkaya via lldb-commits

Author: Kadir Cetinkaya
Date: 2020-06-05T12:25:26+02:00
New Revision: 2af2140983a8de838a93b375121515a6b48524d4

URL: 
https://github.com/llvm/llvm-project/commit/2af2140983a8de838a93b375121515a6b48524d4
DIFF: 
https://github.com/llvm/llvm-project/commit/2af2140983a8de838a93b375121515a6b48524d4.diff

LOG: [lldb] Handle new BFloat16 type

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 892df4fd5750..4e83a244d05b 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4740,6 +4740,7 @@ lldb::Encoding 
TypeSystemClang::GetEncoding(lldb::opaque_compiler_type_t type,
 case clang::BuiltinType::Float128:
 case clang::BuiltinType::Double:
 case clang::BuiltinType::LongDouble:
+case clang::BuiltinType::BFloat16:
   return lldb::eEncodingIEEE754;
 
 case clang::BuiltinType::ObjCClass:



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81119: [lldb] Fix SLEB128 decoding

2020-06-05 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In D81119#2074954 , @jasonmolenda 
wrote:

>   lldb-unit :: Utility/./UtilityTests/DataExtractorTest.GetSLEB128_bit63
>   lldb-shell :: SymbolFile/DWARF/DW_TAG_variable-DW_AT_const_value.s


That should be fixed by rG846909e2ab0b 
, I will 
check the sanitized buildbot, sorry I did check only other buildbots.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81119/new/

https://reviews.llvm.org/D81119



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81210: Teach GetXcodeSDK to look in the Xcode that contains LLDB

2020-06-05 Thread Frederic Riss via Phabricator via lldb-commits
friss added a comment.

This LGTM, with the caveat that it doesn't handle command line tools. But we 
didn't handle it correctly before, so not something we need to fix here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81210/new/

https://reviews.llvm.org/D81210



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81209: Move GetXcode*Directory into HostInfo (NFC)

2020-06-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81209/new/

https://reviews.llvm.org/D81209



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81210: Teach GetXcodeSDK to look in the Xcode that contains LLDB

2020-06-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm:372
+if (!developer_dir.empty())
+  xcrun_cmd = "/usr/bin/env DEVELOPER_DIR=" + developer_dir + " ";
+xcrun_cmd += "xcrun --show-sdk-path --sdk " + sdk_name;

Not something you should fix for this patch, but `RunShellCommand` should be 
able to take environment variables. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81210/new/

https://reviews.llvm.org/D81210



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81058: [lldb/Interpreter] Color "error:" and "warning:" in the CommandReturnObject output.

2020-06-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 268851.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81058/new/

https://reviews.llvm.org/D81058

Files:
  lldb/include/lldb/Interpreter/CommandReturnObject.h
  lldb/include/lldb/Utility/Stream.h
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/CommandReturnObject.cpp
  lldb/source/Utility/Stream.cpp

Index: lldb/source/Utility/Stream.cpp
===
--- lldb/source/Utility/Stream.cpp
+++ lldb/source/Utility/Stream.cpp
@@ -22,13 +22,14 @@
 using namespace lldb;
 using namespace lldb_private;
 
-Stream::Stream(uint32_t flags, uint32_t addr_size, ByteOrder byte_order)
+Stream::Stream(uint32_t flags, uint32_t addr_size, ByteOrder byte_order,
+   bool color)
 : m_flags(flags), m_addr_size(addr_size), m_byte_order(byte_order),
-  m_indent_level(0), m_forwarder(*this) {}
+  m_indent_level(0), m_color_enabled(color), m_forwarder(*this) {}
 
 Stream::Stream()
 : m_flags(0), m_addr_size(4), m_byte_order(endian::InlHostByteOrder()),
-  m_indent_level(0), m_forwarder(*this) {}
+  m_indent_level(0), m_color_enabled(false), m_forwarder(*this) {}
 
 // Destructor
 Stream::~Stream() {}
@@ -174,6 +175,13 @@
 m_indent_level = 0;
 }
 
+bool Stream::HasColors() const { return m_color_enabled; }
+
+void Stream::SetColors(bool colors) {
+  m_color_enabled = colors;
+  m_forwarder.enable_colors(colors);
+}
+
 // Get the address size in bytes
 uint32_t Stream::GetAddressByteSize() const { return m_addr_size; }
 
Index: lldb/source/Interpreter/CommandReturnObject.cpp
===
--- lldb/source/Interpreter/CommandReturnObject.cpp
+++ lldb/source/Interpreter/CommandReturnObject.cpp
@@ -28,9 +28,12 @@
 strm.EOL();
 }
 
-CommandReturnObject::CommandReturnObject()
+CommandReturnObject::CommandReturnObject(bool colors)
 : m_out_stream(), m_err_stream(), m_status(eReturnStatusStarted),
-  m_did_change_process_state(false), m_interactive(true) {}
+  m_did_change_process_state(false), m_interactive(true) {
+  m_out_stream.SetColors(colors);
+  m_err_stream.SetColors(colors);
+}
 
 CommandReturnObject::~CommandReturnObject() {}
 
@@ -45,9 +48,8 @@
 
   const std::string &s = std::string(sstrm.GetString());
   if (!s.empty()) {
-Stream &error_strm = GetErrorStream();
-error_strm.PutCString("error: ");
-DumpStringToStreamWithNewline(error_strm, s);
+llvm::WithColor::error(GetErrorStream().AsRawOstream());
+DumpStringToStreamWithNewline(GetErrorStream(), s);
   }
 }
 
@@ -72,7 +74,8 @@
   sstrm.PrintfVarArg(format, args);
   va_end(args);
 
-  GetErrorStream() << "warning: " << sstrm.GetString();
+  llvm::WithColor::warning(GetErrorStream().AsRawOstream())
+  << sstrm.GetString();
 }
 
 void CommandReturnObject::AppendMessage(llvm::StringRef in_string) {
@@ -84,7 +87,8 @@
 void CommandReturnObject::AppendWarning(llvm::StringRef in_string) {
   if (in_string.empty())
 return;
-  GetErrorStream() << "warning: " << in_string << "\n";
+  llvm::WithColor::warning(GetErrorStream().AsRawOstream())
+  << in_string << '\n';
 }
 
 // Similar to AppendWarning, but do not prepend 'warning: ' to message, and
@@ -99,7 +103,7 @@
 void CommandReturnObject::AppendError(llvm::StringRef in_string) {
   if (in_string.empty())
 return;
-  GetErrorStream() << "error: " << in_string << "\n";
+  llvm::WithColor::error(GetErrorStream().AsRawOstream()) << in_string << '\n';
 }
 
 void CommandReturnObject::SetError(const Status &error,
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -209,7 +209,7 @@
   static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
   Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
 
-  CommandReturnObject result;
+  CommandReturnObject result(m_debugger.GetUseColor());
 
   LoadCommandDictionary();
 
@@ -2792,7 +2792,7 @@
 
   StartHandlingCommand();
 
-  lldb_private::CommandReturnObject result;
+  lldb_private::CommandReturnObject result(m_debugger.GetUseColor());
   HandleCommand(line.c_str(), eLazyBoolCalculate, result);
 
   // Now emit the command output text from the command we just executed
Index: lldb/include/lldb/Utility/Stream.h
===
--- lldb/include/lldb/Utility/Stream.h
+++ lldb/include/lldb/Utility/Stream.h
@@ -56,7 +56,8 @@
   ///
   /// Construct with dump flags \a flags and the default address size. \a
   /// flags can be any of the above enumeration logical OR'ed together.
-  Stream(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order);
+  Stream(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order,
+ bool color = false);
 
   /// Construct a default Stream, not binary, host byt

[Lldb-commits] [PATCH] D81210: Teach GetXcodeSDK to look in the Xcode that contains LLDB

2020-06-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere requested changes to this revision.
JDevlieghere added inline comments.
This revision now requires changes to proceed.



Comment at: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm:364
+Environment env = Host::GetEnvironment();
+std::string developer_dir = env.lookup("DEVELOPER_DIR");
+if (developer_dir.empty()) {

Above we use `getenv`, here we use `Host::GetEnvironment`. We should pick one 
and be consistent. 



Comment at: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm:367
+  // Avoid infinite recursion GetXcodeContentsDirectory calling 
GetXcodeSDK.
+  FileSpec path = ::GetXcodeContentsDirectory(false);
+  if (path.RemoveLastPathComponent())

It looks like this is basically dealing with one case (shlib) of the logic in 
GetXcodeContentsDirectory. I would prefer to make this a separate function 
`GetXcodeDeveloperDirectory` or something that does just that. 

Before I refactored these functions there were several methods where we tried 
to share code like this. While I'm generally a strong opponent of sharing code, 
this lead to the pattern we see here where we need to add complexity to the 
"generic" function to make things work. This in turn makes things more complex 
and harder to understand, up till the point that we inevitable implemented 
something "similar but different" elsewhere. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81210/new/

https://reviews.llvm.org/D81210



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81210: Teach GetXcodeSDK to look in the Xcode that contains LLDB

2020-06-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 268870.
aprantl added a comment.

Address feedback from Jonas!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81210/new/

https://reviews.llvm.org/D81210

Files:
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm


Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -358,7 +358,21 @@
   XcodeSDK::Info info = sdk.Parse();
   std::string sdk_name = XcodeSDK::GetCanonicalName(info);
   auto find_sdk = [](std::string sdk_name) -> std::string {
-std::string xcrun_cmd = "xcrun --show-sdk-path --sdk " + sdk_name;
+std::string xcrun_cmd;
+Environment env = Host::GetEnvironment();
+std::string developer_dir = env.lookup("DEVELOPER_DIR");
+if (developer_dir.empty())
+  if (FileSpec fspec = HostInfo::GetShlibDir())
+if (FileSystem::Instance().Exists(fspec)) {
+  FileSpec path(
+  XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath()));
+  if (path.RemoveLastPathComponent())
+developer_dir = path.GetPath();
+}
+if (!developer_dir.empty())
+  xcrun_cmd = "/usr/bin/env DEVELOPER_DIR=\"" + developer_dir + "\" ";
+xcrun_cmd += "xcrun --show-sdk-path --sdk " + sdk_name;
+
 int status = 0;
 int signo = 0;
 std::string output_str;


Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -358,7 +358,21 @@
   XcodeSDK::Info info = sdk.Parse();
   std::string sdk_name = XcodeSDK::GetCanonicalName(info);
   auto find_sdk = [](std::string sdk_name) -> std::string {
-std::string xcrun_cmd = "xcrun --show-sdk-path --sdk " + sdk_name;
+std::string xcrun_cmd;
+Environment env = Host::GetEnvironment();
+std::string developer_dir = env.lookup("DEVELOPER_DIR");
+if (developer_dir.empty())
+  if (FileSpec fspec = HostInfo::GetShlibDir())
+if (FileSystem::Instance().Exists(fspec)) {
+  FileSpec path(
+  XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath()));
+  if (path.RemoveLastPathComponent())
+developer_dir = path.GetPath();
+}
+if (!developer_dir.empty())
+  xcrun_cmd = "/usr/bin/env DEVELOPER_DIR=\"" + developer_dir + "\" ";
+xcrun_cmd += "xcrun --show-sdk-path --sdk " + sdk_name;
+
 int status = 0;
 int signo = 0;
 std::string output_str;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81210: Teach GetXcodeSDK to look in the Xcode that contains LLDB

2020-06-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm:365
+if (developer_dir.empty())
+  if (FileSpec fspec = HostInfo::GetShlibDir())
+if (FileSystem::Instance().Exists(fspec)) {

Any reason you choose to leave this inline and not making it a separate 
function? If we did we could also cache the result like we do for some of the 
other paths. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81210/new/

https://reviews.llvm.org/D81210



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81210: Teach GetXcodeSDK to look in the Xcode that contains LLDB

2020-06-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl marked 2 inline comments as done.
aprantl added inline comments.



Comment at: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm:364
+Environment env = Host::GetEnvironment();
+std::string developer_dir = env.lookup("DEVELOPER_DIR");
+if (developer_dir.empty()) {

JDevlieghere wrote:
> Above we use `getenv`, here we use `Host::GetEnvironment`. We should pick one 
> and be consistent. 
I will create a follow-up patch for above.



Comment at: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm:365
+if (developer_dir.empty())
+  if (FileSpec fspec = HostInfo::GetShlibDir())
+if (FileSystem::Instance().Exists(fspec)) {

JDevlieghere wrote:
> Any reason you choose to leave this inline and not making it a separate 
> function? If we did we could also cache the result like we do for some of the 
> other paths. 
This function is going to be called at most ~7*2 times, once for each XcodeSDK 
kind * Internal. So caching isn't really relevant. i also would like to 
refactor the other function after this patch, which would make factoring this 
out first really awkward.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81210/new/

https://reviews.llvm.org/D81210



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81210: Teach GetXcodeSDK to look in the Xcode that contains LLDB

2020-06-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm:365
+if (developer_dir.empty())
+  if (FileSpec fspec = HostInfo::GetShlibDir())
+if (FileSystem::Instance().Exists(fspec)) {

aprantl wrote:
> JDevlieghere wrote:
> > Any reason you choose to leave this inline and not making it a separate 
> > function? If we did we could also cache the result like we do for some of 
> > the other paths. 
> This function is going to be called at most ~7*2 times, once for each 
> XcodeSDK kind * Internal. So caching isn't really relevant. i also would like 
> to refactor the other function after this patch, which would make factoring 
> this out first really awkward.
Sounds good!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81210/new/

https://reviews.llvm.org/D81210



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81289: Factor out GetEnvDeveloperDir() (NFC)

2020-06-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added a reviewer: JDevlieghere.

https://reviews.llvm.org/D81289

Files:
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm


Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -297,6 +297,19 @@
   }
 }
 
+/// Return and cache $DEVELOPER_DIR if it is set and exists.
+static std::string GetEnvDeveloperDir() {
+  static std::string g_env_developer_dir;
+  static std::once_flag g_once_flag;
+  std::call_once(g_once_flag, [&]() {
+if (const char *developer_dir_env_var = getenv("DEVELOPER_DIR")) {
+  FileSpec fspec(developer_dir_env_var);
+  if (FileSystem::Instance().Exists(fspec))
+g_env_developer_dir = fspec.GetPath();
+}});
+  return g_env_developer_dir;
+}
+
 FileSpec HostInfoMacOSX::GetXcodeContentsDirectory() {
   static FileSpec g_xcode_contents_path;
   static std::once_flag g_once_flag;
@@ -313,16 +326,14 @@
   }
 }
 
-if (const char *developer_dir_env_var = getenv("DEVELOPER_DIR")) {
-  FileSpec fspec(developer_dir_env_var);
-  if (FileSystem::Instance().Exists(fspec)) {
-// FIXME: This looks like it couldn't possibly work!
-std::string xcode_contents_dir =
-XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath());
-if (!xcode_contents_dir.empty()) {
-  g_xcode_contents_path = FileSpec(xcode_contents_dir);
-  return;
-}
+std::string env_developer_dir = GetEnvDeveloperDir();
+if (!env_developer_dir.empty()) {
+  // FIXME: This looks like it couldn't possibly work!
+  std::string xcode_contents_dir =
+  XcodeSDK::FindXcodeContentsDirectoryInPath(env_developer_dir);
+  if (!xcode_contents_dir.empty()) {
+g_xcode_contents_path = FileSpec(xcode_contents_dir);
+return;
   }
 }
 
@@ -359,8 +370,7 @@
   std::string sdk_name = XcodeSDK::GetCanonicalName(info);
   auto find_sdk = [](std::string sdk_name) -> std::string {
 std::string xcrun_cmd;
-Environment env = Host::GetEnvironment();
-std::string developer_dir = env.lookup("DEVELOPER_DIR");
+std::string developer_dir = GetEnvDeveloperDir();
 if (developer_dir.empty())
   if (FileSpec fspec = HostInfo::GetShlibDir())
 if (FileSystem::Instance().Exists(fspec)) {


Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -297,6 +297,19 @@
   }
 }
 
+/// Return and cache $DEVELOPER_DIR if it is set and exists.
+static std::string GetEnvDeveloperDir() {
+  static std::string g_env_developer_dir;
+  static std::once_flag g_once_flag;
+  std::call_once(g_once_flag, [&]() {
+if (const char *developer_dir_env_var = getenv("DEVELOPER_DIR")) {
+  FileSpec fspec(developer_dir_env_var);
+  if (FileSystem::Instance().Exists(fspec))
+g_env_developer_dir = fspec.GetPath();
+}});
+  return g_env_developer_dir;
+}
+
 FileSpec HostInfoMacOSX::GetXcodeContentsDirectory() {
   static FileSpec g_xcode_contents_path;
   static std::once_flag g_once_flag;
@@ -313,16 +326,14 @@
   }
 }
 
-if (const char *developer_dir_env_var = getenv("DEVELOPER_DIR")) {
-  FileSpec fspec(developer_dir_env_var);
-  if (FileSystem::Instance().Exists(fspec)) {
-// FIXME: This looks like it couldn't possibly work!
-std::string xcode_contents_dir =
-XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath());
-if (!xcode_contents_dir.empty()) {
-  g_xcode_contents_path = FileSpec(xcode_contents_dir);
-  return;
-}
+std::string env_developer_dir = GetEnvDeveloperDir();
+if (!env_developer_dir.empty()) {
+  // FIXME: This looks like it couldn't possibly work!
+  std::string xcode_contents_dir =
+  XcodeSDK::FindXcodeContentsDirectoryInPath(env_developer_dir);
+  if (!xcode_contents_dir.empty()) {
+g_xcode_contents_path = FileSpec(xcode_contents_dir);
+return;
   }
 }
 
@@ -359,8 +370,7 @@
   std::string sdk_name = XcodeSDK::GetCanonicalName(info);
   auto find_sdk = [](std::string sdk_name) -> std::string {
 std::string xcrun_cmd;
-Environment env = Host::GetEnvironment();
-std::string developer_dir = env.lookup("DEVELOPER_DIR");
+std::string developer_dir = GetEnvDeveloperDir();
 if (developer_dir.empty())
   if (FileSpec fspec = HostInfo::GetShlibDir())
 if (FileSystem::Instance().Exists(fspec)) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81290: Fix an oversight in GetXcodeContentsDirectory()

2020-06-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added a reviewer: JDevlieghere.

Since FindXcodeContentsDirectoryInPath expects the *.app/Contents and 
DEVELOPER_DIR is supposed to point to Xcode.app, we need to append the Contents 
path first.


https://reviews.llvm.org/D81290

Files:
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm


Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -326,9 +326,9 @@
   }
 }
 
-std::string env_developer_dir = GetEnvDeveloperDir();
+llvm::SmallString<128> env_developer_dir(GetEnvDeveloperDir());
 if (!env_developer_dir.empty()) {
-  // FIXME: This looks like it couldn't possibly work!
+  llvm::sys::path::append(env_developer_dir, "Contents");
   std::string xcode_contents_dir =
   XcodeSDK::FindXcodeContentsDirectoryInPath(env_developer_dir);
   if (!xcode_contents_dir.empty()) {


Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -326,9 +326,9 @@
   }
 }
 
-std::string env_developer_dir = GetEnvDeveloperDir();
+llvm::SmallString<128> env_developer_dir(GetEnvDeveloperDir());
 if (!env_developer_dir.empty()) {
-  // FIXME: This looks like it couldn't possibly work!
+  llvm::sys::path::append(env_developer_dir, "Contents");
   std::string xcode_contents_dir =
   XcodeSDK::FindXcodeContentsDirectoryInPath(env_developer_dir);
   if (!xcode_contents_dir.empty()) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 79daa3d - Teach GetXcodeSDK to look in the Xcode that contains LLDB

2020-06-05 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-06-05T11:59:22-07:00
New Revision: 79daa3d896495e2755e530ce0658be3e80dfe4c9

URL: 
https://github.com/llvm/llvm-project/commit/79daa3d896495e2755e530ce0658be3e80dfe4c9
DIFF: 
https://github.com/llvm/llvm-project/commit/79daa3d896495e2755e530ce0658be3e80dfe4c9.diff

LOG: Teach GetXcodeSDK to look in the Xcode that contains LLDB

instead of preferring the one chosen with xcode-select.



Differential Revision: https://reviews.llvm.org/D81210

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 5c459a041383..cf2f2dcb3aff 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -358,7 +358,21 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   XcodeSDK::Info info = sdk.Parse();
   std::string sdk_name = XcodeSDK::GetCanonicalName(info);
   auto find_sdk = [](std::string sdk_name) -> std::string {
-std::string xcrun_cmd = "xcrun --show-sdk-path --sdk " + sdk_name;
+std::string xcrun_cmd;
+Environment env = Host::GetEnvironment();
+std::string developer_dir = env.lookup("DEVELOPER_DIR");
+if (developer_dir.empty())
+  if (FileSpec fspec = HostInfo::GetShlibDir())
+if (FileSystem::Instance().Exists(fspec)) {
+  FileSpec path(
+  XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath()));
+  if (path.RemoveLastPathComponent())
+developer_dir = path.GetPath();
+}
+if (!developer_dir.empty())
+  xcrun_cmd = "/usr/bin/env DEVELOPER_DIR=\"" + developer_dir + "\" ";
+xcrun_cmd += "xcrun --show-sdk-path --sdk " + sdk_name;
+
 int status = 0;
 int signo = 0;
 std::string output_str;



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 3d7b926 - Move GetXcode*Directory into HostInfo (NFC)

2020-06-05 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-06-05T11:59:22-07:00
New Revision: 3d7b926dd16ff9ff264337793b76080681636f15

URL: 
https://github.com/llvm/llvm-project/commit/3d7b926dd16ff9ff264337793b76080681636f15
DIFF: 
https://github.com/llvm/llvm-project/commit/3d7b926dd16ff9ff264337793b76080681636f15.diff

LOG: Move GetXcode*Directory into HostInfo (NFC)

These functions really don't belong into PlatformDarwin, since they
actualy query state of the Host and not of the remote platform.

Added: 


Modified: 
lldb/include/lldb/Host/HostInfoBase.h
lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
lldb/include/lldb/Utility/XcodeSDK.h
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
lldb/source/Utility/XcodeSDK.cpp
lldb/unittests/Platform/PlatformDarwinTest.cpp
lldb/unittests/Utility/XcodeSDKTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/HostInfoBase.h 
b/lldb/include/lldb/Host/HostInfoBase.h
index dbd11505c21b..70682c9b685e 100644
--- a/lldb/include/lldb/Host/HostInfoBase.h
+++ b/lldb/include/lldb/Host/HostInfoBase.h
@@ -92,6 +92,9 @@ class HostInfoBase {
   static bool ComputePathRelativeToLibrary(FileSpec &file_spec,
llvm::StringRef dir);
 
+  static FileSpec GetXcodeContentsDirectory() { return {}; }
+  static FileSpec GetXcodeDeveloperDirectory() { return {}; }
+  
   /// Return the directory containing a specific Xcode SDK.
   static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk) { return {}; }
 

diff  --git a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h 
b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
index dacb8c40f0fb..3941414f8abd 100644
--- a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
+++ b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
@@ -32,7 +32,8 @@ class HostInfoMacOSX : public HostInfoPosix {
   static bool GetOSBuildString(std::string &s);
   static bool GetOSKernelDescription(std::string &s);
   static FileSpec GetProgramFileSpec();
-  static std::string FindXcodeContentsDirectoryInPath(llvm::StringRef path);
+  static FileSpec GetXcodeContentsDirectory();
+  static FileSpec GetXcodeDeveloperDirectory();
 
   /// Query xcrun to find an Xcode SDK directory.
   static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk);

diff  --git a/lldb/include/lldb/Utility/XcodeSDK.h 
b/lldb/include/lldb/Utility/XcodeSDK.h
index 2ed5fab1c941..307fe7f46798 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -87,6 +87,8 @@ class XcodeSDK {
   static std::string GetCanonicalName(Info info);
   /// Return the best-matching SDK type for a specific triple.
   static XcodeSDK::Type GetSDKTypeForTriple(const llvm::Triple &triple);
+
+  static std::string FindXcodeContentsDirectoryInPath(llvm::StringRef path);
 };
 
 } // namespace lldb_private

diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 615f77b2dbcc..5c459a041383 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -297,6 +297,63 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   }
 }
 
+FileSpec HostInfoMacOSX::GetXcodeContentsDirectory() {
+  static FileSpec g_xcode_contents_path;
+  static std::once_flag g_once_flag;
+  std::call_once(g_once_flag, [&]() {
+// Try the shlib dir first.
+if (FileSpec fspec = HostInfo::GetShlibDir()) {
+  if (FileSystem::Instance().Exists(fspec)) {
+std::string xcode_contents_dir =
+XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath());
+if (!xcode_contents_dir.empty()) {
+  g_xcode_contents_path = FileSpec(xcode_contents_dir);
+  return;
+}
+  }
+}
+
+if (const char *developer_dir_env_var = getenv("DEVELOPER_DIR")) {
+  FileSpec fspec(developer_dir_env_var);
+  if (FileSystem::Instance().Exists(fspec)) {
+// FIXME: This looks like it couldn't possibly work!
+std::string xcode_contents_dir =
+XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath());
+if (!xcode_contents_dir.empty()) {
+  g_xcode_contents_path = FileSpec(xcode_contents_dir);
+  return;
+}
+  }
+}
+
+FileSpec fspec(HostInfo::GetXcodeSDKPath(XcodeSDK::GetAnyMa

[Lldb-commits] [PATCH] D81210: Teach GetXcodeSDK to look in the Xcode that contains LLDB

2020-06-05 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG79daa3d89649: Teach GetXcodeSDK to look in the Xcode that 
contains LLDB (authored by aprantl).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81210/new/

https://reviews.llvm.org/D81210

Files:
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm


Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -358,7 +358,21 @@
   XcodeSDK::Info info = sdk.Parse();
   std::string sdk_name = XcodeSDK::GetCanonicalName(info);
   auto find_sdk = [](std::string sdk_name) -> std::string {
-std::string xcrun_cmd = "xcrun --show-sdk-path --sdk " + sdk_name;
+std::string xcrun_cmd;
+Environment env = Host::GetEnvironment();
+std::string developer_dir = env.lookup("DEVELOPER_DIR");
+if (developer_dir.empty())
+  if (FileSpec fspec = HostInfo::GetShlibDir())
+if (FileSystem::Instance().Exists(fspec)) {
+  FileSpec path(
+  XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath()));
+  if (path.RemoveLastPathComponent())
+developer_dir = path.GetPath();
+}
+if (!developer_dir.empty())
+  xcrun_cmd = "/usr/bin/env DEVELOPER_DIR=\"" + developer_dir + "\" ";
+xcrun_cmd += "xcrun --show-sdk-path --sdk " + sdk_name;
+
 int status = 0;
 int signo = 0;
 std::string output_str;


Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -358,7 +358,21 @@
   XcodeSDK::Info info = sdk.Parse();
   std::string sdk_name = XcodeSDK::GetCanonicalName(info);
   auto find_sdk = [](std::string sdk_name) -> std::string {
-std::string xcrun_cmd = "xcrun --show-sdk-path --sdk " + sdk_name;
+std::string xcrun_cmd;
+Environment env = Host::GetEnvironment();
+std::string developer_dir = env.lookup("DEVELOPER_DIR");
+if (developer_dir.empty())
+  if (FileSpec fspec = HostInfo::GetShlibDir())
+if (FileSystem::Instance().Exists(fspec)) {
+  FileSpec path(
+  XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath()));
+  if (path.RemoveLastPathComponent())
+developer_dir = path.GetPath();
+}
+if (!developer_dir.empty())
+  xcrun_cmd = "/usr/bin/env DEVELOPER_DIR=\"" + developer_dir + "\" ";
+xcrun_cmd += "xcrun --show-sdk-path --sdk " + sdk_name;
+
 int status = 0;
 int signo = 0;
 std::string output_str;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81300: Enable -DLLDB_ENERGY when compiling against an internal SDK

2020-06-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: jasonmolenda, friss, JDevlieghere.
Herald added a subscriber: mgorny.

This brings over functionality from the xcodeproject that went missing during 
the CMake transition.

rdar://problem/63840635


https://reviews.llvm.org/D81300

Files:
  lldb/tools/debugserver/source/CMakeLists.txt


Index: lldb/tools/debugserver/source/CMakeLists.txt
===
--- lldb/tools/debugserver/source/CMakeLists.txt
+++ lldb/tools/debugserver/source/CMakeLists.txt
@@ -129,6 +129,14 @@
   endif()
 endif()
 
+if($ENV{SDKROOT} MATCHES ".Internal.sdk$")
+  message(STATUS "LLDB debugserver energy support is enabled")
+  add_definitions(-DLLDB_ENERGY)
+  set(ENERGY_LIBRARY -lpmenergy -lpmsample)
+else()
+  message(STATUS "LLDB debugserver energy support is disabled")
+endif()
+
 set(generated_mach_interfaces
   ${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h
   ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
@@ -208,7 +216,8 @@
   lldbDebugserverDarwin_DarwinLog
   ${FOUNDATION_LIBRARY}
   ${SECURITY_LIBRARY}
-  ${LIBCOMPRESSION})
+  ${LIBCOMPRESSION}
+  ${ENERGY_LIBRARY})
 if(HAVE_LIBCOMPRESSION)
   set_property(TARGET lldbDebugserverCommon APPEND PROPERTY
 COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)


Index: lldb/tools/debugserver/source/CMakeLists.txt
===
--- lldb/tools/debugserver/source/CMakeLists.txt
+++ lldb/tools/debugserver/source/CMakeLists.txt
@@ -129,6 +129,14 @@
   endif()
 endif()
 
+if($ENV{SDKROOT} MATCHES ".Internal.sdk$")
+  message(STATUS "LLDB debugserver energy support is enabled")
+  add_definitions(-DLLDB_ENERGY)
+  set(ENERGY_LIBRARY -lpmenergy -lpmsample)
+else()
+  message(STATUS "LLDB debugserver energy support is disabled")
+endif()
+
 set(generated_mach_interfaces
   ${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h
   ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
@@ -208,7 +216,8 @@
   lldbDebugserverDarwin_DarwinLog
   ${FOUNDATION_LIBRARY}
   ${SECURITY_LIBRARY}
-  ${LIBCOMPRESSION})
+  ${LIBCOMPRESSION}
+  ${ENERGY_LIBRARY})
 if(HAVE_LIBCOMPRESSION)
   set_property(TARGET lldbDebugserverCommon APPEND PROPERTY
 COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] f28177d - Factor out GetEnvDeveloperDir() (NFC)

2020-06-05 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-06-05T13:50:37-07:00
New Revision: f28177dbe8d2e2955f7ca0a0ffdb1a44fefe092d

URL: 
https://github.com/llvm/llvm-project/commit/f28177dbe8d2e2955f7ca0a0ffdb1a44fefe092d
DIFF: 
https://github.com/llvm/llvm-project/commit/f28177dbe8d2e2955f7ca0a0ffdb1a44fefe092d.diff

LOG: Factor out GetEnvDeveloperDir() (NFC)

Differential Revision: https://reviews.llvm.org/D81289

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index cf2f2dcb3aff..37bcff24ba23 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -297,6 +297,19 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   }
 }
 
+/// Return and cache $DEVELOPER_DIR if it is set and exists.
+static std::string GetEnvDeveloperDir() {
+  static std::string g_env_developer_dir;
+  static std::once_flag g_once_flag;
+  std::call_once(g_once_flag, [&]() {
+if (const char *developer_dir_env_var = getenv("DEVELOPER_DIR")) {
+  FileSpec fspec(developer_dir_env_var);
+  if (FileSystem::Instance().Exists(fspec))
+g_env_developer_dir = fspec.GetPath();
+}});
+  return g_env_developer_dir;
+}
+
 FileSpec HostInfoMacOSX::GetXcodeContentsDirectory() {
   static FileSpec g_xcode_contents_path;
   static std::once_flag g_once_flag;
@@ -313,16 +326,14 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   }
 }
 
-if (const char *developer_dir_env_var = getenv("DEVELOPER_DIR")) {
-  FileSpec fspec(developer_dir_env_var);
-  if (FileSystem::Instance().Exists(fspec)) {
-// FIXME: This looks like it couldn't possibly work!
-std::string xcode_contents_dir =
-XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath());
-if (!xcode_contents_dir.empty()) {
-  g_xcode_contents_path = FileSpec(xcode_contents_dir);
-  return;
-}
+std::string env_developer_dir = GetEnvDeveloperDir();
+if (!env_developer_dir.empty()) {
+  // FIXME: This looks like it couldn't possibly work!
+  std::string xcode_contents_dir =
+  XcodeSDK::FindXcodeContentsDirectoryInPath(env_developer_dir);
+  if (!xcode_contents_dir.empty()) {
+g_xcode_contents_path = FileSpec(xcode_contents_dir);
+return;
   }
 }
 
@@ -359,8 +370,7 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   std::string sdk_name = XcodeSDK::GetCanonicalName(info);
   auto find_sdk = [](std::string sdk_name) -> std::string {
 std::string xcrun_cmd;
-Environment env = Host::GetEnvironment();
-std::string developer_dir = env.lookup("DEVELOPER_DIR");
+std::string developer_dir = GetEnvDeveloperDir();
 if (developer_dir.empty())
   if (FileSpec fspec = HostInfo::GetShlibDir())
 if (FileSystem::Instance().Exists(fspec)) {



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] ad4e7b9 - Fix an oversight in GetXcodeContentsDirectory()

2020-06-05 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-06-05T13:50:37-07:00
New Revision: ad4e7b9dc82b13d124071f0add09cb541b495a0e

URL: 
https://github.com/llvm/llvm-project/commit/ad4e7b9dc82b13d124071f0add09cb541b495a0e
DIFF: 
https://github.com/llvm/llvm-project/commit/ad4e7b9dc82b13d124071f0add09cb541b495a0e.diff

LOG: Fix an oversight in GetXcodeContentsDirectory()

Since FindXcodeContentsDirectoryInPath expects the *.app/Contents and
DEVELOPER_DIR is supposed to point to Xcode.app, we need to append the
Contents path first.

Differential Revision: https://reviews.llvm.org/D81290

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 37bcff24ba23..fd88d0c31de6 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -326,9 +326,9 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   }
 }
 
-std::string env_developer_dir = GetEnvDeveloperDir();
+llvm::SmallString<128> env_developer_dir(GetEnvDeveloperDir());
 if (!env_developer_dir.empty()) {
-  // FIXME: This looks like it couldn't possibly work!
+  llvm::sys::path::append(env_developer_dir, "Contents");
   std::string xcode_contents_dir =
   XcodeSDK::FindXcodeContentsDirectoryInPath(env_developer_dir);
   if (!xcode_contents_dir.empty()) {



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81209: Move GetXcode*Directory into HostInfo (NFC)

2020-06-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl closed this revision.
aprantl added a comment.

3d7b926dd16ff9ff264337793b76080681636f15 



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81209/new/

https://reviews.llvm.org/D81209



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81290: Fix an oversight in GetXcodeContentsDirectory()

2020-06-05 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGad4e7b9dc82b: Fix an oversight in 
GetXcodeContentsDirectory() (authored by aprantl).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81290/new/

https://reviews.llvm.org/D81290

Files:
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm


Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -326,9 +326,9 @@
   }
 }
 
-std::string env_developer_dir = GetEnvDeveloperDir();
+llvm::SmallString<128> env_developer_dir(GetEnvDeveloperDir());
 if (!env_developer_dir.empty()) {
-  // FIXME: This looks like it couldn't possibly work!
+  llvm::sys::path::append(env_developer_dir, "Contents");
   std::string xcode_contents_dir =
   XcodeSDK::FindXcodeContentsDirectoryInPath(env_developer_dir);
   if (!xcode_contents_dir.empty()) {


Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -326,9 +326,9 @@
   }
 }
 
-std::string env_developer_dir = GetEnvDeveloperDir();
+llvm::SmallString<128> env_developer_dir(GetEnvDeveloperDir());
 if (!env_developer_dir.empty()) {
-  // FIXME: This looks like it couldn't possibly work!
+  llvm::sys::path::append(env_developer_dir, "Contents");
   std::string xcode_contents_dir =
   XcodeSDK::FindXcodeContentsDirectoryInPath(env_developer_dir);
   if (!xcode_contents_dir.empty()) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81289: Factor out GetEnvDeveloperDir() (NFC)

2020-06-05 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf28177dbe8d2: Factor out GetEnvDeveloperDir() (NFC) 
(authored by aprantl).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81289/new/

https://reviews.llvm.org/D81289

Files:
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm


Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -297,6 +297,19 @@
   }
 }
 
+/// Return and cache $DEVELOPER_DIR if it is set and exists.
+static std::string GetEnvDeveloperDir() {
+  static std::string g_env_developer_dir;
+  static std::once_flag g_once_flag;
+  std::call_once(g_once_flag, [&]() {
+if (const char *developer_dir_env_var = getenv("DEVELOPER_DIR")) {
+  FileSpec fspec(developer_dir_env_var);
+  if (FileSystem::Instance().Exists(fspec))
+g_env_developer_dir = fspec.GetPath();
+}});
+  return g_env_developer_dir;
+}
+
 FileSpec HostInfoMacOSX::GetXcodeContentsDirectory() {
   static FileSpec g_xcode_contents_path;
   static std::once_flag g_once_flag;
@@ -313,16 +326,14 @@
   }
 }
 
-if (const char *developer_dir_env_var = getenv("DEVELOPER_DIR")) {
-  FileSpec fspec(developer_dir_env_var);
-  if (FileSystem::Instance().Exists(fspec)) {
-// FIXME: This looks like it couldn't possibly work!
-std::string xcode_contents_dir =
-XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath());
-if (!xcode_contents_dir.empty()) {
-  g_xcode_contents_path = FileSpec(xcode_contents_dir);
-  return;
-}
+std::string env_developer_dir = GetEnvDeveloperDir();
+if (!env_developer_dir.empty()) {
+  // FIXME: This looks like it couldn't possibly work!
+  std::string xcode_contents_dir =
+  XcodeSDK::FindXcodeContentsDirectoryInPath(env_developer_dir);
+  if (!xcode_contents_dir.empty()) {
+g_xcode_contents_path = FileSpec(xcode_contents_dir);
+return;
   }
 }
 
@@ -359,8 +370,7 @@
   std::string sdk_name = XcodeSDK::GetCanonicalName(info);
   auto find_sdk = [](std::string sdk_name) -> std::string {
 std::string xcrun_cmd;
-Environment env = Host::GetEnvironment();
-std::string developer_dir = env.lookup("DEVELOPER_DIR");
+std::string developer_dir = GetEnvDeveloperDir();
 if (developer_dir.empty())
   if (FileSpec fspec = HostInfo::GetShlibDir())
 if (FileSystem::Instance().Exists(fspec)) {


Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -297,6 +297,19 @@
   }
 }
 
+/// Return and cache $DEVELOPER_DIR if it is set and exists.
+static std::string GetEnvDeveloperDir() {
+  static std::string g_env_developer_dir;
+  static std::once_flag g_once_flag;
+  std::call_once(g_once_flag, [&]() {
+if (const char *developer_dir_env_var = getenv("DEVELOPER_DIR")) {
+  FileSpec fspec(developer_dir_env_var);
+  if (FileSystem::Instance().Exists(fspec))
+g_env_developer_dir = fspec.GetPath();
+}});
+  return g_env_developer_dir;
+}
+
 FileSpec HostInfoMacOSX::GetXcodeContentsDirectory() {
   static FileSpec g_xcode_contents_path;
   static std::once_flag g_once_flag;
@@ -313,16 +326,14 @@
   }
 }
 
-if (const char *developer_dir_env_var = getenv("DEVELOPER_DIR")) {
-  FileSpec fspec(developer_dir_env_var);
-  if (FileSystem::Instance().Exists(fspec)) {
-// FIXME: This looks like it couldn't possibly work!
-std::string xcode_contents_dir =
-XcodeSDK::FindXcodeContentsDirectoryInPath(fspec.GetPath());
-if (!xcode_contents_dir.empty()) {
-  g_xcode_contents_path = FileSpec(xcode_contents_dir);
-  return;
-}
+std::string env_developer_dir = GetEnvDeveloperDir();
+if (!env_developer_dir.empty()) {
+  // FIXME: This looks like it couldn't possibly work!
+  std::string xcode_contents_dir =
+  XcodeSDK::FindXcodeContentsDirectoryInPath(env_developer_dir);
+  if (!xcode_contents_dir.empty()) {
+g_xcode_contents_path = FileSpec(xcode_contents_dir);
+return;
   }
 }
 
@@ -359,8 +370,7 @@
   std::string sdk_name = XcodeSDK::GetCanonicalName(info);
   auto find_sdk = [](std::string sdk_name) -> std::string {
 std::string xcrun_cmd;
-Environment env = Host::GetEnvironment();
-std::string developer_dir = env.lookup("DEVELOPER_DIR");
+std::string developer_dir = GetEnvDeveloperDir();
 if (developer_dir.empty())
   if (FileSpec fspec = HostInfo::GetShlibDir())
 if (FileSystem::Instance().Exists(fspec)) {
___

[Lldb-commits] [lldb] c3f0d9f - [IRExecutionUnit] Early returns for clarity. NFCI.

2020-06-05 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2020-06-05T14:52:36-07:00
New Revision: c3f0d9f3d22d7a3770f2886df9c554e1c277e45a

URL: 
https://github.com/llvm/llvm-project/commit/c3f0d9f3d22d7a3770f2886df9c554e1c277e45a
DIFF: 
https://github.com/llvm/llvm-project/commit/c3f0d9f3d22d7a3770f2886df9c554e1c277e45a.diff

LOG: [IRExecutionUnit] Early returns for clarity. NFCI.

Added: 


Modified: 
lldb/source/Expression/IRExecutionUnit.cpp
lldb/source/Expression/IRInterpreter.cpp

Removed: 




diff  --git a/lldb/source/Expression/IRExecutionUnit.cpp 
b/lldb/source/Expression/IRExecutionUnit.cpp
index 36ac5913abbc..1bcd6aa918e9 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -741,19 +741,22 @@ void IRExecutionUnit::CollectFallbackNames(
   for (const SearchSpec &C_spec : C_specs) {
 ConstString name = C_spec.name;
 
-if (CPlusPlusLanguage::IsCPPMangledName(name.GetCString())) {
-  Mangled mangled_name(name);
-  ConstString demangled_name = mangled_name.GetDemangledName();
-  if (!demangled_name.IsEmpty()) {
-const char *demangled_cstr = demangled_name.AsCString();
-const char *lparen_loc = strchr(demangled_cstr, '(');
-if (lparen_loc) {
-  llvm::StringRef base_name(demangled_cstr,
-lparen_loc - demangled_cstr);
-  fallback_specs.push_back(ConstString(base_name));
-}
-  }
-}
+if (!CPlusPlusLanguage::IsCPPMangledName(name.GetCString()))
+  continue;
+
+Mangled mangled_name(name);
+ConstString demangled_name = mangled_name.GetDemangledName();
+if (demangled_name.IsEmpty())
+  continue;
+
+const char *demangled_cstr = demangled_name.AsCString();
+const char *lparen_loc = strchr(demangled_cstr, '(');
+if (!lparen_loc)
+  continue;
+
+llvm::StringRef base_name(demangled_cstr,
+  lparen_loc - demangled_cstr);
+fallback_specs.push_back(ConstString(base_name));
   }
 }
 

diff  --git a/lldb/source/Expression/IRInterpreter.cpp 
b/lldb/source/Expression/IRInterpreter.cpp
index 0af767116b74..04d7cb3e74b6 100644
--- a/lldb/source/Expression/IRInterpreter.cpp
+++ b/lldb/source/Expression/IRInterpreter.cpp
@@ -173,24 +173,24 @@ class InterpreterStackFrame {
 
   return AssignToMatchType(scalar, value_apint.getLimitedValue(),
value->getType());
-} else {
-  lldb::addr_t process_address = ResolveValue(value, module);
-  size_t value_size = m_target_data.getTypeStoreSize(value->getType());
+}
 
-  lldb_private::DataExtractor value_extractor;
-  lldb_private::Status extract_error;
+lldb::addr_t process_address = ResolveValue(value, module);
+size_t value_size = m_target_data.getTypeStoreSize(value->getType());
 
-  m_execution_unit.GetMemoryData(value_extractor, process_address,
- value_size, extract_error);
+lldb_private::DataExtractor value_extractor;
+lldb_private::Status extract_error;
 
-  if (!extract_error.Success())
-return false;
+m_execution_unit.GetMemoryData(value_extractor, process_address,
+   value_size, extract_error);
 
-  lldb::offset_t offset = 0;
-  if (value_size <= 8) {
-uint64_t u64value = value_extractor.GetMaxU64(&offset, value_size);
-return AssignToMatchType(scalar, u64value, value->getType());
-  }
+if (!extract_error.Success())
+  return false;
+
+lldb::offset_t offset = 0;
+if (value_size <= 8) {
+  uint64_t u64value = value_extractor.GetMaxU64(&offset, value_size);
+  return AssignToMatchType(scalar, u64value, value->getType());
 }
 
 return false;



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [clang] c13dd74 - Set the captures on a CXXRecordDecl representing a lambda closure type

2020-06-05 Thread Richard Smith via lldb-commits
On Thu, 4 Jun 2020 at 23:45, Jonas Devlieghere via cfe-commits <
cfe-comm...@lists.llvm.org> wrote:

> Hey Richard,
>
> It appears this broke the lldb bots:
>
> http://lab.llvm.org:8011/builders/lldb-x86_64-debian
> http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/20549/
>

That's not caused by this NFC commit, it's the one after it. Thanks for the
revert.


> It's hitting an assertion in
> llvm-project/clang/include/clang/AST/DeclCXX.h:887:
>
> Assertion `(data().DefaultedCopyAssignmentIsDeleted ||
> needsOverloadResolutionForCopyAssignment()) && "copy assignment should not
> be deleted"' failed.
>
> I've reverted this commit and the subsequent one
> (c57f8a3a20540fcf9fbf98c0a73f381ec32fce2a) to turn the bots green again
> overnight. Could you please take a look tomorrow?
>

Looks like lldb is doing unusual things with special members when
generating classes directly from debug info. It can't use Sema, so it's
faking up some of what Sema would do, and needed to be extended to also
fake up the new stuff for copy assignments in this patch.

Re-landed with fix in 825e3bb58082eafa8db87a9034379b88f892ce9d.


> Thanks,
> Jonas
>
>
>
> On Thu, Jun 4, 2020 at 7:25 PM Richard Smith via cfe-commits <
> cfe-comm...@lists.llvm.org> wrote:
>
>>
>> Author: Richard Smith
>> Date: 2020-06-04T19:19:01-07:00
>> New Revision: c13dd74e311d2ac70dd3ea663d800307d1aa5b6b
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/c13dd74e311d2ac70dd3ea663d800307d1aa5b6b
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/c13dd74e311d2ac70dd3ea663d800307d1aa5b6b.diff
>>
>> LOG: Set the captures on a CXXRecordDecl representing a lambda closure
>> type
>> before marking it complete.
>>
>> No functionality change intended.
>>
>> Added:
>>
>>
>> Modified:
>> clang/include/clang/AST/DeclCXX.h
>> clang/include/clang/AST/ExprCXX.h
>> clang/lib/AST/ASTImporter.cpp
>> clang/lib/AST/DeclCXX.cpp
>> clang/lib/AST/ExprCXX.cpp
>> clang/lib/Sema/SemaLambda.cpp
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/clang/include/clang/AST/DeclCXX.h
>> b/clang/include/clang/AST/DeclCXX.h
>> index 3a400a778e53..856717fa0abb 100644
>> --- a/clang/include/clang/AST/DeclCXX.h
>> +++ b/clang/include/clang/AST/DeclCXX.h
>> @@ -999,6 +999,9 @@ class CXXRecordDecl : public RecordDecl {
>>  return
>> static_cast(getLambdaData().CaptureDefault);
>>}
>>
>> +  /// Set the captures for this lambda closure type.
>> +  void setCaptures(ArrayRef Captures);
>> +
>>/// For a closure type, retrieve the mapping from captured
>>/// variables and \c this to the non-static data members that store the
>>/// values or references of the captures.
>> @@ -1030,6 +1033,8 @@ class CXXRecordDecl : public RecordDecl {
>>: nullptr;
>>}
>>
>> +  unsigned capture_size() const { return getLambdaData().NumCaptures; }
>> +
>>using conversion_iterator = UnresolvedSetIterator;
>>
>>conversion_iterator conversion_begin() const {
>>
>> diff  --git a/clang/include/clang/AST/ExprCXX.h
>> b/clang/include/clang/AST/ExprCXX.h
>> index 272ad138d14a..56b27d57bd5c 100644
>> --- a/clang/include/clang/AST/ExprCXX.h
>> +++ b/clang/include/clang/AST/ExprCXX.h
>> @@ -1862,10 +1862,9 @@ class LambdaExpr final : public Expr,
>>/// Construct a lambda expression.
>>LambdaExpr(QualType T, SourceRange IntroducerRange,
>>   LambdaCaptureDefault CaptureDefault,
>> - SourceLocation CaptureDefaultLoc, ArrayRef
>> Captures,
>> - bool ExplicitParams, bool ExplicitResultType,
>> - ArrayRef CaptureInits, SourceLocation ClosingBrace,
>> - bool ContainsUnexpandedParameterPack);
>> + SourceLocation CaptureDefaultLoc, bool ExplicitParams,
>> + bool ExplicitResultType, ArrayRef CaptureInits,
>> + SourceLocation ClosingBrace, bool
>> ContainsUnexpandedParameterPack);
>>
>>/// Construct an empty lambda expression.
>>LambdaExpr(EmptyShell Empty, unsigned NumCaptures)
>> @@ -1888,9 +1887,9 @@ class LambdaExpr final : public Expr,
>>static LambdaExpr *
>>Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange
>> IntroducerRange,
>>   LambdaCaptureDefault CaptureDefault, SourceLocation
>> CaptureDefaultLoc,
>> - ArrayRef Captures, bool ExplicitParams,
>> - bool ExplicitResultType, ArrayRef CaptureInits,
>> - SourceLocation ClosingBrace, bool
>> ContainsUnexpandedParameterPack);
>> + bool ExplicitParams, bool ExplicitResultType,
>> + ArrayRef CaptureInits, SourceLocation ClosingBrace,
>> + bool ContainsUnexpandedParameterPack);
>>
>>/// Construct a new lambda expression that will be deserialized from
>>/// an external source.
>>
>> diff  --git a/clang/lib/AST/ASTImporter.cpp
>> b/clang/lib/AST/ASTImporter.cpp
>> index 10035162299e..a2a712e6b6ca 100644
>> --- a/clang/lib/AST/ASTIm

[Lldb-commits] [lldb] 825e3bb - PR46209: properly determine whether a copy assignment operator is

2020-06-05 Thread Richard Smith via lldb-commits

Author: Richard Smith
Date: 2020-06-05T16:05:32-07:00
New Revision: 825e3bb58082eafa8db87a9034379b88f892ce9d

URL: 
https://github.com/llvm/llvm-project/commit/825e3bb58082eafa8db87a9034379b88f892ce9d
DIFF: 
https://github.com/llvm/llvm-project/commit/825e3bb58082eafa8db87a9034379b88f892ce9d.diff

LOG: PR46209: properly determine whether a copy assignment operator is
trivial.

We previously took a shortcut by assuming that if a subobject had a
trivial copy assignment operator (with a few side-conditions), we would
always invoke it, and could avoid going through overload resolution.
That turns out to not be correct in the presenve of ref-qualifiers (and
also won't be the case for copy-assignments with requires-clauses
either). Use the same logic for lazy declaration of copy-assignments
that we use for all other special member functions.

Previously committed as c57f8a3a20540fcf9fbf98c0a73f381ec32fce2a. This
now also includes an extension of LLDB's workaround for handling special
members without the help of Sema to cover copy assignments.

Added: 


Modified: 
clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/AST/ast-dump-decl-context-json.cpp
clang/test/AST/ast-dump-decl.cpp
clang/test/AST/ast-dump-expr-json.cpp
clang/test/AST/ast-dump-record-definition-data-json.cpp
clang/test/AST/ast-dump-records-json.cpp
clang/test/AST/ast-dump-records.cpp
clang/test/AST/ast-dump-special-member-functions.cpp
clang/test/AST/ast-dump-template-decls-json.cpp
clang/test/SemaCXX/type-traits.cpp
clang/test/SemaObjCXX/arc-0x.mm
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def 
b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
index bd4d8247aeca..33e65f8ebf44 100644
--- a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
+++ b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
@@ -140,6 +140,7 @@ FIELD(HasInheritedAssignment, 1, NO_MERGE)
 /// @{
 FIELD(NeedOverloadResolutionForCopyConstructor, 1, NO_MERGE)
 FIELD(NeedOverloadResolutionForMoveConstructor, 1, NO_MERGE)
+FIELD(NeedOverloadResolutionForCopyAssignment, 1, NO_MERGE)
 FIELD(NeedOverloadResolutionForMoveAssignment, 1, NO_MERGE)
 FIELD(NeedOverloadResolutionForDestructor, 1, NO_MERGE)
 /// @}
@@ -149,6 +150,7 @@ FIELD(NeedOverloadResolutionForDestructor, 1, NO_MERGE)
 /// @{
 FIELD(DefaultedCopyConstructorIsDeleted, 1, NO_MERGE)
 FIELD(DefaultedMoveConstructorIsDeleted, 1, NO_MERGE)
+FIELD(DefaultedCopyAssignmentIsDeleted, 1, NO_MERGE)
 FIELD(DefaultedMoveAssignmentIsDeleted, 1, NO_MERGE)
 FIELD(DefaultedDestructorIsDeleted, 1, NO_MERGE)
 /// @}

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 856717fa0abb..2b8d7e879a0a 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -712,6 +712,13 @@ class CXXRecordDecl : public RecordDecl {
!data().DefaultedMoveConstructorIsDeleted;
   }
 
+  /// \c true if we know for sure that this class has a single,
+  /// accessible, unambiguous copy assignment operator that is not deleted.
+  bool hasSimpleCopyAssignment() const {
+return !hasUserDeclaredCopyAssignment() &&
+   !data().DefaultedCopyAssignmentIsDeleted;
+  }
+
   /// \c true if we know for sure that this class has a single,
   /// accessible, unambiguous move assignment operator that is not deleted.
   bool hasSimpleMoveAssignment() const {
@@ -872,6 +879,15 @@ class CXXRecordDecl : public RecordDecl {
 return data().UserDeclaredSpecialMembers & SMF_CopyAssignment;
   }
 
+  /// Set that we attempted to declare an implicit copy assignment
+  /// operator, but overload resolution failed so we deleted it.
+  void setImplicitCopyAssignmentIsDeleted() {
+assert((data().DefaultedCopyAssignmentIsDeleted ||
+needsOverloadResolutionForCopyAssignment()) &&
+   "copy assignment should not be deleted");
+data().DefaultedCopyAssignmentIsDeleted = true;
+  }
+
   /// Determine whether this class needs an implicit copy
   /// assignment operator to be lazily declared.
   bool needsImplicitCopyAssignment() const {
@@ -881,7 +897,16 @@ class CXXRecordDecl : public RecordDecl {
   /// Determine whether we need to eagerly declare a defaulted copy
   /// assignment operator for this class.
   bool needsOverloadResolutionForCopyAssignment() const {
-return data().HasMutableFields;
+// C++20 [class.copy.assign]p2:
+//   If the class definition declares a move constructor or move assignment
+//   operator, the implicitl