[Lldb-commits] [PATCH] D59381: Change CompileUnit and ARanges interfaces to propagate errors

2019-12-24 Thread Igor Kudrin via Phabricator via lldb-commits
ikudrin added inline comments.



Comment at: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp:60
+llvm::Error error = set.extract(debug_aranges_data, &offset);
+if (!error)
+  return error;

@zturner, this probably should be
```
if (error)
  return std::move(error);
```


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59381



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


[Lldb-commits] [lldb] 4657a39 - [lldb][NFC] Remove ClangExternalASTSourceCommon

2019-12-24 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-12-24T13:17:27+01:00
New Revision: 4657a397c22a27775823b8f731abdc6477badfea

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

LOG: [lldb][NFC] Remove ClangExternalASTSourceCommon

ClangExternalASTSourceCommon's purpose is to store a map from
Decl*/Type* to ClangASTMetadata. Usually this data is accessed
via the ClangASTContext interface which then grabs the
current ExternalASTSource of its ASTContext, tries to cast it
to ClangExternalASTSourceCommon and then accesses the metadata
map. If the casting fails the setter does nothing and the getter
returns a nullptr as if there was no known metadata for a type/decl.

This system breaks as soon as any non-LLDB ExternalASTSource is added via
a multiplexer to our existing ExternalASTSource (in which case we suddenly
loose all out metadata as the casting always fails with an ExternalASTSource
that is not inheriting from ClangExternalASTSourceCommon).

This patch moves the metadata map to the ClangASTContext. This gets
rid of all the fragile casting, the requirement that every ExternalASTSource in
LLDB has to inherit from ClangExternalASTSourceCommon and simplifies
the metadata implementation to a simple map lookup. As 
ClangExternalASTSourceCommon
had no other purpose than storing metadata, this patch deletes this class
and replaces all uses with clang::ExternalASTSource.

No other code changes in this commit beside the AppleObjCDeclVendor which
was the only code that did not use the ClangASTContext interface but directly
accessed the ClangExternalASTSourceCommon.

Added: 


Modified: 
lldb/include/lldb/Symbol/ClangASTContext.h
lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
lldb/source/Symbol/CMakeLists.txt
lldb/source/Symbol/ClangASTContext.cpp

Removed: 
lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h
lldb/source/Symbol/ClangExternalASTSourceCommon.cpp



