[Lldb-commits] [PATCH] D72107: [lldb/CMake] Autodetect Python dependency

2020-01-02 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: lldb/cmake/modules/FindPythonInterpAndLibs.cmake:2
+#.rst:
+# FindPythonInterpndLibs
+# ---

Typo.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72107



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


[Lldb-commits] [lldb] 4117c8c - Revert "[lldb/Command] Add --force option for `watchpoint delete` command"

2020-01-02 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2020-01-03T02:14:45+01:00
New Revision: 4117c8c0194cdf59e229f6826e0908eb3f2bcfc6

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

LOG: Revert "[lldb/Command] Add --force option for `watchpoint delete` command"

This reverts commit 3620e5f28a4d2800fb6c325ec24b3d660e48b9ba.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
lldb/source/Commands/CommandObjectWatchpoint.cpp
lldb/source/Commands/Options.td

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
 
b/lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
index e92af6dc9c6e..27c332b68bb4 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
@@ -155,56 +155,6 @@ def test_rw_watchpoint_delete(self):
 self.expect("process status",
 substrs=['exited'])
 
-# Read-write watchpoints not supported on SystemZ
-@expectedFailureAll(archs=['s390x'])
-def test_rw_watchpoint_delete(self):
-"""Test delete watchpoint and expect not to stop for watchpoint."""
-self.build(dictionary=self.d)
-self.setTearDownCleanup(dictionary=self.d)
-
-exe = self.getBuildArtifact(self.exe_name)
-self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
-
-# Add a breakpoint to set a watchpoint when stopped on the breakpoint.
-lldbutil.run_break_set_by_file_and_line(
-self, None, self.line, num_expected_locations=1)
-
-# Run the program.
-self.runCmd("run", RUN_SUCCEEDED)
-
-# We should be stopped again due to the breakpoint.
-# The stop reason of the thread should be breakpoint.
-self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
-substrs=['stopped',
- 'stop reason = breakpoint'])
-
-# Now let's set a read_write-type watchpoint for 'global'.
-# There should be two watchpoint hits (see main.c).
-self.expect(
-"watchpoint set variable -w read_write global",
-WATCHPOINT_CREATED,
-substrs=[
-'Watchpoint created',
-'size = 4',
-'type = rw',
-'%s:%d' %
-(self.source,
- self.decl)])
-
-# Delete the watchpoint immediately using the force option.
-self.expect("watchpoint delete --force",
-substrs=['All watchpoints removed.'])
-
-# Use the '-v' option to do verbose listing of the watchpoint.
-self.runCmd("watchpoint list -v")
-
-self.runCmd("process continue")
-
-# There should be no more watchpoint hit and the process status should
-# be 'exited'.
-self.expect("process status",
-substrs=['exited'])
-
 # Read-write watchpoints not supported on SystemZ
 @expectedFailureAll(archs=['s390x'])
 def test_rw_watchpoint_set_ignore_count(self):

diff  --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp 
b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index c965d354f734..1b1d59740c86 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -414,10 +414,6 @@ class CommandObjectWatchpointDisable : public 
CommandObjectParsed {
   }
 };
 
-// CommandObjectWatchpointDelete
-#define LLDB_OPTIONS_watchpoint_delete
-#include "CommandOptions.inc"
-
 // CommandObjectWatchpointDelete
 #pragma mark Delete
 