diff  --git a/lldb/include/lldb/Symbol/ClangASTContext.h 
b/lldb/include/lldb/Symbol/ClangASTContext.h
index cc8be8451571..59abe19eba1c 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -966,6 +966,15 @@ class ClangASTContext : public TypeSystem {
   std::unique_ptr m_mangle_ctx_up;
   uint32_t m_pointer_byte_size = 0;
   bool m_ast_owned = false;
+
+  typedef llvm::DenseMap 
DeclMetadataMap;
+  /// Maps Decls to their associated ClangASTMetadata.
+  DeclMetadataMap m_decl_metadata;
+
+  typedef llvm::DenseMap 
TypeMetadataMap;
+  /// Maps Types to their associated ClangASTMetadata.
+  TypeMetadataMap m_type_metadata;
+
   /// The sema associated that is currently used to build this ASTContext.
   /// May be null if we are already done parsing this ASTContext or the
   /// ASTContext wasn't created by parsing source code.

diff  --git a/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h 
b/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
index ed7e3b8ece7a..290ecc9b9017 100644
--- a/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
+++ b/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
@@ -9,13 +9,14 @@
 #ifndef liblldb_ClangExternalASTSourceCallbacks_h_
 #define liblldb_ClangExternalASTSourceCallbacks_h_
 
-#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "clang/AST/ExternalASTSource.h"
 
 namespace lldb_private {
 
 class ClangASTContext;
 
-class ClangExternalASTSourceCallbacks : public ClangExternalASTSourceCommon {
+class ClangExternalASTSourceCallbacks : public clang::ExternalASTSource {
 public:
   ClangExternalASTSourceCallbacks(ClangASTContext &ast) : m_ast(ast) {}
 

diff  --git a/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h 
b/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h
deleted file mode 100644
index dada61d7d026..
--- a/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h
+++ /dev/null
@@ -1,82 +0,0 @@
-//===-- ClangExternalASTSourceCommon.h --*- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#ifndef liblldb_ClangExternalASTSourceCommon_h
-#define liblldb_ClangExternalASTSourceCommon_h
-
-// Clang headers like to use NDEBUG inside of them to enable/disable debug
-// related features using "#ifndef NDEBUG" preproces

[Lldb-commits] [lldb] a12ac70 - [lldb][NFC] Move ClangASTContext::m_scratch_ast_source_up to the appropriate class

2019-12-24 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-12-24T16:32:40+01:00
New Revision: a12ac7009e99c6f9e72652e34019f07df9970204

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

LOG: [lldb][NFC] Move ClangASTContext::m_scratch_ast_source_up to the 
appropriate class

m_scratch_ast_source_up is only used by ClangASTContextForExpressions so it
should also be declared only in that class. Also make all other members of
ClangASTContext private and move the initialization code for 
ClangASTContextForExpressions
into the constructor.

Added: 


Modified: 
lldb/include/lldb/Symbol/ClangASTContext.h
lldb/source/Symbol/ClangASTContext.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/ClangASTContext.h 
b/lldb/include/lldb/Symbol/ClangASTContext.h
index 59abe19eba1c..c56a4975f53e 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -943,7 +943,7 @@ class ClangASTContext : public TypeSystem {
   clang::DeclarationName
   GetDeclarationName(const char *name, const CompilerType 
&function_clang_type);
 
-protected:
+private:
   const clang::ClassTemplateSpecializationDecl *
   GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type);
 
@@ -962,7 +962,6 @@ class ClangASTContext : public TypeSystem {
   std::unique_ptr m_builtins_up;
   std::unique_ptr m_dwarf_ast_parser_up;
   std::unique_ptr m_pdb_ast_parser_up;
-  std::unique_ptr m_scratch_ast_source_up;
   std::unique_ptr m_mangle_ctx_up;
   uint32_t m_pointer_byte_size = 0;
   bool m_ast_owned = false;
@@ -980,7 +979,6 @@ class ClangASTContext : public TypeSystem {
   /// ASTContext wasn't created by parsing source code.
   clang::Sema *m_sema = nullptr;
 
-private:
   // For ClangASTContext only
   ClangASTContext(const ClangASTContext &);
   const ClangASTContext &operator=(const ClangASTContext &);
@@ -995,6 +993,8 @@ class ClangASTContextForExpressions : public 
ClangASTContext {
 
   ~ClangASTContextForExpressions() override = default;
 
+  void Finalize() override;
+
   UserExpression *
   GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
 lldb::LanguageType language,
@@ -1016,6 +1016,7 @@ class ClangASTContextForExpressions : public 
ClangASTContext {
   std::unique_ptr
   m_persistent_variables; // These are the persistent variables associated
   // with this process for the expression parser
+  std::unique_ptr m_scratch_ast_source_up;
 };
 
 } // namespace lldb_private

diff  --git a/lldb/source/Symbol/ClangASTContext.cpp 
b/lldb/source/Symbol/ClangASTContext.cpp
index f98e08848199..937951c0608d 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -569,12 +569,6 @@ lldb::TypeSystemSP 
ClangASTContext::CreateInstance(lldb::LanguageType language,
   } else if (target && target->IsValid()) {
 std::shared_ptr ast_sp(
 new ClangASTContextForExpressions(*target, fixed_arch));
-ast_sp->m_scratch_ast_source_up.reset(new ClangASTSource(
-target->shared_from_this(), target->GetClangASTImporter()));
-ast_sp->m_scratch_ast_source_up->InstallASTContext(*ast_sp);
-llvm::IntrusiveRefCntPtr proxy_ast_source(
-ast_sp->m_scratch_ast_source_up->CreateProxy());
-ast_sp->SetExternalSource(proxy_ast_source);
 return ast_sp;
   }
   return lldb::TypeSystemSP();
@@ -630,7 +624,6 @@ void ClangASTContext::Finalize() {
   m_diagnostics_engine_up.reset();
   m_source_manager_up.reset();
   m_language_options_up.reset();
-  m_scratch_ast_source_up.reset();
 }
 
 void ClangASTContext::setSema(Sema *s) {
@@ -9381,7 +9374,19 @@ ClangASTContext::DeclContextGetClangASTContext(const 
CompilerDeclContext &dc) {
 ClangASTContextForExpressions::ClangASTContextForExpressions(Target &target,
  ArchSpec arch)
 : ClangASTContext(arch), m_target_wp(target.shared_from_this()),
-  m_persistent_variables(new ClangPersistentVariables) {}
+  m_persistent_variables(new ClangPersistentVariables) {
+  m_scratch_ast_source_up.reset(new ClangASTSource(
+  target.shared_from_this(), target.GetClangASTImporter()));
+  m_scratch_ast_source_up->InstallASTContext(*this);
+  llvm::IntrusiveRefCntPtr proxy_ast_source(
+  m_scratch_ast_source_up->CreateProxy());
+  SetExternalSource(proxy_ast_source);
+}
+
+void ClangASTContextForExpressions::Finalize() {
+  ClangASTContext::Finalize();
+  m_scratch_ast_source_up.reset();
+}
 
 UserExpression *ClangASTContextForExpressions::GetUserExpression(
 llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.ll

[Lldb-commits] [lldb] 64c6bb3 - test: ensure that we dead-strip in the linker

2019-12-24 Thread Saleem Abdulrasool via lldb-commits

Author: Saleem Abdulrasool
Date: 2019-12-24T10:19:22-08:00
New Revision: 64c6bb37832c2139a91801fece96de8898151079

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

LOG: test: ensure that we dead-strip in the linker

`/OPT:REF` is needed for link to dead strip functions, `/Gy` by itself
is not sufficient.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/functionalities/dead-strip/Makefile

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/dead-strip/Makefile 
b/lldb/packages/Python/lldbsuite/test/functionalities/dead-strip/Makefile
index fa147bb2096a..ea15ec84d685 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/dead-strip/Makefile
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/dead-strip/Makefile
@@ -8,6 +8,7 @@ ifeq "$(OS)" "Darwin"
 LD_EXTRAS = -Xlinker -dead_strip
 else ifeq "$(OS)" "Windows_NT"
 CFLAGS_EXTRAS += /Gw /Gy
+LD_EXTRAS = -Xlinker /OPT:REF
 else
 CFLAGS_EXTRAS += -fdata-sections -ffunction-sections
 LD_EXTRAS = -Wl,--gc-sections



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


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

2019-12-24 Thread Mark de Wever via Phabricator via lldb-commits
Mordante created this revision.
Mordante added reviewers: aaron.ballman, xbolva00.
Mordante added projects: LLVM, LLDB, clang.
Herald added subscribers: bmahjour, usaxena95, kadircet, arphaman, jkorous, 
kbarton, hiraditya, nemanjai, qcolombet, MatzeB.

This avoids new warnings due to D68912  adds 
-Wrange-loop-analysis to -Wall.

This should be the last cleanup patch.


Repository:
  rG LLVM Github Monorepo

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 &C : 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 &C : R600GPUs) {
 if (CPU == C.Name)
   return C.Kind;
   }
@@ -163,12 +163,12 @@
 
 void AMDGPU::fillValidArchListAMDGCN(SmallVectorImpl &Values) {
   // XXX: Should this only report unique canonical names?
-  for (const auto C : AMDGCNGPUs)
+  for (const auto &C : AMDGCNGPUs)
 Values.push_back(C.Name);
 }
 
 void AMDGPU::fillValidArchListR600(SmallVectorImpl &Values) {
-  for (const auto C : R600GPUs)
+  for (const auto &C : 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 &Sub : 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 &Sub : RegisteredSubCommands) {
+  for (auto Sub : RegisteredSubCommands) {
 if (SC == Sub)
   continue;
 addOption(O, Sub);
@@ -318,7 +318,7 @@
   }
 
   bool hasOptions() const {
-for (const auto &S : RegisteredSubCommands) {
+for (auto S : RegisteredSubCommands) {
   if (hasOptions(*S))
 return true;
 }
@@ -2112,7 +2112,7 @@
 static void
 sortSubCommands(const SmallPtrSetImpl &SubMap,
 SmallVectorImpl> &Subs) {
-  for (const auto &S : 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 &LC : Lines.Blocks) {
 Result->createBlock(LC.FileName);
 if (Result->

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

2019-12-24 Thread pre-merge checks [bot] via Phabricator via lldb-commits
merge_guards_bot added a comment.
Herald added a subscriber: wuzish.

{icon check-circle color=green} Unit tests: pass. 61116 tests passed, 0 failed 
and 728 were skipped.

{icon times-circle color=red} clang-tidy: fail. Please fix clang-tidy findings 
.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



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