@@ -427,8 +423,7 @@ class CommandObjectWatchpointDelete : public 
CommandObjectParsed {
   : CommandObjectParsed(interpreter, "watchpoint delete",
 "Delete the specified watchpoint(s).  If no "
 "watchpoints are specified, delete them all.",
-nullptr, eCommandRequiresTarget),
-m_options() {
+nullptr, eCommandRequiresTarget) {
 CommandArgumentEntry arg;
 CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID,
   eArgTypeWatchpointIDRange);
@@ -439,41 +434,6 @@ class CommandObjectWatchpointDelete : public 
CommandObjectParsed {
 
   ~CommandObjectWatchpointDelete() override = default;
 
-  Options *GetOptions() override { return _options; }
-
-  class CommandOptions : public Options {
-  public:
-CommandOptions() : Options(), m_force(false) {}
-
-~CommandOptions() 

[Lldb-commits] [lldb] d265c8b - [lldb/Python] Remove unused imports (NFC)

2020-01-02 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-02T16:55:09-08:00
New Revision: d265c8bf0d1e6eed3c97dfb96f98712e5adc8bf7

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

LOG: [lldb/Python] Remove unused imports (NFC)

Added: 


Modified: 
lldb/packages/Python/lldbsuite/support/funcutils.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/support/funcutils.py 
b/lldb/packages/Python/lldbsuite/support/funcutils.py
index 2fa10097d43b..648d95d23d97 100644
--- a/lldb/packages/Python/lldbsuite/support/funcutils.py
+++ b/lldb/packages/Python/lldbsuite/support/funcutils.py
@@ -1,14 +1,5 @@
-from __future__ import print_function
-from __future__ import absolute_import
-
-# System modules
 import inspect
 
-# Third-party modules
-
-# LLDB modules
-
-
 def requires_self(func):
 func_argc = len(inspect.getargspec(func).args)
 if func_argc == 0 or (



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


[Lldb-commits] [lldb] 8580397 - [lldb/Python] Remove unused support file (NFC)

2020-01-02 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-02T16:55:09-08:00
New Revision: 8580397f2e7d389940fbdd5575f26271df743aee

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

LOG: [lldb/Python] Remove unused support file (NFC)

Added: 


Modified: 


Removed: 
lldb/packages/Python/lldbsuite/support/optional_with.py



diff  --git a/lldb/packages/Python/lldbsuite/support/optional_with.py 
b/lldb/packages/Python/lldbsuite/support/optional_with.py
deleted file mode 100644
index f91b3c6fdeb6..
--- a/lldb/packages/Python/lldbsuite/support/optional_with.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# 
-# Provides a with-style resource handler for optionally-None resources
-# 
-
-
-class optional_with(object):
-# pylint: disable=too-few-public-methods
-# This is a wrapper - it is not meant to provide any extra methods.
-"""Provides a wrapper for objects supporting "with", allowing None.
-
-This lets a user use the "with object" syntax for resource usage
-(e.g. locks) even when the wrapped with object is None.
-
-e.g.
-
-wrapped_lock = optional_with(thread.Lock())
-with wrapped_lock:
-# Do something while the lock is obtained.
-pass
-
-might_be_none = None
-wrapped_none = optional_with(might_be_none)
-with wrapped_none:
-# This code here still works.
-pass
-
-This prevents having to write code like this when
-a lock is optional:
-
-if lock:
-lock.acquire()
-
-try:
-code_fragment_always_run()
-finally:
-if lock:
-lock.release()
-
-And I'd posit it is safer, as it becomes impossible to
-forget the try/finally using optional_with(), since
-the with syntax can be used.
-"""
-
-def __init__(self, wrapped_object):
-self.wrapped_object = wrapped_object
-
-def __enter__(self):
-if self.wrapped_object is not None:
-return self.wrapped_object.__enter__()
-else:
-return self
-
-def __exit__(self, the_type, value, traceback):
-if self.wrapped_object is not None:
-return self.wrapped_object.__exit__(the_type, value, traceback)
-else:
-# Don't suppress any exceptions
-return False



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


[Lldb-commits] [lldb] 3620e5f - [lldb/Command] Add --force option for `watchpoint delete` command

2020-01-02 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2020-01-03T01:51:22+01:00
New Revision: 3620e5f28a4d2800fb6c325ec24b3d660e48b9ba

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

LOG: [lldb/Command] Add --force option for `watchpoint delete` command

Currently, there is no option to delete all the watchpoint without LLDB
asking for a confirmation. Besides making the watchpoint delete command
homogeneous with the breakpoint delete command, this option could also
become handy to trigger automated watchpoint deletion i.e. using
breakpoint actions.

rdar://42560586

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
lldb/source/Commands/CommandObjectWatchpoint.cpp
lldb/source/Commands/Options.td

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
 
b/lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
index 27c332b68bb4..e92af6dc9c6e 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
@@ -155,6 +155,56 @@ def test_rw_watchpoint_delete(self):
 self.expect("process status",
 substrs=['exited'])
 
+# Read-write watchpoints not supported on SystemZ
+@expectedFailureAll(archs=['s390x'])
+def test_rw_watchpoint_delete(self):
+"""Test delete watchpoint and expect not to stop for watchpoint."""
+self.build(dictionary=self.d)
+self.setTearDownCleanup(dictionary=self.d)
+
+exe = self.getBuildArtifact(self.exe_name)
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+# Add a breakpoint to set a watchpoint when stopped on the breakpoint.
+lldbutil.run_break_set_by_file_and_line(
+self, None, self.line, num_expected_locations=1)
+
+# Run the program.
+self.runCmd("run", RUN_SUCCEEDED)
+
+# We should be stopped again due to the breakpoint.
+# The stop reason of the thread should be breakpoint.
+self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+# Now let's set a read_write-type watchpoint for 'global'.
+# There should be two watchpoint hits (see main.c).
+self.expect(
+"watchpoint set variable -w read_write global",
+WATCHPOINT_CREATED,
+substrs=[
+'Watchpoint created',
+'size = 4',
+'type = rw',
+'%s:%d' %
+(self.source,
+ self.decl)])
+
+# Delete the watchpoint immediately using the force option.
+self.expect("watchpoint delete --force",
+substrs=['All watchpoints removed.'])
+
+# Use the '-v' option to do verbose listing of the watchpoint.
+self.runCmd("watchpoint list -v")
+
+self.runCmd("process continue")
+
+# There should be no more watchpoint hit and the process status should
+# be 'exited'.
+self.expect("process status",
+substrs=['exited'])
+
 # Read-write watchpoints not supported on SystemZ
 @expectedFailureAll(archs=['s390x'])
 def test_rw_watchpoint_set_ignore_count(self):

diff  --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp 
b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index 1b1d59740c86..c965d354f734 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -414,6 +414,10 @@ class CommandObjectWatchpointDisable : public 
CommandObjectParsed {
   }
 };
 
+// CommandObjectWatchpointDelete
+#define LLDB_OPTIONS_watchpoint_delete
+#include "CommandOptions.inc"
+
 // CommandObjectWatchpointDelete
 #pragma mark Delete
 
@@ -423,7 +427,8 @@ class CommandObjectWatchpointDelete : public 
CommandObjectParsed {
   : CommandObjectParsed(interpreter, "watchpoint delete",
 "Delete the specified watchpoint(s).  If no "
 "watchpoints are specified, delete them all.",
-nullptr, eCommandRequiresTarget) {
+nullptr, eCommandRequiresTarget),
+m_options() {
 CommandArgumentEntry arg;
 CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID,
   eArgTypeWatchpointIDRange);
@@ -434,6 +439,41 @@ class CommandObjectWatchpointDelete : 

Re: [Lldb-commits] [lldb] 8612e92 - [lldb][NFC] Remove GetASTContext call in ClangDeclVendor

2020-01-02 Thread Shafik Yaghmour via lldb-commits
To further clarify all the member functions of CompilerDecl e.g.:

GetMangledName(…)
GetDeclContext(…)

End up passing m_opaque_decl as an argument to a member function of 
m_type_system and in these member functions they unconditionally cast the 
argument to Decl* so why not make m_opaque_decl a Decl*

> On Jan 2, 2020, at 4:20 PM, Shafik Yaghmour via lldb-commits 
>  wrote:
> 
> Apologies, m_opaque_decl member of CompilerDecl and operator < in 
> CompilerDecl.h 
> 
>> On Jan 2, 2020, at 3:54 PM, Raphael “Teemperor” Isemann 
>>  wrote:
>> 
>> Not sure if I can follow. What variable should just be a Decl* and what 
>> operator> 
>> (Also yeah that reinterpret_cast could also be a static_cast)
>> 
>>> On Jan 3, 2020, at 12:38 AM, Shafik Yaghmour  wrote:
>>> 
>>> I am not crazy about the reinterpret_cast although if we look inside 
>>> CompilerDecl impl we can see that basically it is always assuming it is a 
>>> Decl* and just C-style casts it as such. So why not just make it a Decl*
>>> 
>>> Also operator<(…) is super sketchy doing a < on void* 
>>> 
 On Dec 28, 2019, at 6:52 AM, Raphael Isemann via lldb-commits 
  wrote:
 
 
 Author: Raphael Isemann
 Date: 2019-12-28T15:20:19+01:00
 New Revision: 8612e92ed590e615f9f56e4fb86a1fdaf3a39e15
 
 URL: 
 https://github.com/llvm/llvm-project/commit/8612e92ed590e615f9f56e4fb86a1fdaf3a39e15
 DIFF: 
 https://github.com/llvm/llvm-project/commit/8612e92ed590e615f9f56e4fb86a1fdaf3a39e15.diff
 
 LOG: [lldb][NFC] Remove GetASTContext call in ClangDeclVendor
 
 Instead of returning NamedDecls and then calling GetASTContext
 to find back the ClangASTContext we used can just implement the
 FindDecl variant that returns CompilerDecls (and implement the
 other function by throwing away the ClangASTContext part of the
 compiler decl).
 
 Added: 
 
 
 Modified: 
 lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
 lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
 lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
 lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
 lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
 
 Removed: 
 
 
 
 
 diff  --git 
 a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp 
 b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
 index c59722b7b4f8..0c5796650d45 100644
 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
 +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
 @@ -15,16 +15,17 @@ using namespace lldb_private;
 
 uint32_t ClangDeclVendor::FindDecls(ConstString name, bool append,
  uint32_t max_matches,
 -std::vector ) {
 +std::vector 
 ) {
 if (!append)
  decls.clear();
 
 -  std::vector named_decls;
 -  uint32_t ret = FindDecls(name, /*append*/ false, max_matches, 
 named_decls);
 -  for (auto *named_decl : named_decls) {
 -decls.push_back(CompilerDecl(
 -ClangASTContext::GetASTContext(_decl->getASTContext()),
 -named_decl));
 +  std::vector compiler_decls;
 +  uint32_t ret = FindDecls(name, /*append*/ false, max_matches, 
 compiler_decls);
 +  for (CompilerDecl compiler_decl : compiler_decls) {
 +clang::Decl *d =
 +reinterpret_cast(compiler_decl.GetOpaqueDecl());
 +clang::NamedDecl *nd = llvm::cast(d);
 +decls.push_back(nd);
 }
 return ret;
 }
 
 diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h 
 b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
 index 85a10400a201..0c888de08841 100644
 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
 +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
 @@ -21,12 +21,10 @@ class ClangDeclVendor : public DeclVendor {
 
 virtual ~ClangDeclVendor() {}
 
 -  uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
 - std::vector ) override;
 +  using DeclVendor::FindDecls;
 
 -  virtual uint32_t FindDecls(ConstString name, bool append,
 - uint32_t max_matches,
 - std::vector ) = 0;
 +  uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
 + std::vector );
 
 static bool classof(const DeclVendor *vendor) {
  return vendor->GetKind() >= eClangDeclVendor &&
 
 diff  --git 
 a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
 

Re: [Lldb-commits] [lldb] 8612e92 - [lldb][NFC] Remove GetASTContext call in ClangDeclVendor

2020-01-02 Thread Shafik Yaghmour via lldb-commits
Apologies, m_opaque_decl member of CompilerDecl and operator < in 
CompilerDecl.h 

> On Jan 2, 2020, at 3:54 PM, Raphael “Teemperor” Isemann  
> wrote:
> 
> Not sure if I can follow. What variable should just be a Decl* and what 
> operator 
> (Also yeah that reinterpret_cast could also be a static_cast)
> 
>> On Jan 3, 2020, at 12:38 AM, Shafik Yaghmour  wrote:
>> 
>> I am not crazy about the reinterpret_cast although if we look inside 
>> CompilerDecl impl we can see that basically it is always assuming it is a 
>> Decl* and just C-style casts it as such. So why not just make it a Decl*
>> 
>> Also operator<(…) is super sketchy doing a < on void* 
>> 
>>> On Dec 28, 2019, at 6:52 AM, Raphael Isemann via lldb-commits 
>>>  wrote:
>>> 
>>> 
>>> Author: Raphael Isemann
>>> Date: 2019-12-28T15:20:19+01:00
>>> New Revision: 8612e92ed590e615f9f56e4fb86a1fdaf3a39e15
>>> 
>>> URL: 
>>> https://github.com/llvm/llvm-project/commit/8612e92ed590e615f9f56e4fb86a1fdaf3a39e15
>>> DIFF: 
>>> https://github.com/llvm/llvm-project/commit/8612e92ed590e615f9f56e4fb86a1fdaf3a39e15.diff
>>> 
>>> LOG: [lldb][NFC] Remove GetASTContext call in ClangDeclVendor
>>> 
>>> Instead of returning NamedDecls and then calling GetASTContext
>>> to find back the ClangASTContext we used can just implement the
>>> FindDecl variant that returns CompilerDecls (and implement the
>>> other function by throwing away the ClangASTContext part of the
>>> compiler decl).
>>> 
>>> Added: 
>>> 
>>> 
>>> Modified: 
>>>  lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
>>>  lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
>>>  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
>>>  
>>> lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
>>>  
>>> lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
>>> 
>>> Removed: 
>>> 
>>> 
>>> 
>>> 
>>> diff  --git 
>>> a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp 
>>> b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
>>> index c59722b7b4f8..0c5796650d45 100644
>>> --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
>>> +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
>>> @@ -15,16 +15,17 @@ using namespace lldb_private;
>>> 
>>> uint32_t ClangDeclVendor::FindDecls(ConstString name, bool append,
>>>   uint32_t max_matches,
>>> -std::vector ) {
>>> +std::vector 
>>> ) {
>>> if (!append)
>>>   decls.clear();
>>> 
>>> -  std::vector named_decls;
>>> -  uint32_t ret = FindDecls(name, /*append*/ false, max_matches, 
>>> named_decls);
>>> -  for (auto *named_decl : named_decls) {
>>> -decls.push_back(CompilerDecl(
>>> -ClangASTContext::GetASTContext(_decl->getASTContext()),
>>> -named_decl));
>>> +  std::vector compiler_decls;
>>> +  uint32_t ret = FindDecls(name, /*append*/ false, max_matches, 
>>> compiler_decls);
>>> +  for (CompilerDecl compiler_decl : compiler_decls) {
>>> +clang::Decl *d =
>>> +reinterpret_cast(compiler_decl.GetOpaqueDecl());
>>> +clang::NamedDecl *nd = llvm::cast(d);
>>> +decls.push_back(nd);
>>> }
>>> return ret;
>>> }
>>> 
>>> diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h 
>>> b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
>>> index 85a10400a201..0c888de08841 100644
>>> --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
>>> +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
>>> @@ -21,12 +21,10 @@ class ClangDeclVendor : public DeclVendor {
>>> 
>>> virtual ~ClangDeclVendor() {}
>>> 
>>> -  uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
>>> - std::vector ) override;
>>> +  using DeclVendor::FindDecls;
>>> 
>>> -  virtual uint32_t FindDecls(ConstString name, bool append,
>>> - uint32_t max_matches,
>>> - std::vector ) = 0;
>>> +  uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
>>> + std::vector );
>>> 
>>> static bool classof(const DeclVendor *vendor) {
>>>   return vendor->GetKind() >= eClangDeclVendor &&
>>> 
>>> diff  --git 
>>> a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
>>> b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
>>> index ff0905dda4ef..0696c669f2e2 100644
>>> --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
>>> +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
>>> @@ -80,7 +80,7 @@ class ClangModulesDeclVendorImpl : public 
>>> ClangModulesDeclVendor {
>>>   Stream _stream) override;
>>> 
>>> uint32_t FindDecls(ConstString name, bool append, 

Re: [Lldb-commits] [lldb] 8612e92 - [lldb][NFC] Remove GetASTContext call in ClangDeclVendor

2020-01-02 Thread Raphael “Teemperor” Isemann via lldb-commits
Not sure if I can follow. What variable should just be a Decl* and what 
operator On Jan 3, 2020, at 12:38 AM, Shafik Yaghmour  wrote:
> 
> I am not crazy about the reinterpret_cast although if we look inside 
> CompilerDecl impl we can see that basically it is always assuming it is a 
> Decl* and just C-style casts it as such. So why not just make it a Decl*
> 
> Also operator<(…) is super sketchy doing a < on void* 
> 
>> On Dec 28, 2019, at 6:52 AM, Raphael Isemann via lldb-commits 
>>  wrote:
>> 
>> 
>> Author: Raphael Isemann
>> Date: 2019-12-28T15:20:19+01:00
>> New Revision: 8612e92ed590e615f9f56e4fb86a1fdaf3a39e15
>> 
>> URL: 
>> https://github.com/llvm/llvm-project/commit/8612e92ed590e615f9f56e4fb86a1fdaf3a39e15
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/8612e92ed590e615f9f56e4fb86a1fdaf3a39e15.diff
>> 
>> LOG: [lldb][NFC] Remove GetASTContext call in ClangDeclVendor
>> 
>> Instead of returning NamedDecls and then calling GetASTContext
>> to find back the ClangASTContext we used can just implement the
>> FindDecl variant that returns CompilerDecls (and implement the
>> other function by throwing away the ClangASTContext part of the
>> compiler decl).
>> 
>> Added: 
>> 
>> 
>> Modified: 
>>   lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
>>   lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
>>   lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
>>   
>> lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
>>   
>> lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
>> 
>> Removed: 
>> 
>> 
>> 
>> 
>> diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp 
>> b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
>> index c59722b7b4f8..0c5796650d45 100644
>> --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
>> +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
>> @@ -15,16 +15,17 @@ using namespace lldb_private;
>> 
>> uint32_t ClangDeclVendor::FindDecls(ConstString name, bool append,
>>uint32_t max_matches,
>> -std::vector ) {
>> +std::vector ) 
>> {
>>  if (!append)
>>decls.clear();
>> 
>> -  std::vector named_decls;
>> -  uint32_t ret = FindDecls(name, /*append*/ false, max_matches, 
>> named_decls);
>> -  for (auto *named_decl : named_decls) {
>> -decls.push_back(CompilerDecl(
>> -ClangASTContext::GetASTContext(_decl->getASTContext()),
>> -named_decl));
>> +  std::vector compiler_decls;
>> +  uint32_t ret = FindDecls(name, /*append*/ false, max_matches, 
>> compiler_decls);
>> +  for (CompilerDecl compiler_decl : compiler_decls) {
>> +clang::Decl *d =
>> +reinterpret_cast(compiler_decl.GetOpaqueDecl());
>> +clang::NamedDecl *nd = llvm::cast(d);
>> +decls.push_back(nd);
>>  }
>>  return ret;
>> }
>> 
>> diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h 
>> b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
>> index 85a10400a201..0c888de08841 100644
>> --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
>> +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
>> @@ -21,12 +21,10 @@ class ClangDeclVendor : public DeclVendor {
>> 
>>  virtual ~ClangDeclVendor() {}
>> 
>> -  uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
>> - std::vector ) override;
>> +  using DeclVendor::FindDecls;
>> 
>> -  virtual uint32_t FindDecls(ConstString name, bool append,
>> - uint32_t max_matches,
>> - std::vector ) = 0;
>> +  uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
>> + std::vector );
>> 
>>  static bool classof(const DeclVendor *vendor) {
>>return vendor->GetKind() >= eClangDeclVendor &&
>> 
>> diff  --git 
>> a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
>> b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
>> index ff0905dda4ef..0696c669f2e2 100644
>> --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
>> +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
>> @@ -80,7 +80,7 @@ class ClangModulesDeclVendorImpl : public 
>> ClangModulesDeclVendor {
>>Stream _stream) override;
>> 
>>  uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
>> - std::vector ) override;
>> + std::vector ) override;
>> 
>>  void ForEachMacro(const ModuleVector ,
>>std::function handler) 
>> override;
>> @@ -356,7 +356,7 @@ bool 
>> ClangModulesDeclVendorImpl::AddModulesForCompileUnit(
>> uint32_t
>> 

Re: [Lldb-commits] [lldb] 8612e92 - [lldb][NFC] Remove GetASTContext call in ClangDeclVendor

2020-01-02 Thread Shafik Yaghmour via lldb-commits
I am not crazy about the reinterpret_cast although if we look inside 
CompilerDecl impl we can see that basically it is always assuming it is a Decl* 
and just C-style casts it as such. So why not just make it a Decl*

Also operator<(…) is super sketchy doing a < on void* 

> On Dec 28, 2019, at 6:52 AM, Raphael Isemann via lldb-commits 
>  wrote:
> 
> 
> Author: Raphael Isemann
> Date: 2019-12-28T15:20:19+01:00
> New Revision: 8612e92ed590e615f9f56e4fb86a1fdaf3a39e15
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/8612e92ed590e615f9f56e4fb86a1fdaf3a39e15
> DIFF: 
> https://github.com/llvm/llvm-project/commit/8612e92ed590e615f9f56e4fb86a1fdaf3a39e15.diff
> 
> LOG: [lldb][NFC] Remove GetASTContext call in ClangDeclVendor
> 
> Instead of returning NamedDecls and then calling GetASTContext
> to find back the ClangASTContext we used can just implement the
> FindDecl variant that returns CompilerDecls (and implement the
> other function by throwing away the ClangASTContext part of the
> compiler decl).
> 
> Added: 
> 
> 
> Modified: 
>lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
>lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
>lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
>
> lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
>
> lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp 
> b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
> index c59722b7b4f8..0c5796650d45 100644
> --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
> +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
> @@ -15,16 +15,17 @@ using namespace lldb_private;
> 
> uint32_t ClangDeclVendor::FindDecls(ConstString name, bool append,
> uint32_t max_matches,
> -std::vector ) {
> +std::vector ) {
>   if (!append)
> decls.clear();
> 
> -  std::vector named_decls;
> -  uint32_t ret = FindDecls(name, /*append*/ false, max_matches, named_decls);
> -  for (auto *named_decl : named_decls) {
> -decls.push_back(CompilerDecl(
> -ClangASTContext::GetASTContext(_decl->getASTContext()),
> -named_decl));
> +  std::vector compiler_decls;
> +  uint32_t ret = FindDecls(name, /*append*/ false, max_matches, 
> compiler_decls);
> +  for (CompilerDecl compiler_decl : compiler_decls) {
> +clang::Decl *d =
> +reinterpret_cast(compiler_decl.GetOpaqueDecl());
> +clang::NamedDecl *nd = llvm::cast(d);
> +decls.push_back(nd);
>   }
>   return ret;
> }
> 
> diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h 
> b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
> index 85a10400a201..0c888de08841 100644
> --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
> +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
> @@ -21,12 +21,10 @@ class ClangDeclVendor : public DeclVendor {
> 
>   virtual ~ClangDeclVendor() {}
> 
> -  uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
> - std::vector ) override;
> +  using DeclVendor::FindDecls;
> 
> -  virtual uint32_t FindDecls(ConstString name, bool append,
> - uint32_t max_matches,
> - std::vector ) = 0;
> +  uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
> + std::vector );
> 
>   static bool classof(const DeclVendor *vendor) {
> return vendor->GetKind() >= eClangDeclVendor &&
> 
> diff  --git 
> a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
> b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
> index ff0905dda4ef..0696c669f2e2 100644
> --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
> +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
> @@ -80,7 +80,7 @@ class ClangModulesDeclVendorImpl : public 
> ClangModulesDeclVendor {
> Stream _stream) override;
> 
>   uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
> - std::vector ) override;
> + std::vector ) override;
> 
>   void ForEachMacro(const ModuleVector ,
> std::function handler) 
> override;
> @@ -356,7 +356,7 @@ bool ClangModulesDeclVendorImpl::AddModulesForCompileUnit(
> uint32_t
> ClangModulesDeclVendorImpl::FindDecls(ConstString name, bool append,
>   uint32_t max_matches,
> -  std::vector 
> ) {
> +  std::vector ) {
>   if 

[Lldb-commits] [PATCH] D72107: [lldb/CMake] Autodetect Python dependency

2020-01-02 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D72107#1802048 , @xiaobai wrote:

> In D72107#1802029 , @JDevlieghere 
> wrote:
>
> > Do you mean forcing `LLDB_ENABLE_PYTHON` to on so that it fails in case the 
> > logic changes and Python isn't found?
>
>
> Yes, something like that. It looks like the previous expected behavior was 
> that python was implicitly a required dependency (unless you explicitly 
> disabled it or were building for android/ios). Making it an optional 
> dependency means that the buildbots should probably explicitly say that they 
> want to enable python. You could probably not change buildbot invocations, 
> but that means that if a buildbot fails to find python then we won't know 
> until something goes wrong (e.g. A test fails locally on some setup that 
> passed buildbots because buildbots weren't running python tests).


Yup, I've updated the config in 9a3d9b7f 



Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72107



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


[Lldb-commits] [PATCH] D70764: build: reduce CMake handling for zlib

2020-01-02 Thread Saleem Abdulrasool via Phabricator via lldb-commits
compnerd closed this revision.
compnerd added a comment.

GIT 68a235d07f9 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70764



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


[Lldb-commits] [PATCH] D71857: [NFC] Fixes -Wrange-loop-analysis warnings

2020-01-02 Thread Mark de Wever via Phabricator via lldb-commits
Mordante added a comment.

In D71857#1800663 , @MaskRay wrote:

> However, I am afraid I don't like some of the fixes here. You can replace 
> `const auto` with `const auto &` and call that a fix... IMHO if the type is 
> not obvious, `const ConcreteType &` will be better.


I notice some parts of the code prefer `auto` and others `ConcreteType`, so 
there is no consensus on what is the best. I feel with this change I want to 
change as little as possible.

> I think there is a false positive.
> 
> https://github.com/llvm/llvm-project/tree/master/lld/ELF/Relocations.cpp#L1622
> 
>   for (const std::pair ts : isd->thunkSections)
>
> 
> Diagnostic:
> 
>   lld/ELF/Relocations.cpp:1622:14: note: use reference type 'const 
> std::pair &' (aka 'const 
> pair &') to prevent copying
>   for (const std::pair ts : 
> isd->thunkSections)
>   
> 
> 
> i.e. The diagnostic asks me to replace `const std::pair` with 
> `const std::pair &`, when it is clear that the type is cheap to 
> copy.

The code has a 'protection' for this case `clang/lib/Sema/SemaStmt.cpp:2803`:

  // TODO: Determine a maximum size that a POD type can be before a diagnostic
  // should be emitted.  Also, only ignore POD types with trivial copy
  // constructors.
  if (VariableType.isPODType(SemaRef.Context))
return;

I could change this protection to test whether the type is trivially copyable 
which will reduce the number of warnings. Unfortunately std::pair is not 
trivially copyable so that won't help here. Do you think it makes sense to 
allow trivially copyable types instead of POD types? Any suggestion how we 
could solve it for std::pair?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71857



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


[Lldb-commits] [PATCH] D70644: [DebugInfo] Support for DW_OP_implicit_pointer (llvm.dbg_derefval)

2020-01-02 Thread Alok Kumar Sharma via Phabricator via lldb-commits
alok updated this revision to Diff 235919.
alok added a comment.

Rebased and updated.


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

https://reviews.llvm.org/D70644

Files:
  lldb/source/Expression/IRInterpreter.cpp
  llvm/docs/SourceLevelDebugging.rst
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
  llvm/include/llvm/CodeGen/MachineInstr.h
  llvm/include/llvm/CodeGen/MachineInstrBuilder.h
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/InstVisitor.h
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Analysis/MemorySSA.cpp
  llvm/lib/Analysis/ObjCARCInstKind.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
  llvm/lib/CodeGen/LiveDebugValues.cpp
  llvm/lib/CodeGen/MachineInstr.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  polly/lib/Support/ScopHelper.cpp

Index: polly/lib/Support/ScopHelper.cpp
===
--- polly/lib/Support/ScopHelper.cpp
+++ polly/lib/Support/ScopHelper.cpp
@@ -624,6 +624,7 @@
 case llvm::Intrinsic::assume:
 // Some debug info intrinsics are supported/ignored.
 case llvm::Intrinsic::dbg_value:
+case llvm::Intrinsic::dbg_derefval:
 case llvm::Intrinsic::dbg_declare:
   return true;
 default:
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -4010,6 +4010,7 @@
 switch (IntrinsicID) {
 case Intrinsic::dbg_declare:
 case Intrinsic::dbg_value:
+case Intrinsic::dbg_derefval:
 case Intrinsic::dbg_label:
 case Intrinsic::lifetime_end:
   break;
Index: llvm/lib/Transforms/Utils/Local.cpp
===
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -385,6 +385,11 @@
   return false;
 return true;
   }
+  if (DbgDerefValueInst *DVI = dyn_cast(I)) {
+if (DVI->getDerefVariable())
+  return false;
+return true;
+  }
   if (DbgLabelInst *DLI = dyn_cast(I)) {
 if (DLI->getLabel())
   return false;
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -4322,6 +4322,9 @@
   case Intrinsic::dbg_value: // llvm.dbg.value
 visitDbgIntrinsic("value", cast(Call));
 break;
+  case Intrinsic::dbg_derefval: // llvm.dbg.derefval
+visitDbgIntrinsic("derefval", cast(Call));
+break;
   case Intrinsic::dbg_label: // llvm.dbg.label
 visitDbgLabelIntrinsic("label", cast(Call));
 break;
@@ -4877,8 +4880,9 @@
 void Verifier::visitDbgIntrinsic(StringRef Kind, DbgVariableIntrinsic ) {
   auto *MD = cast(DII.getArgOperand(0))->getMetadata();
   AssertDI(isa(MD) ||
- (isa(MD) && !cast(MD)->getNumOperands()),
- "invalid llvm.dbg." + Kind + " intrinsic address/value", , MD);
+   (isa(MD) && !cast(MD)->getNumOperands()) ||
+   isa(DII),
+   "invalid llvm.dbg." + Kind + " intrinsic address/value", , MD);
   AssertDI(isa(DII.getRawVariable()),
  "invalid llvm.dbg." + Kind + " intrinsic variable", ,
  DII.getRawVariable());
Index: llvm/lib/IR/IntrinsicInst.cpp
===
--- llvm/lib/IR/IntrinsicInst.cpp
+++ llvm/lib/IR/IntrinsicInst.cpp
@@ -50,6 +50,14 @@
   return nullptr;
 }
 
+Value *DbgVariableIntrinsic::getDerefVariable(bool AllowNullOp) const {
+  Value *Op = getArgOperand(0);
+  if (AllowNullOp && !Op)
+return nullptr;
+
+  return Op;
+}
+
 Optional DbgVariableIntrinsic::getFragmentSizeInBits() const {
   if (auto Fragment = getExpression()->getFragmentInfo())
 return Fragment->SizeInBits;
Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -33,7 +33,7 @@
 
 DIBuilder::DIBuilder(Module , bool AllowUnresolvedNodes, DICompileUnit *CU)
   : M(m), VMContext(M.getContext()), CUNode(CU),
-  DeclareFn(nullptr), ValueFn(nullptr), LabelFn(nullptr),
+  DeclareFn(nullptr), ValueFn(nullptr), DerefvalFn(nullptr), LabelFn(nullptr),
   AllowUnresolvedNodes(AllowUnresolvedNodes) {}
 
 void DIBuilder::trackIfUnresolved(MDNode *N) {
@@ -887,6 +887,22 @@
   InsertBefore);
 }
 
+Instruction *DIBuilder::insertDbgDerefValueIntrinsic(
+Value *V, DILocalVariable *VarInfo, DIExpression *Expr,
+const DILocation *DL, Instruction 

[Lldb-commits] [PATCH] D71857: [NFC] Fixes -Wrange-loop-analysis warnings

2020-01-02 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

I really like the new feature. Thanks for making the efforts!

However, I am afraid I don't like some of the fixes here. You can replace 
`const auto` with `const auto &` and call that a fix... IMHO if the type is not 
obvious, `const ConcreteType &` will be better.

In addition, I think there are some false positives, e.g. the diagnostic may 
ask me to replace `const std::pair` with `const std::pair &` when it is clear that the type is trivial and cheap to copy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71857



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


[Lldb-commits] [PATCH] D70644: [DebugInfo] Support for DW_OP_implicit_pointer (llvm.dbg_derefval)

2020-01-02 Thread Alok Kumar Sharma via Phabricator via lldb-commits
alok updated this revision to Diff 235772.
alok added a comment.

Update to re-base and minor correction.


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

https://reviews.llvm.org/D70644

Files:
  lldb/source/Expression/IRInterpreter.cpp
  llvm/docs/SourceLevelDebugging.rst
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
  llvm/include/llvm/CodeGen/MachineInstr.h
  llvm/include/llvm/CodeGen/MachineInstrBuilder.h
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/InstVisitor.h
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Analysis/MemorySSA.cpp
  llvm/lib/Analysis/ObjCARCInstKind.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
  llvm/lib/CodeGen/LiveDebugValues.cpp
  llvm/lib/CodeGen/MachineInstr.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  polly/lib/Support/ScopHelper.cpp

Index: polly/lib/Support/ScopHelper.cpp
===
--- polly/lib/Support/ScopHelper.cpp
+++ polly/lib/Support/ScopHelper.cpp
@@ -624,6 +624,7 @@
 case llvm::Intrinsic::assume:
 // Some debug info intrinsics are supported/ignored.
 case llvm::Intrinsic::dbg_value:
+case llvm::Intrinsic::dbg_derefval:
 case llvm::Intrinsic::dbg_declare:
   return true;
 default:
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -4010,6 +4010,7 @@
 switch (IntrinsicID) {
 case Intrinsic::dbg_declare:
 case Intrinsic::dbg_value:
+case Intrinsic::dbg_derefval:
 case Intrinsic::dbg_label:
 case Intrinsic::lifetime_end:
   break;
Index: llvm/lib/Transforms/Utils/Local.cpp
===
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -385,6 +385,11 @@
   return false;
 return true;
   }
+  if (DbgDerefValueInst *DVI = dyn_cast(I)) {
+if (DVI->getDerefVariable())
+  return false;
+return true;
+  }
   if (DbgLabelInst *DLI = dyn_cast(I)) {
 if (DLI->getLabel())
   return false;
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -4322,6 +4322,9 @@
   case Intrinsic::dbg_value: // llvm.dbg.value
 visitDbgIntrinsic("value", cast(Call));
 break;
+  case Intrinsic::dbg_derefval: // llvm.dbg.derefval
+visitDbgIntrinsic("derefval", cast(Call));
+break;
   case Intrinsic::dbg_label: // llvm.dbg.label
 visitDbgLabelIntrinsic("label", cast(Call));
 break;
@@ -4877,8 +4880,9 @@
 void Verifier::visitDbgIntrinsic(StringRef Kind, DbgVariableIntrinsic ) {
   auto *MD = cast(DII.getArgOperand(0))->getMetadata();
   AssertDI(isa(MD) ||
- (isa(MD) && !cast(MD)->getNumOperands()),
- "invalid llvm.dbg." + Kind + " intrinsic address/value", , MD);
+   (isa(MD) && !cast(MD)->getNumOperands()) ||
+   isa(DII),
+   "invalid llvm.dbg." + Kind + " intrinsic address/value", , MD);
   AssertDI(isa(DII.getRawVariable()),
  "invalid llvm.dbg." + Kind + " intrinsic variable", ,
  DII.getRawVariable());
Index: llvm/lib/IR/IntrinsicInst.cpp
===
--- llvm/lib/IR/IntrinsicInst.cpp
+++ llvm/lib/IR/IntrinsicInst.cpp
@@ -50,6 +50,14 @@
   return nullptr;
 }
 
+Value *DbgVariableIntrinsic::getDerefVariable(bool AllowNullOp) const {
+  Value *Op = getArgOperand(0);
+  if (AllowNullOp && !Op)
+return nullptr;
+
+  return Op;
+}
+
 Optional DbgVariableIntrinsic::getFragmentSizeInBits() const {
   if (auto Fragment = getExpression()->getFragmentInfo())
 return Fragment->SizeInBits;
Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -33,7 +33,7 @@
 
 DIBuilder::DIBuilder(Module , bool AllowUnresolvedNodes, DICompileUnit *CU)
   : M(m), VMContext(M.getContext()), CUNode(CU),
-  DeclareFn(nullptr), ValueFn(nullptr), LabelFn(nullptr),
+  DeclareFn(nullptr), ValueFn(nullptr), DerefvalFn(nullptr), LabelFn(nullptr),
   AllowUnresolvedNodes(AllowUnresolvedNodes) {}
 
 void DIBuilder::trackIfUnresolved(MDNode *N) {
@@ -887,6 +887,14 @@
   InsertBefore);
 }
 
+Instruction *DIBuilder::insertDbgDerefValueIntrinsic(
+Value *V, DILocalVariable *VarInfo, DIExpression *Expr,
+const DILocation *DL, 

[Lldb-commits] [PATCH] D71857: [NFC] Fixes -Wrange-loop-analysis warnings

2020-01-02 Thread Mark de Wever via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8dc7b982b455: [NFC] Fixes -Wrange-loop-analysis warnings 
(authored by Mordante).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71857

Files:
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  clang/lib/Tooling/ASTDiff/ASTDiff.cpp
  clang/tools/clang-refactor/TestSupport.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
  lldb/source/Plugins/Platform/Android/AdbClient.cpp
  lldb/source/Target/StackFrameRecognizer.cpp
  llvm/include/llvm/Analysis/LoopInfo.h
  llvm/include/llvm/Analysis/LoopInfoImpl.h
  llvm/include/llvm/Support/GenericDomTree.h
  llvm/lib/Analysis/DomTreeUpdater.cpp
  llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/CodeGen/InlineSpiller.cpp
  llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp
  llvm/lib/CodeGen/RegAllocFast.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
  llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
  llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
  llvm/lib/IR/TypeFinder.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/lib/MC/XCOFFObjectWriter.cpp
  llvm/lib/MCA/HardwareUnits/ResourceManager.cpp
  llvm/lib/MCA/Stages/InstructionTables.cpp
  llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
  llvm/lib/Support/CommandLine.cpp
  llvm/lib/Support/TargetParser.cpp

Index: llvm/lib/Support/TargetParser.cpp
===
--- llvm/lib/Support/TargetParser.cpp
+++ llvm/lib/Support/TargetParser.cpp
@@ -132,7 +132,7 @@
 }
 
 AMDGPU::GPUKind llvm::AMDGPU::parseArchAMDGCN(StringRef CPU) {
-  for (const auto C : AMDGCNGPUs) {
+  for (const auto  : AMDGCNGPUs) {
 if (CPU == C.Name)
   return C.Kind;
   }
@@ -141,7 +141,7 @@
 }
 
 AMDGPU::GPUKind llvm::AMDGPU::parseArchR600(StringRef CPU) {
-  for (const auto C : R600GPUs) {
+  for (const auto  : R600GPUs) {
 if (CPU == C.Name)
   return C.Kind;
   }
@@ -163,12 +163,12 @@
 
 void AMDGPU::fillValidArchListAMDGCN(SmallVectorImpl ) {
   // XXX: Should this only report unique canonical names?
-  for (const auto C : AMDGCNGPUs)
+  for (const auto  : AMDGCNGPUs)
 Values.push_back(C.Name);
 }
 
 void AMDGPU::fillValidArchListR600(SmallVectorImpl ) {
-  for (const auto C : R600GPUs)
+  for (const auto  : R600GPUs)
 Values.push_back(C.Name);
 }
 
Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -187,7 +187,7 @@
 // If we're adding this to all sub-commands, add it to the ones that have
 // already been registered.
 if (SC == &*AllSubCommands) {
-  for (const auto  : RegisteredSubCommands) {
+  for (auto *Sub : RegisteredSubCommands) {
 if (SC == Sub)
   continue;
 addLiteralOption(Opt, Sub, Name);
@@ -243,7 +243,7 @@
 // If we're adding this to all sub-commands, add it to the ones that have
 // already been registered.
 if (SC == &*AllSubCommands) {
-  for (const auto  : RegisteredSubCommands) {
+  for (auto *Sub : RegisteredSubCommands) {
 if (SC == Sub)
   continue;
 addOption(O, Sub);
@@ -318,7 +318,7 @@
   }
 
   bool hasOptions() const {
-for (const auto  : RegisteredSubCommands) {
+for (const auto *S : RegisteredSubCommands) {
   if (hasOptions(*S))
 return true;
 }
@@ -2112,7 +2112,7 @@
 static void
 sortSubCommands(const SmallPtrSetImpl ,
 SmallVectorImpl> ) {
-  for (const auto  : SubMap) {
+  for (auto *S : SubMap) {
 if (S->getName().empty())
   continue;
 Subs.push_back(std::make_pair(S->getName().data(), S));
Index: llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
===
--- llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
+++ llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
@@ -421,7 +421,7 @@
   for (const auto  : Lines.Blocks) {
 Result->createBlock(LC.FileName);
 if (Result->hasColumnInfo()) {
-  for (const auto  : zip(LC.Lines, LC.Columns)) {
+  for (auto Item : zip(LC.Lines, LC.Columns)) {
 auto  = std::get<0>(Item);
 auto  = std::get<1>(Item);
 

Re: [Lldb-commits] [lldb] fe8e25a - [lldb][NFC] Create type-safe function for creating a CompilerType from a QualType

2020-01-02 Thread Raphael “Teemperor” Isemann via lldb-commits
Somehow your mail is missing examples after the ‘… like:’ but the method is 
named similar to the GetType* methods directly below it. Don’t really have an 
opinion about whether this should be GetType* or GetCompilerType* (though I 
wouldn’t add the ‘As’ to it though as that’s usually used for casting 
utilities). I can rename the whole pack of function to GetCompilerType(…), that 
sounds good to me.

> On Jan 2, 2020, at 11:05 PM, Shafik Yaghmour  wrote:
> 
> Instead of GetType(...) I think GetCompilerType(…) is better or maybe even 
> GetAsCompilerType(…). It adds a bit more context, we have so many types. It 
> also feels a bit more consistent with methods like:
> 
> 
> 
>> On Jan 2, 2020, at 2:55 AM, Raphael Isemann via lldb-commits 
>>  wrote:
>> 
>> 
>> Author: Raphael Isemann
>> Date: 2020-01-02T11:54:45+01:00
>> New Revision: fe8e25a48a2a0f8f508499ba950181dba3d600b0
>> 
>> URL: 
>> https://github.com/llvm/llvm-project/commit/fe8e25a48a2a0f8f508499ba950181dba3d600b0
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/fe8e25a48a2a0f8f508499ba950181dba3d600b0.diff
>> 
>> LOG: [lldb][NFC] Create type-safe function for creating a CompilerType from 
>> a QualType
>> 
>> LLDB frequently converts QualType to CompilerType. This is currently done 
>> like this:
>>   result = CompilerType(this, qual_type_var.getAsOpaquePtr())
>> There are a few shortcomings in this current approach:
>> 1. CompilerType's constructor takes a void* pointer so it isn't type safe.
>> 2. We can't add any sanity checks to the CompilerType constructor (e.g. that 
>> the type
>>actually belongs to the passed ClangASTContext) without expanding the 
>> TypeSystem API.
>> 3. The logic for converting QualType->CompilerType is spread out over all of 
>> LLDB so
>>changing it is difficult (e.g., what if we want to just pass the type ptr 
>> and not the
>>1type_ptr | qual_flags1 to CompilerType).
>> 
>> This patch adds a `ClangASTContext::GetType` function similar to the other 
>> GetTypeForDecl
>> functions that does this conversion in a type safe way.
>> 
>> It also adds a sanity check for Tag-based types that the type actually 
>> belongs to the
>> current ClangASTContext (Types don't seem to know their ASTContext, so we 
>> have to
>> workaround by looking at the decl for the underlying TagDecl. This doesn't 
>> cover all types
>> we construct but it's better than no sanity check).
>> 
>> Added: 
>> 
>> 
>> Modified: 
>>   lldb/include/lldb/Symbol/ClangASTContext.h
>>   lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>>   lldb/source/Plugins/Language/ObjC/NSArray.cpp
>>   
>> lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
>>   lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
>>   lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
>>   lldb/source/Symbol/ClangASTContext.cpp
>> 
>> Removed: 
>> 
>> 
>> 
>> 
>> diff  --git a/lldb/include/lldb/Symbol/ClangASTContext.h 
>> b/lldb/include/lldb/Symbol/ClangASTContext.h
>> index e9a1d536ca8e..53ecd1bb78fc 100644
>> --- a/lldb/include/lldb/Symbol/ClangASTContext.h
>> +++ b/lldb/include/lldb/Symbol/ClangASTContext.h
>> @@ -164,6 +164,22 @@ class ClangASTContext : public TypeSystem {
>>  static bool AreTypesSame(CompilerType type1, CompilerType type2,
>>   bool ignore_qualifiers = false);
>> 
>> +  /// Creates a CompilerType form the given QualType with the current
>> +  /// ClangASTContext instance as the CompilerType's typesystem.
>> +  /// \param qt The QualType for a type that belongs to the ASTContext of 
>> this
>> +  ///   ClangASTContext.
>> +  /// \return The CompilerType representing the given QualType. If the
>> +  /// QualType's type pointer is a nullptr then the function 
>> returns an
>> +  /// invalid CompilerType.
>> +  CompilerType GetType(clang::QualType qt) {
>> +if (qt.getTypePtrOrNull() == nullptr)
>> +  return CompilerType();
>> +// Check that the type actually belongs to this ClangASTContext.
>> +assert(qt->getAsTagDecl() == nullptr ||
>> +   >getAsTagDecl()->getASTContext() == ());
>> +return CompilerType(this, qt.getAsOpaquePtr());
>> +  }
>> +
>>  CompilerType GetTypeForDecl(clang::NamedDecl *decl);
>> 
>>  CompilerType GetTypeForDecl(clang::TagDecl *decl);
>> 
>> diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
>> b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>> index ff86f9f818b2..b0043f9c0f64 100644
>> --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>> +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>> @@ -1861,7 +1861,7 @@ CompilerType ClangASTSource::GuardedCopyType(const 
>> CompilerType _type) {
>>// seems to be generating bad types on occasion.
>>return CompilerType();
>> 
>> -  return CompilerType(m_clang_ast_context, 
>> 

[Lldb-commits] [PATCH] D72107: [lldb/CMake] Autodetect Python dependency

2020-01-02 Thread Alex Langford via Phabricator via lldb-commits
xiaobai added a comment.

In D72107#1802029 , @JDevlieghere 
wrote:

> Do you mean forcing `LLDB_ENABLE_PYTHON` to on so that it fails in case the 
> logic changes and Python isn't found?


Yes, something like that. It looks like the previous expected behavior was that 
python was implicitly a required dependency (unless you explicitly disabled it 
or were building for android/ios). Making it an optional dependency means that 
the buildbots should probably explicitly say that they want to enable python. 
You could probably not change buildbot invocations, but that means that if a 
buildbot fails to find python then we won't know until something goes wrong 
(e.g. A test fails locally on some setup that passed buildbots because 
buildbots weren't running python tests).


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72107



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


Re: [Lldb-commits] [lldb] fe8e25a - [lldb][NFC] Create type-safe function for creating a CompilerType from a QualType

2020-01-02 Thread Shafik Yaghmour via lldb-commits
Instead of GetType(...) I think GetCompilerType(…) is better or maybe even 
GetAsCompilerType(…). It adds a bit more context, we have so many types. It 
also feels a bit more consistent with methods like:



> On Jan 2, 2020, at 2:55 AM, Raphael Isemann via lldb-commits 
>  wrote:
> 
> 
> Author: Raphael Isemann
> Date: 2020-01-02T11:54:45+01:00
> New Revision: fe8e25a48a2a0f8f508499ba950181dba3d600b0
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/fe8e25a48a2a0f8f508499ba950181dba3d600b0
> DIFF: 
> https://github.com/llvm/llvm-project/commit/fe8e25a48a2a0f8f508499ba950181dba3d600b0.diff
> 
> LOG: [lldb][NFC] Create type-safe function for creating a CompilerType from a 
> QualType
> 
> LLDB frequently converts QualType to CompilerType. This is currently done 
> like this:
>result = CompilerType(this, qual_type_var.getAsOpaquePtr())
> There are a few shortcomings in this current approach:
>  1. CompilerType's constructor takes a void* pointer so it isn't type safe.
>  2. We can't add any sanity checks to the CompilerType constructor (e.g. that 
> the type
> actually belongs to the passed ClangASTContext) without expanding the 
> TypeSystem API.
>  3. The logic for converting QualType->CompilerType is spread out over all of 
> LLDB so
> changing it is difficult (e.g., what if we want to just pass the type ptr 
> and not the
> 1type_ptr | qual_flags1 to CompilerType).
> 
> This patch adds a `ClangASTContext::GetType` function similar to the other 
> GetTypeForDecl
> functions that does this conversion in a type safe way.
> 
> It also adds a sanity check for Tag-based types that the type actually 
> belongs to the
> current ClangASTContext (Types don't seem to know their ASTContext, so we 
> have to
> workaround by looking at the decl for the underlying TagDecl. This doesn't 
> cover all types
> we construct but it's better than no sanity check).
> 
> Added: 
> 
> 
> Modified: 
>lldb/include/lldb/Symbol/ClangASTContext.h
>lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
>lldb/source/Plugins/Language/ObjC/NSArray.cpp
>
> lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
>lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
>lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
>lldb/source/Symbol/ClangASTContext.cpp
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/include/lldb/Symbol/ClangASTContext.h 
> b/lldb/include/lldb/Symbol/ClangASTContext.h
> index e9a1d536ca8e..53ecd1bb78fc 100644
> --- a/lldb/include/lldb/Symbol/ClangASTContext.h
> +++ b/lldb/include/lldb/Symbol/ClangASTContext.h
> @@ -164,6 +164,22 @@ class ClangASTContext : public TypeSystem {
>   static bool AreTypesSame(CompilerType type1, CompilerType type2,
>bool ignore_qualifiers = false);
> 
> +  /// Creates a CompilerType form the given QualType with the current
> +  /// ClangASTContext instance as the CompilerType's typesystem.
> +  /// \param qt The QualType for a type that belongs to the ASTContext of 
> this
> +  ///   ClangASTContext.
> +  /// \return The CompilerType representing the given QualType. If the
> +  /// QualType's type pointer is a nullptr then the function returns 
> an
> +  /// invalid CompilerType.
> +  CompilerType GetType(clang::QualType qt) {
> +if (qt.getTypePtrOrNull() == nullptr)
> +  return CompilerType();
> +// Check that the type actually belongs to this ClangASTContext.
> +assert(qt->getAsTagDecl() == nullptr ||
> +   >getAsTagDecl()->getASTContext() == ());
> +return CompilerType(this, qt.getAsOpaquePtr());
> +  }
> +
>   CompilerType GetTypeForDecl(clang::NamedDecl *decl);
> 
>   CompilerType GetTypeForDecl(clang::TagDecl *decl);
> 
> diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
> b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
> index ff86f9f818b2..b0043f9c0f64 100644
> --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
> +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
> @@ -1861,7 +1861,7 @@ CompilerType ClangASTSource::GuardedCopyType(const 
> CompilerType _type) {
> // seems to be generating bad types on occasion.
> return CompilerType();
> 
> -  return CompilerType(m_clang_ast_context, 
> copied_qual_type.getAsOpaquePtr());
> +  return m_clang_ast_context->GetType(copied_qual_type);
> }
> 
> clang::NamedDecl *NameSearchContext::AddVarDecl(const CompilerType ) {
> @@ -1988,9 +1988,8 @@ clang::NamedDecl 
> *NameSearchContext::AddGenericFunDecl() {
>   ArrayRef(), // argument types
>   proto_info));
> 
> -  return AddFunDecl(CompilerType(m_ast_source.m_clang_ast_context,
> - generic_function_type.getAsOpaquePtr()),
> -true);
> +  return AddFunDecl(
> +  

[Lldb-commits] [PATCH] D72107: [lldb/CMake] Autodetect Python dependency

2020-01-02 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D72107#1802001 , @xiaobai wrote:

> It's nice to consolidate the logic into one place. I think you will probably 
> need to make an appropriate change on the buildbot side as well (if you 
> haven't done that already).


Do you mean forcing `LLDB_ENABLE_PYTHON` to on so that it fails in case the 
logic changes and Python isn't found?

> Where is `FindPythonInterpAndLibs` being included?

It's included from the `add_optional_dependency` macro.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72107



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


[Lldb-commits] [PATCH] D72107: [lldb/CMake] Autodetect Python dependency

2020-01-02 Thread Alex Langford via Phabricator via lldb-commits
xiaobai added a comment.

It's nice to consolidate the logic into one place. I think you will probably 
need to make an appropriate change on the buildbot side as well (if you haven't 
done that already).

Where is `FindPythonInterpAndLibs` being included?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72107



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


[Lldb-commits] [PATCH] D72107: [lldb/CMake] Autodetect Python dependency

2020-01-02 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, compnerd, xiaobai.
Herald added a subscriber: mgorny.
Herald added a project: LLDB.

Python was the last remaining "optional" dependency for LLDB. This moves the 
code to find Python into `FindPythonInterpAndLibs` using the same principles as 
`FindCursesAndPanel`.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D72107

Files:
  lldb/cmake/modules/FindPythonInterpAndLibs.cmake
  lldb/cmake/modules/LLDBConfig.cmake

Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -51,16 +51,8 @@
 add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" CursesAndPanel CURSESANDPANEL_FOUND)
 add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA LIBLZMA_FOUND)
 add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" Lua LUA_FOUND)
+add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
 
-set(default_enable_python ON)
-
-if(CMAKE_SYSTEM_NAME MATCHES "Android")
-  set(default_enable_python OFF)
-elseif(IOS)
-  set(default_enable_python OFF)
-endif()
-
-option(LLDB_ENABLE_PYTHON "Enable Python scripting integration." ${default_enable_python})
 option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to locate Python." OFF)
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF)
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
@@ -142,48 +134,13 @@
 endif()
 
 if (LLDB_ENABLE_PYTHON)
-  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
-find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
-if(Python3_VERSION VERSION_LESS 3.5)
-  message(SEND_ERROR "Python 3.5 or newer is required (found: ${Python3_VERSION}")
-endif()
-set(PYTHON_LIBRARIES ${Python3_LIBRARIES})
-include_directories(${Python3_INCLUDE_DIRS})
-
-if (NOT LLDB_RELOCATABLE_PYTHON)
-  get_filename_component(PYTHON_HOME "${Python3_EXECUTABLE}" DIRECTORY)
-  file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
-endif()
-  else()
-find_package(PythonInterp REQUIRED)
-find_package(PythonLibs REQUIRED)
-
-if (NOT CMAKE_CROSSCOMPILING)
-  string(REPLACE "." ";" pythonlibs_version_list ${PYTHONLIBS_VERSION_STRING})
-  list(GET pythonlibs_version_list 0 pythonlibs_major)
-  list(GET pythonlibs_version_list 1 pythonlibs_minor)
-
-  # Ignore the patch version. Some versions of macOS report a different patch
-  # version for the system provided interpreter and libraries.
-  if (NOT PYTHON_VERSION_MAJOR VERSION_EQUAL pythonlibs_major OR
-  NOT PYTHON_VERSION_MINOR VERSION_EQUAL pythonlibs_minor)
-message(FATAL_ERROR "Found incompatible Python interpreter (${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})"
-" and Python libraries (${pythonlibs_major}.${pythonlibs_minor})")
-  endif()
-endif()
-
-if (PYTHON_INCLUDE_DIR)
-  include_directories(${PYTHON_INCLUDE_DIR})
-endif()
+  include_directories(${PYTHON_INCLUDE_DIRS})
+  if (NOT LLDB_RELOCATABLE_PYTHON)
+get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
+file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
   endif()
 endif()
 
-if (NOT LLDB_ENABLE_PYTHON)
-  unset(PYTHON_INCLUDE_DIR)
-  unset(PYTHON_LIBRARIES)
-  unset(PYTHON_EXECUTABLE)
-endif()
-
 if (LLVM_EXTERNAL_CLANG_SOURCE_DIR)
   include_directories(${LLVM_EXTERNAL_CLANG_SOURCE_DIR}/include)
 else ()
Index: lldb/cmake/modules/FindPythonInterpAndLibs.cmake
===
--- /dev/null
+++ lldb/cmake/modules/FindPythonInterpAndLibs.cmake
@@ -0,0 +1,51 @@
+#.rst:
+# FindPythonInterpndLibs
+# ---
+#
+# Find the python interpreter and libraries as a whole.
+
+if(PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIRS AND PYTHON_EXECUTABLE)
+  set(PYTHONINTERPANDLIBS_FOUND TRUE)
+else()
+  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
+find_package(Python3 COMPONENTS Interpreter Development QUIET)
+if (Python3_FOUND AND Python3_Interpreter_FOUND)
+  set(PYTHON_LIBRARIES ${Python3_LIBRARIES})
+  set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
+  set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
+  mark_as_advanced(
+PYTHON_LIBRARIES
+PYTHON_INCLUDE_DIRS
+PYTHON_EXECUTABLE)
+endif()
+  else()
+find_package(PythonInterp QUIET)
+find_package(PythonLibs QUIET)
+if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
+  if (NOT CMAKE_CROSSCOMPILING)
+string(REPLACE "." ";" pythonlibs_version_list ${PYTHONLIBS_VERSION_STRING})
+list(GET pythonlibs_version_list 0 pythonlibs_major)
+list(GET pythonlibs_version_list 1 

[Lldb-commits] [lldb] f83801f - [lldb/CMake] Print whether an optional dependency was enabled.

2020-01-02 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-02T13:40:01-08:00
New Revision: f83801fb2a4064d666cf8c17d716376a99e4a555

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

LOG: [lldb/CMake] Print whether an optional dependency was enabled.

Use a status message to convey whether an optional dependency was found
or not. With the auto-detection code it's not longer as simple as
checking the CMake cache.

Added: 


Modified: 
lldb/cmake/modules/LLDBConfig.cmake

Removed: 




diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index b77880cc0af4..52b8257951be 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -36,19 +36,21 @@ macro(add_optional_dependency variable description package 
found)
 set(maybe_required REQUIRED)
   else()
 set(find_package FALSE)
-set(${variable} FALSE PARENT_SCOPE)
+set(${variable} FALSE)
   endif()
 
   if(${find_package})
 find_package(${package} ${maybe_required})
 set(${variable} "${${found}}")
   endif()
+
+  message(STATUS "${description}: ${${variable}}")
 endmacro()
 
-add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support." LibEdit 
LibEdit_FOUND)
-add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support." 
CursesAndPanel CURSESANDPANEL_FOUND)
-add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support." 
LibLZMA LIBLZMA_FOUND)
-add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support." Lua 
LUA_FOUND)
+add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support in LLDB" 
LibEdit LibEdit_FOUND)
+add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" 
CursesAndPanel CURSESANDPANEL_FOUND)
+add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in 
LLDB" LibLZMA LIBLZMA_FOUND)
+add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" 
Lua LUA_FOUND)
 
 set(default_enable_python ON)
 



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


[Lldb-commits] [lldb] f38234e - [lldb/CMake] Fix variable naming in FindLibEdit

2020-01-02 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-02T13:39:57-08:00
New Revision: f38234ed8b579230a3742317ffd5fb95514d9638

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

LOG: [lldb/CMake] Fix variable naming in FindLibEdit

The current FOUND_VAR for FindLibEdit is libedit_FOUND but wasn't set by
find_package_handle_standard_args. However this isn't valid for the
package name.

  The argument for FOUND_VAR is "libedit_FOUND", but only "LibEdit_FOUND" and
  "LIBEDIT_FOUND" are valid names.

This fixes all the variables set by FindLibEdit to match the desired
naming scheme.

Added: 


Modified: 
lldb/cmake/modules/FindLibEdit.cmake
lldb/cmake/modules/LLDBConfig.cmake
lldb/source/Core/CMakeLists.txt
lldb/source/Host/CMakeLists.txt
lldb/source/Interpreter/CMakeLists.txt
lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt

Removed: 




diff  --git a/lldb/cmake/modules/FindLibEdit.cmake 
b/lldb/cmake/modules/FindLibEdit.cmake
index df8f2abb0164..b4f0cb329811 100644
--- a/lldb/cmake/modules/FindLibEdit.cmake
+++ b/lldb/cmake/modules/FindLibEdit.cmake
@@ -8,25 +8,25 @@
 #
 # ::
 #
-#   libedit_FOUND - true if libedit was found
-#   libedit_INCLUDE_DIRS  - include search path
-#   libedit_LIBRARIES - libraries to link
-#   libedit_VERSION   - version number
+#   LibEdit_FOUND  - true if libedit was found
+#   LibEdit_INCLUDE_DIRS   - include search path
+#   LibEdit_LIBRARIES  - libraries to link
+#   LibEdit_VERSION_STRING - version number
 
-if(libedit_INCLUDE_DIRS AND libedit_LIBRARIES)
-  set(libedit_FOUND TRUE)
+if(LibEdit_INCLUDE_DIRS AND LibEdit_LIBRARIES)
+  set(LibEdit_FOUND TRUE)
 else()
   find_package(PkgConfig QUIET)
   pkg_check_modules(PC_LIBEDIT QUIET libedit)
 
-  find_path(libedit_INCLUDE_DIRS
+  find_path(LibEdit_INCLUDE_DIRS
 NAMES
   histedit.h
 HINTS
   ${PC_LIBEDIT_INCLUDEDIR}
   ${PC_LIBEDIT_INCLUDE_DIRS}
   ${CMAKE_INSTALL_FULL_INCLUDEDIR})
-  find_library(libedit_LIBRARIES
+  find_library(LibEdit_LIBRARIES
NAMES
  edit libedit
HINTS
@@ -34,29 +34,31 @@ else()
  ${PC_LIBEDIT_LIBRARY_DIRS}
  ${CMAKE_INSTALL_FULL_LIBDIR})
 
-  if(libedit_INCLUDE_DIRS AND EXISTS "${libedit_INCLUDE_DIRS}/histedit.h")
-file(STRINGS "${libedit_INCLUDE_DIRS}/histedit.h"
+  if(LibEdit_INCLUDE_DIRS AND EXISTS "${LibEdit_INCLUDE_DIRS}/histedit.h")
+file(STRINGS "${LibEdit_INCLUDE_DIRS}/histedit.h"
  libedit_major_version_str
  REGEX "^#define[ \t]+LIBEDIT_MAJOR[ \t]+[0-9]+")
 string(REGEX REPLACE "^#define[ \t]+LIBEDIT_MAJOR[ \t]+([0-9]+)" "\\1"
LIBEDIT_MAJOR_VERSION "${libedit_major_version_str}")
 
-file(STRINGS "${libedit_INCLUDE_DIRS}/histedit.h"
+file(STRINGS "${LibEdit_INCLUDE_DIRS}/histedit.h"
  libedit_minor_version_str
  REGEX "^#define[ \t]+LIBEDIT_MINOR[ \t]+[0-9]+")
 string(REGEX REPLACE "^#define[ \t]+LIBEDIT_MINOR[ \t]+([0-9]+)" "\\1"
LIBEDIT_MINOR_VERSION "${libedit_minor_version_str}")
 
-set(libedit_VERSION_STRING 
"${libedit_major_version}.${libedit_minor_version}")
+set(LibEdit_VERSION_STRING 
"${libedit_major_version}.${libedit_minor_version}")
   endif()
 
   include(FindPackageHandleStandardArgs)
   find_package_handle_standard_args(LibEdit
+FOUND_VAR
+  LibEdit_FOUND
 REQUIRED_VARS
-  libedit_INCLUDE_DIRS
-  libedit_LIBRARIES
+  LibEdit_INCLUDE_DIRS
+  LibEdit_LIBRARIES
 VERSION_VAR
-  libedit_VERSION_STRING)
-  mark_as_advanced(libedit_INCLUDE_DIRS libedit_LIBRARIES)
+  LibEdit_VERSION_STRING)
+  mark_as_advanced(LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES)
 endif()
 

diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 88f39f235277..b77880cc0af4 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -45,7 +45,7 @@ macro(add_optional_dependency variable description package 
found)
   endif()
 endmacro()
 
-add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support." LibEdit 
libedit_FOUND)
+add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support." LibEdit 
LibEdit_FOUND)
 add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support." 
CursesAndPanel CURSESANDPANEL_FOUND)
 add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA 

[Lldb-commits] [PATCH] D71909: [lldb] Fix crash in AccessDeclContextSanity when copying FunctionTemplateDecl inside a record.

2020-01-02 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: lldb/source/Symbol/ClangASTContext.cpp:1347
+  if (decl_ctx->isRecord())
+func_tmpl_decl->setAccess(clang::AccessSpecifier::AS_public);
 

Where is the method being added and why are we not setting the access there? 
Are we creating it though `CreateFunctionTemplateDecl` should be be checking 
the `DeclContext` there to see if it is a `RecordDecl`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71909



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


[Lldb-commits] [PATCH] D72086: [lldb] Fix that SBThread.GetStopDescription is returning strings with uninitialized memory at the end.

2020-01-02 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: lldb/source/API/SBThread.cpp:337
+  }
   else {
 // NULL dst passed in, return the length needed to contain the

The `else` branch feels inconsistent with the change above. Especially the `+ 
1`.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72086



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


[Lldb-commits] [lldb] 3ddfb04 - [lldb/CMake] Use PYTHON_LIBRARIES instead of PYTHON_LIBRARY

2020-01-02 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-01-02T13:01:17-08:00
New Revision: 3ddfb04f41ac60529316f64ae5ab1a8ff1cce6e2

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

LOG: [lldb/CMake] Use PYTHON_LIBRARIES instead of PYTHON_LIBRARY

PYTHON_LIBRARIES is the canonical variable set by FindPythonLibs while
PYTHON_LIBRARY is an implementation detail. This replaces the uses of
the latter with the former.

Added: 


Modified: 
lldb/cmake/modules/LLDBConfig.cmake
lldb/source/API/CMakeLists.txt
lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt

Removed: 




diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 64d0750239e8..88f39f235277 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -145,7 +145,7 @@ if (LLDB_ENABLE_PYTHON)
 if(Python3_VERSION VERSION_LESS 3.5)
   message(SEND_ERROR "Python 3.5 or newer is required (found: 
${Python3_VERSION}")
 endif()
-set(PYTHON_LIBRARY ${Python3_LIBRARIES})
+set(PYTHON_LIBRARIES ${Python3_LIBRARIES})
 include_directories(${Python3_INCLUDE_DIRS})
 
 if (NOT LLDB_RELOCATABLE_PYTHON)
@@ -178,7 +178,7 @@ endif()
 
 if (NOT LLDB_ENABLE_PYTHON)
   unset(PYTHON_INCLUDE_DIR)
-  unset(PYTHON_LIBRARY)
+  unset(PYTHON_LIBRARIES)
   unset(PYTHON_EXECUTABLE)
 endif()
 

diff  --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 7b9d4cb61e25..d036caf2f434 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -172,9 +172,9 @@ endif()
 
 if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
   # Only MSVC has the ABI compatibility problem and avoids using 
FindPythonLibs,
-  # so only it needs to explicitly link against ${PYTHON_LIBRARY}
+  # so only it needs to explicitly link against ${PYTHON_LIBRARIES}
   if (MSVC AND LLDB_ENABLE_PYTHON)
-target_link_libraries(liblldb PRIVATE ${PYTHON_LIBRARY})
+target_link_libraries(liblldb PRIVATE ${PYTHON_LIBRARIES})
   endif()
 else()
   set_target_properties(liblldb

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt 
b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
index e8d1e762effa..9088afe81409 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
@@ -19,7 +19,7 @@ add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
 lldbHost
 lldbInterpreter
 lldbTarget
-${PYTHON_LIBRARY}
+${PYTHON_LIBRARIES}
 ${LLDB_LIBEDIT_LIBS}
 
   LINK_COMPONENTS



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


[Lldb-commits] [lldb] abb0075 - build: reduce CMake handling for zlib

2020-01-02 Thread Saleem Abdulrasool via lldb-commits

Author: Saleem Abdulrasool
Date: 2020-01-02T11:19:12-08:00
New Revision: abb00753069554c538f3d850897373d093389945

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

LOG: build: reduce CMake handling for zlib

Rather than handling zlib handling manually, use `find_package` from CMake
to find zlib properly. Use this to normalize the `LLVM_ENABLE_ZLIB`,
`HAVE_ZLIB`, `HAVE_ZLIB_H`. Furthermore, require zlib if `LLVM_ENABLE_ZLIB` is
set to `YES`, which requires the distributor to explicitly select whether
zlib is enabled or not. This simplifies the CMake handling and usage in
the rest of the tooling.

This restores 68a235d07f9e7049c7eb0c8091f37e385327ac28,
e6c7ed6d2164a0659fd9f6ee44f1375d301e3cad.  The problem with the windows
bot is a need for clearing the cache.

Added: 


Modified: 
clang/test/CMakeLists.txt
clang/test/lit.site.cfg.py.in
compiler-rt/test/lit.common.configured.in
lld/test/CMakeLists.txt
lld/test/lit.site.cfg.py.in
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
llvm/CMakeLists.txt
llvm/cmake/config-ix.cmake
llvm/include/llvm/Config/config.h.cmake
llvm/lib/Support/CMakeLists.txt
llvm/lib/Support/CRC.cpp
llvm/lib/Support/Compression.cpp
llvm/test/CMakeLists.txt
llvm/test/lit.site.cfg.py.in
llvm/unittests/Support/CompressionTest.cpp

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 16e487f07b78..6f6121f06e56 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -9,22 +9,13 @@ endif ()
 
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
 
-if(CLANG_BUILT_STANDALONE)
-  # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
-  # value is forced to 0 if zlib was not found, so it is fine to use it
-  # instead of HAVE_LIBZ (not recorded).
-  if(LLVM_ENABLE_ZLIB)
-set(HAVE_LIBZ 1)
-  endif()
-endif()
-
 llvm_canonicalize_cmake_booleans(
   CLANG_BUILD_EXAMPLES
   CLANG_ENABLE_ARCMT
   CLANG_ENABLE_STATIC_ANALYZER
   ENABLE_BACKTRACES
   ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
-  HAVE_LIBZ
+  LLVM_ENABLE_ZLIB
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
   LLVM_ENABLE_PLUGINS
   LLVM_ENABLE_THREADS)

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 520afab6af82..e9b35ac01771 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -16,7 +16,7 @@ config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.host_cxx = "@CMAKE_CXX_COMPILER@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = @HAVE_LIBZ@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.clang_arcmt = @CLANG_ENABLE_ARCMT@
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@

diff  --git a/compiler-rt/test/lit.common.configured.in 
b/compiler-rt/test/lit.common.configured.in
index b4862f74cdd0..0fb51741783e 100644
--- a/compiler-rt/test/lit.common.configured.in
+++ b/compiler-rt/test/lit.common.configured.in
@@ -50,7 +50,7 @@ if config.enable_per_target_runtime_dir:
 else:
   set_default("target_suffix", "-%s" % config.target_arch)
 
-set_default("have_zlib", "@HAVE_LIBZ@")
+set_default("have_zlib", "@LLVM_ENABLE_ZLIB@")
 set_default("libcxx_used", "@LLVM_LIBCXX_USED@")
 
 # LLVM tools dir can be passed in lit parameters, so try to

diff  --git a/lld/test/CMakeLists.txt b/lld/test/CMakeLists.txt
index 8be42c46dd8a..dc8cedf2ea09 100644
--- a/lld/test/CMakeLists.txt
+++ b/lld/test/CMakeLists.txt
@@ -4,17 +4,8 @@ set(LLVM_BUILD_MODE "%(build_mode)s")
 set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s")
 set(LLVM_LIBS_DIR 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/%(build_config)s")
 
-if(LLD_BUILT_STANDALONE)
-  # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
-  # value is forced to 0 if zlib was not found, so it is fine to use it
-  # instead of HAVE_LIBZ (not recorded).
-  if(LLVM_ENABLE_ZLIB)
-set(HAVE_LIBZ 1)
-  endif()
-endif()
-
 llvm_canonicalize_cmake_booleans(
-  HAVE_LIBZ
+  LLVM_ENABLE_ZLIB
   LLVM_LIBXML2_ENABLED
   )
 

diff  --git a/lld/test/lit.site.cfg.py.in b/lld/test/lit.site.cfg.py.in
index 02840f8d6a30..531fce15839d 100644
--- a/lld/test/lit.site.cfg.py.in
+++ b/lld/test/lit.site.cfg.py.in
@@ -14,7 +14,7 @@ config.lld_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@"
 config.lld_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
-config.have_zlib = @HAVE_LIBZ@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.sizeof_void_p = @CMAKE_SIZEOF_VOID_P@
 

[Lldb-commits] [PATCH] D72096: [lldb/Command] Add --force option for `watchpoint delete` command

2020-01-02 Thread Frederic Riss via Phabricator via lldb-commits
friss added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py:162-179
+self.build(dictionary=self.d)
+self.setTearDownCleanup(dictionary=self.d)
+
+exe = self.getBuildArtifact(self.exe_name)
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+# Add a breakpoint to set a watchpoint when stopped on the breakpoint.

If you cannot reuse another test (see bellow), all the setup can be replaced by 
`lldbutil.run_to_line_breakpoint` or `lldbutil.run_to_source_breakpoint`



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py:194-196
+# Delete the watchpoint immediately using the force option.
+self.expect("watchpoint delete --force",
+substrs=['All watchpoints removed.'])

Can't we just add this to the end of another test without spinning up a new 
process?

Did you verify that the test failed before your patch? I'm asking because I 
don't know what m_interpreter.Confirm() does when there's no PTY connected. 
Does it default to no or yes?



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py:199
+# Use the '-v' option to do verbose listing of the watchpoint.
+self.runCmd("watchpoint list -v")
+

You don't test the result of this command, so you don't actually test that 
deleting the breakpoints really happened. Is there an SB API to list 
watchpoints? If there is, it would be a better fit for this test instead of 
matching the output of a command. 



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py:203-206
+# There should be no more watchpoint hit and the process status should
+# be 'exited'.
+self.expect("process status",
+substrs=['exited'])

I see, this is the actual test that no watchpoints are present. I'm fine with 
adding this new test, I think testing it this way makes sense, but please also 
find a way to make sure the list of watchpoints is empty.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72096



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


[Lldb-commits] [PATCH] D72096: [lldb/Command] Add --force option for `watchpoint delete` command

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

LGTM with the inline comment(s) addressed.




Comment at: lldb/source/Commands/CommandObjectWatchpoint.cpp:463
+
+  return error;
+}

Given that error is never actually populated, it might be nice to use `return 
{}` to make it clear that we're returning a default constructed instance.



Comment at: lldb/source/Commands/CommandObjectWatchpoint.cpp:529
 
 return result.Succeeded();
   }

I know it's not code you touched but moving this into the first if-clause would 
allow for an early return. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72096



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


[Lldb-commits] [PATCH] D72096: [lldb/Command] Add --force option for `watchpoint delete` command

2020-01-02 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: LLDB, teemperor.
mib added a project: LLDB.
Herald added a subscriber: lldb-commits.

[lldb/Command] Add --force option for `watchpoint delete` command

Currently, there is no option to delete all the watchpoint without LLDB
asking for a confirmation. Besides making the watchpoint delete command
homogeneous with the breakpoint delete command, this option could also
become handy to trigger automated watchpoint deletion i.e. using
breakpoint actions.

rdar://42560586

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72096

Files:
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
  lldb/source/Commands/CommandObjectWatchpoint.cpp
  lldb/source/Commands/Options.td

Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -1126,3 +1126,8 @@
 "to run as command for this watchpoint. Be sure to give a module name if "
 "appropriate.">;
 }
+
+let Command = "watchpoint delete" in {
+  def watchpoint_delete_force : Option<"force", "f">, Group<1>,
+Desc<"Delete all watchpoints without querying for confirmation.">;
+}
Index: lldb/source/Commands/CommandObjectWatchpoint.cpp
===
--- lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -414,6 +414,10 @@
   }
 };
 
+// CommandObjectWatchpointDelete
+#define LLDB_OPTIONS_watchpoint_delete
+#include "CommandOptions.inc"
+
 // CommandObjectWatchpointDelete
 #pragma mark Delete
 
@@ -423,7 +427,8 @@
   : CommandObjectParsed(interpreter, "watchpoint delete",
 "Delete the specified watchpoint(s).  If no "
 "watchpoints are specified, delete them all.",
-nullptr, eCommandRequiresTarget) {
+nullptr, eCommandRequiresTarget),
+m_options() {
 CommandArgumentEntry arg;
 CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID,
   eArgTypeWatchpointIDRange);
@@ -434,6 +439,42 @@
 
   ~CommandObjectWatchpointDelete() override = default;
 
+  Options *GetOptions() override { return _options; }
+
+  class CommandOptions : public Options {
+  public:
+CommandOptions() : Options(), m_force(false) {}
+
+~CommandOptions() override = default;
+
+Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+  ExecutionContext *execution_context) override {
+  Status error;
+  const int short_option = m_getopt_table[option_idx].val;
+
+  switch (short_option) {
+  case 'f':
+m_force = true;
+break;
+  default:
+llvm_unreachable("Unimplemented option");
+  }
+
+  return error;
+}
+
+void OptionParsingStarting(ExecutionContext *execution_context) override {
+  m_force = false;
+}
+
+llvm::ArrayRef GetDefinitions() override {
+  return llvm::makeArrayRef(g_watchpoint_delete_options);
+}
+
+// Instance variables to hold the values for command options.
+bool m_force;
+  };
+
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
 Target *target = ();
@@ -453,8 +494,9 @@
   return false;
 }
 
-if (command.GetArgumentCount() == 0) {
-  if (!m_interpreter.Confirm(
+if (command.empty()) {
+  if (!m_options.m_force &&
+  !m_interpreter.Confirm(
   "About to delete all watchpoints, do you want to do that?",
   true)) {
 result.AppendMessage("Operation cancelled...");
@@ -486,6 +528,9 @@
 
 return result.Succeeded();
   }
+
+private:
+  CommandOptions m_options;
 };
 
 // CommandObjectWatchpointIgnore
Index: lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
===
--- lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
+++ lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
@@ -155,6 +155,56 @@
 self.expect("process status",
 substrs=['exited'])
 
+# Read-write watchpoints not supported on SystemZ
+@expectedFailureAll(archs=['s390x'])
+def test_rw_watchpoint_delete(self):
+"""Test delete watchpoint and expect not to stop for watchpoint."""
+self.build(dictionary=self.d)
+self.setTearDownCleanup(dictionary=self.d)
+
+exe = self.getBuildArtifact(self.exe_name)
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+# Add a breakpoint to set a watchpoint when stopped on the breakpoint.
+

[Lldb-commits] [PATCH] D71906: [lldb][tests] Make it possible to expect failure for a whole category

2020-01-02 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

If I understand correctly this is the equivalent of `skip-category` but you 
want to XFAIL the tests instead of skip them? Seems reasonable to me :-)


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71906



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


[Lldb-commits] [PATCH] D72086: [lldb] Fix that SBThread.GetStopDescription is returning strings with uninitialized memory at the end.

2020-01-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: labath.
Herald added subscribers: lldb-commits, JDevlieghere, abidh.
Herald added a project: LLDB.

`SBThread.GetStopDescription` is a curious API as it takes a buffer length as a 
parameter that specifies
how many bytes the buffer we pass has. Then we fill the buffer until the 
specified length (or the length
of the stop description string) and return the string length. If the buffer is 
a nullptr however, we instead
return how many bytes we would have written to the buffer so that the user can 
allocate a buffer with
the right size and pass that size to a subsequent `SBThread.GetStopDescription` 
call.

Funnily enough, it is not possible to pass a nullptr via the Python SWIG 
bindings, so that might be the
first API in LLDB that is not only hard to use correctly but impossible to use 
correctly. The only way to
call this function via Python is to throw in a large size limit that is 
hopefully large enough to contain the
stop description (otherwise we only get the truncated stop description).

Currently passing a size limit that is smaller than the returned stop 
description doesn't cause the
Python bindings to return the stop description but instead the truncated stop 
description + uninitialized characters
at the end of the string. The reason for this is that we return the result of 
`snprintf` from the method
which returns the amount of bytes that *would* have been written (which is 
larger than the buffer).
This causes our Python bindings to return a string that is as large as full 
stop description but the
buffer that has been filled is only as large as the passed in buffer size.

This patch fixes this issue by just returning the actual length of the buffer 
we have written to (which is either
the buffer length or the length of the stop description, whatever is shorter).


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D72086

Files:
  lldb/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py
  lldb/source/API/SBThread.cpp


Index: lldb/source/API/SBThread.cpp
===
--- lldb/source/API/SBThread.cpp
+++ lldb/source/API/SBThread.cpp
@@ -327,8 +327,13 @@
   if (stop_info_sp) {
 const char *stop_desc = stop_info_sp->GetDescription();
 if (stop_desc) {
-  if (dst)
-return ::snprintf(dst, dst_len, "%s", stop_desc);
+  if (dst) {
+::snprintf(dst, dst_len, "%s", stop_desc);
+// The string we return is either as long as buffer length minus 
null
+// terminator or the number of characters in the description 
(depending
+// which of these two is shorter).
+return std::min(dst_len - 1, strlen(stop_desc));
+  }
   else {
 // NULL dst passed in, return the length needed to contain the
 // description
Index: lldb/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py
+++ lldb/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py
@@ -122,14 +122,20 @@
 self.assertTrue(
 thread.IsValid(),
 "There should be a thread stopped due to breakpoint")
-#self.runCmd("process status")
-
-# Due to the typemap magic (see lldb.swig), we pass in an (int)length 
to GetStopDescription
-# and expect to get a Python string as the return object!
-# The 100 is just an arbitrary number specifying the buffer size.
-stop_description = thread.GetStopDescription(100)
-self.expect(stop_description, exe=False,
-startstr='breakpoint')
+
+# Get the stop reason. GetStopDescription expects that we pass in the 
size of the description
+# we expect plus an additional byte for the null terminator.
+
+# Test with a buffer that is exactly as large as the expected stop 
reason.
+self.assertEqual("breakpoint 1.1", 
thread.GetStopDescription(len('breakpoint 1.1') + 1)
+
+# Test some smaller buffer sizes.
+self.assertEqual("breakpoint", 
thread.GetStopDescription(len('breakpoint') + 1))
+self.assertEqual("break", thread.GetStopDescription(len('break') + 1)
+self.assertEqual("b", thread.GetStopDescription(len('b') + 1)
+
+# Test that we can pass in a much larger size and still get the right 
output.
+self.assertEqual("breakpoint 1.1", 
thread.GetStopDescription(len('breakpoint 1.1') + 100)
 
 def step_out_of_malloc_into_function_b(self, exe_name):
 """Test Python SBThread.StepOut() API to step out of a malloc call 
where the call site is at function b()."""


Index: lldb/source/API/SBThread.cpp
===
--- lldb/source/API/SBThread.cpp
+++ 

[Lldb-commits] [PATCH] D71909: [lldb] Fix crash in AccessDeclContextSanity when copying FunctionTemplateDecl inside a record.

2020-01-02 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7ead00872929: [lldb] Fix crash in AccessDeclContextSanity 
when copying FunctionTemplateDecl… (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71909

Files:
  
lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash2/TestCompletionCrash2.py
  
lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash2/main.cpp
  
lldb/packages/Python/lldbsuite/test/commands/expression/regression-access-function-template-in-record/TestRegressionAccessFunctionTemplateInRecord.py
  
lldb/packages/Python/lldbsuite/test/commands/expression/regression-access-function-template-in-record/main.cpp
  lldb/source/Symbol/ClangASTContext.cpp
  lldb/unittests/Symbol/TestClangASTContext.cpp


Index: lldb/unittests/Symbol/TestClangASTContext.cpp
===
--- lldb/unittests/Symbol/TestClangASTContext.cpp
+++ lldb/unittests/Symbol/TestClangASTContext.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/Symbol/ClangTestUtils.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/ClangASTContext.h"
@@ -471,3 +472,51 @@
   QualType t = ctxt.getTypeOfType(t_base);
   EXPECT_EQ(lldb::eTypeClassBuiltin, m_ast->GetTypeClass(t.getAsOpaquePtr()));
 }
+
+TEST_F(TestClangASTContext, TestFunctionTemplateConstruction) {
+  // Tests creating a function template.
+
+  CompilerType int_type = m_ast->GetBasicType(lldb::eBasicTypeInt);
+  clang::TranslationUnitDecl *TU = m_ast->GetTranslationUnitDecl();
+
+  // Prepare the declarations/types we need for the template.
+  CompilerType clang_type =
+  m_ast->CreateFunctionType(int_type, nullptr, 0U, false, 0U);
+  FunctionDecl *func =
+  m_ast->CreateFunctionDeclaration(TU, "foo", clang_type, 0, false);
+  ClangASTContext::TemplateParameterInfos empty_params;
+
+  // Create the actual function template.
+  clang::FunctionTemplateDecl *func_template =
+  m_ast->CreateFunctionTemplateDecl(TU, func, "foo", empty_params);
+
+  EXPECT_EQ(TU, func_template->getDeclContext());
+  EXPECT_EQ("foo", func_template->getName());
+  EXPECT_EQ(clang::AccessSpecifier::AS_none, func_template->getAccess());
+}
+
+TEST_F(TestClangASTContext, TestFunctionTemplateInRecordConstruction) {
+  // Tests creating a function template inside a record.
+
+  CompilerType int_type = m_ast->GetBasicType(lldb::eBasicTypeInt);
+
+  // Create a record we can put the function template int.
+  CompilerType record_type =
+  clang_utils::createRecordWithField(*m_ast, "record", int_type, "field");
+  clang::TagDecl *record = ClangUtil::GetAsTagDecl(record_type);
+
+  // Prepare the declarations/types we need for the template.
+  CompilerType clang_type =
+  m_ast->CreateFunctionType(int_type, nullptr, 0U, false, 0U);
+  FunctionDecl *func =
+  m_ast->CreateFunctionDeclaration(record, "foo", clang_type, 0, false);
+  ClangASTContext::TemplateParameterInfos empty_params;
+
+  // Create the actual function template.
+  clang::FunctionTemplateDecl *func_template =
+  m_ast->CreateFunctionTemplateDecl(record, func, "foo", empty_params);
+
+  EXPECT_EQ(record, func_template->getDeclContext());
+  EXPECT_EQ("foo", func_template->getName());
+  EXPECT_EQ(clang::AccessSpecifier::AS_public, func_template->getAccess());
+}
Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -1340,6 +1340,11 @@
 // TODO: verify which decl context we should put template_param_decls 
into..
 template_param_decls[i]->setDeclContext(func_decl);
   }
+  // Function templates inside a record need to have an access specifier.
+  // It doesn't matter what access specifier we give the template as LLDB
+  // anyway allows accessing everything inside a record.
+  if (decl_ctx->isRecord())
+func_tmpl_decl->setAccess(clang::AccessSpecifier::AS_public);
 
   return func_tmpl_decl;
 }
Index: 
lldb/packages/Python/lldbsuite/test/commands/expression/regression-access-function-template-in-record/TestRegressionAccessFunctionTemplateInRecord.py
===
--- /dev/null
+++ 
lldb/packages/Python/lldbsuite/test/commands/expression/regression-access-function-template-in-record/TestRegressionAccessFunctionTemplateInRecord.py
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), [])
Index: 
lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash2/TestCompletionCrash2.py

[Lldb-commits] [lldb] 7ead008 - [lldb] Fix crash in AccessDeclContextSanity when copying FunctionTemplateDecl inside a record.

2020-01-02 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-01-02T14:47:04+01:00
New Revision: 7ead00872929a994ac40fc2c99fce15968e2c5a6

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

LOG: [lldb] Fix crash in AccessDeclContextSanity when copying 
FunctionTemplateDecl inside a record.

Summary:
We currently don't set access specifiers for function template declarations. 
This seems to be fine
as long as the function template is not declared inside any record in which 
case Clang asserts
with the following once we try to query it's access:
```
Assertion failed: (Access != AS_none && "Access specifier is AS_none inside a 
record decl"), function AccessDeclContextSanity,
```

This patch just marks these function template declarations as public to make 
Clang happy.

Reviewers: shafik, teemperor

Reviewed By: teemperor

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

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

Added: 

lldb/packages/Python/lldbsuite/test/commands/expression/regression-access-function-template-in-record/TestRegressionAccessFunctionTemplateInRecord.py

lldb/packages/Python/lldbsuite/test/commands/expression/regression-access-function-template-in-record/main.cpp

Modified: 
lldb/source/Symbol/ClangASTContext.cpp
lldb/unittests/Symbol/TestClangASTContext.cpp

Removed: 

lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash2/TestCompletionCrash2.py

lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash2/main.cpp



diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash2/TestCompletionCrash2.py
 
b/lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash2/TestCompletionCrash2.py
deleted file mode 100644
index 922347aa7810..
--- 
a/lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash2/TestCompletionCrash2.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from lldbsuite.test import lldbinline
-from lldbsuite.test import decorators
-
-lldbinline.MakeInlineTest(__file__, globals(), 
[decorators.skipIf(bugnumber="rdar://53754063")])

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/expression/regression-access-function-template-in-record/TestRegressionAccessFunctionTemplateInRecord.py
 
b/lldb/packages/Python/lldbsuite/test/commands/expression/regression-access-function-template-in-record/TestRegressionAccessFunctionTemplateInRecord.py
new file mode 100644
index ..f08c0dcbda98
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/expression/regression-access-function-template-in-record/TestRegressionAccessFunctionTemplateInRecord.py
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), [])

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash2/main.cpp
 
b/lldb/packages/Python/lldbsuite/test/commands/expression/regression-access-function-template-in-record/main.cpp
similarity index 100%
rename from 
lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash2/main.cpp
rename to 
lldb/packages/Python/lldbsuite/test/commands/expression/regression-access-function-template-in-record/main.cpp

diff  --git a/lldb/source/Symbol/ClangASTContext.cpp 
b/lldb/source/Symbol/ClangASTContext.cpp
index 4cf70fa9c1cb..99299c3c6c42 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -1340,6 +1340,11 @@ clang::FunctionTemplateDecl 
*ClangASTContext::CreateFunctionTemplateDecl(
 // TODO: verify which decl context we should put template_param_decls 
into..
 template_param_decls[i]->setDeclContext(func_decl);
   }
+  // Function templates inside a record need to have an access specifier.
+  // It doesn't matter what access specifier we give the template as LLDB
+  // anyway allows accessing everything inside a record.
+  if (decl_ctx->isRecord())
+func_tmpl_decl->setAccess(clang::AccessSpecifier::AS_public);
 
   return func_tmpl_decl;
 }

diff  --git a/lldb/unittests/Symbol/TestClangASTContext.cpp 
b/lldb/unittests/Symbol/TestClangASTContext.cpp
index 2cbd94982aa0..cea3a2912e30 100644
--- a/lldb/unittests/Symbol/TestClangASTContext.cpp
+++ b/lldb/unittests/Symbol/TestClangASTContext.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/Symbol/ClangTestUtils.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/ClangASTContext.h"
@@ -471,3 +472,51 @@ TEST_F(TestClangASTContext, TestGetTypeClassNested) {
   QualType t = ctxt.getTypeOfType(t_base);
   EXPECT_EQ(lldb::eTypeClassBuiltin, 

[Lldb-commits] [PATCH] D71909: [lldb] Fix crash in AccessDeclContextSanity when copying FunctionTemplateDecl inside a record.

2020-01-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

I'll land this now as its a pretty straightforward fix.


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

https://reviews.llvm.org/D71909



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


[Lldb-commits] [PATCH] D71906: [lldb][tests] Make it possible to expect failure for a whole category

2020-01-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

This LGTM but I'm not the right person to sign this off. I guess Pavel and 
Jonas know this code better.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71906



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


[Lldb-commits] [lldb] a95f4c8 - [lldb][NFC] Remove unused variable in DWARFASTParserClang::ParseSingleMember

2020-01-02 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-01-02T11:57:00+01:00
New Revision: a95f4c87842d76a9fce146b2f25e6c8079f6bbdc

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

LOG: [lldb][NFC] Remove unused variable in 
DWARFASTParserClang::ParseSingleMember

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 3cae9a190010..bb75c699352e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2579,7 +2579,6 @@ void DWARFASTParserClang::ParseSingleMember(
 }
 
 if (prop_name) {
-  ConstString fixed_getter;
   ConstString fixed_setter;
 
   // Check if the property getter/setter were provided as full names.



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


[Lldb-commits] [lldb] fe8e25a - [lldb][NFC] Create type-safe function for creating a CompilerType from a QualType

2020-01-02 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-01-02T11:54:45+01:00
New Revision: fe8e25a48a2a0f8f508499ba950181dba3d600b0

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

LOG: [lldb][NFC] Create type-safe function for creating a CompilerType from a 
QualType

LLDB frequently converts QualType to CompilerType. This is currently done like 
this:
result = CompilerType(this, qual_type_var.getAsOpaquePtr())
There are a few shortcomings in this current approach:
  1. CompilerType's constructor takes a void* pointer so it isn't type safe.
  2. We can't add any sanity checks to the CompilerType constructor (e.g. that 
the type
 actually belongs to the passed ClangASTContext) without expanding the 
TypeSystem API.
  3. The logic for converting QualType->CompilerType is spread out over all of 
LLDB so
 changing it is difficult (e.g., what if we want to just pass the type ptr 
and not the
 1type_ptr | qual_flags1 to CompilerType).

This patch adds a `ClangASTContext::GetType` function similar to the other 
GetTypeForDecl
functions that does this conversion in a type safe way.

It also adds a sanity check for Tag-based types that the type actually belongs 
to the
current ClangASTContext (Types don't seem to know their ASTContext, so we have 
to
workaround by looking at the decl for the underlying TagDecl. This doesn't 
cover all types
we construct but it's better than no sanity check).

Added: 


Modified: 
lldb/include/lldb/Symbol/ClangASTContext.h
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
lldb/source/Plugins/Language/ObjC/NSArray.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/source/Symbol/ClangASTContext.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/ClangASTContext.h 
b/lldb/include/lldb/Symbol/ClangASTContext.h
index e9a1d536ca8e..53ecd1bb78fc 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -164,6 +164,22 @@ class ClangASTContext : public TypeSystem {
   static bool AreTypesSame(CompilerType type1, CompilerType type2,
bool ignore_qualifiers = false);
 
+  /// Creates a CompilerType form the given QualType with the current
+  /// ClangASTContext instance as the CompilerType's typesystem.
+  /// \param qt The QualType for a type that belongs to the ASTContext of this
+  ///   ClangASTContext.
+  /// \return The CompilerType representing the given QualType. If the
+  /// QualType's type pointer is a nullptr then the function returns an
+  /// invalid CompilerType.
+  CompilerType GetType(clang::QualType qt) {
+if (qt.getTypePtrOrNull() == nullptr)
+  return CompilerType();
+// Check that the type actually belongs to this ClangASTContext.
+assert(qt->getAsTagDecl() == nullptr ||
+   >getAsTagDecl()->getASTContext() == ());
+return CompilerType(this, qt.getAsOpaquePtr());
+  }
+
   CompilerType GetTypeForDecl(clang::NamedDecl *decl);
 
   CompilerType GetTypeForDecl(clang::TagDecl *decl);

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index ff86f9f818b2..b0043f9c0f64 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -1861,7 +1861,7 @@ CompilerType ClangASTSource::GuardedCopyType(const 
CompilerType _type) {
 // seems to be generating bad types on occasion.
 return CompilerType();
 
-  return CompilerType(m_clang_ast_context, copied_qual_type.getAsOpaquePtr());
+  return m_clang_ast_context->GetType(copied_qual_type);
 }
 
 clang::NamedDecl *NameSearchContext::AddVarDecl(const CompilerType ) {
@@ -1988,9 +1988,8 @@ clang::NamedDecl *NameSearchContext::AddGenericFunDecl() {
   ArrayRef(), // argument types
   proto_info));
 
-  return AddFunDecl(CompilerType(m_ast_source.m_clang_ast_context,
- generic_function_type.getAsOpaquePtr()),
-true);
+  return AddFunDecl(
+  m_ast_source.m_clang_ast_context->GetType(generic_function_type), true);
 }
 
 clang::NamedDecl *

diff  --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp 
b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
index 64461fc2bc0f..0ac7fb6d2330 100644
--- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
@@ -612,9 +612,8 @@ 
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::
   auto *clang_ast_context =