Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Commit

Permalink
[Symbol] Remove swift from CompilerType
Browse files Browse the repository at this point in the history
I removed clang from CompilerType, so removing swift seems like the natural
progression
  • Loading branch information
bulbazord committed Aug 20, 2019
1 parent c1ab123 commit 5894f26
Show file tree
Hide file tree
Showing 10 changed files with 159 additions and 109 deletions.
2 changes: 0 additions & 2 deletions include/lldb/Symbol/CompilerType.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <string>
#include <vector>

#include "lldb/Core/SwiftForward.h"
#include "lldb/lldb-private.h"
#include "llvm/ADT/APSInt.h"

Expand All @@ -32,7 +31,6 @@ class CompilerType {
public:
// Constructors and Destructors
CompilerType(TypeSystem *type_system, lldb::opaque_compiler_type_t type);
CompilerType(swift::Type qual_type);

CompilerType(const CompilerType &rhs)
: m_type(rhs.m_type), m_type_system(rhs.m_type_system) {}
Expand Down
17 changes: 12 additions & 5 deletions source/Plugins/ExpressionParser/Swift/SwiftASTManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,9 @@ void SwiftASTManipulator::FindVariableDeclarations(
auto type = var_decl->getDeclContext()->mapTypeIntoContext(
var_decl->getInterfaceType());
persistent_info.m_name = name;
persistent_info.m_type = {type.getPointer()};
persistent_info.m_type = CompilerType(
SwiftASTContext::GetSwiftASTContext(&type->getASTContext()),
type.getPointer());
persistent_info.m_decl = var_decl;

m_variables.push_back(persistent_info);
Expand Down Expand Up @@ -814,7 +816,8 @@ void SwiftASTManipulator::InsertResult(
SwiftASTManipulator::ResultLocationInfo &result_info) {
swift::ASTContext &ast_context = m_source_file.getASTContext();

CompilerType return_ast_type(result_type.getPointer());
CompilerType return_ast_type(SwiftASTContext::GetSwiftASTContext(&ast_context),
result_type.getPointer());

result_var->overwriteAccess(swift::AccessLevel::Public);
result_var->overwriteSetterAccess(swift::AccessLevel::Public);
Expand Down Expand Up @@ -855,7 +858,8 @@ void SwiftASTManipulator::InsertError(swift::VarDecl *error_var,

swift::ASTContext &ast_context = m_source_file.getASTContext();

CompilerType error_ast_type(error_type.getPointer());
CompilerType error_ast_type(SwiftASTContext::GetSwiftASTContext(&ast_context),
error_type.getPointer());

error_var->overwriteAccess(swift::AccessLevel::Public);
error_var->overwriteSetterAccess(swift::AccessLevel::Public);
Expand Down Expand Up @@ -955,7 +959,8 @@ bool SwiftASTManipulator::FixupResultAfterTypeChecking(Status &error) {

swift::ASTContext &ast_context = m_source_file.getASTContext();

CompilerType return_ast_type(result_type.getPointer());
CompilerType return_ast_type(SwiftASTContext::GetSwiftASTContext(&ast_context),
result_type.getPointer());
swift::Identifier result_var_name =
ast_context.getIdentifier(GetResultName());
SwiftASTManipulatorBase::VariableMetadataSP metadata_sp(
Expand Down Expand Up @@ -999,7 +1004,9 @@ bool SwiftASTManipulator::FixupResultAfterTypeChecking(Status &error) {
continue;

swift::Type error_type = var_decl->getInterfaceType();
CompilerType error_ast_type(error_type.getPointer());
CompilerType error_ast_type(SwiftASTContext::GetSwiftASTContext(
&error_type->getASTContext()),
error_type.getPointer());
SwiftASTManipulatorBase::VariableMetadataSP error_metadata_sp(
new VariableMetadataError());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

// Project includes
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/SwiftForward.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Symbol/TaggedASTType.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#ifndef liblldb_SwiftREPLMaterializer_h
#define liblldb_SwiftREPLMaterializer_h

#include "lldb/Core/SwiftForward.h"
#include "lldb/Expression/Materializer.h"

namespace lldb_private {
Expand Down
4 changes: 3 additions & 1 deletion source/Plugins/Language/Swift/SwiftFormatters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,9 @@ bool lldb_private::formatters::swift::SIMDVector_SummaryProvider(
if (generic_args.size() != 1)
return false;
auto swift_arg_type = generic_args[0];
CompilerType arg_type(swift_arg_type);
CompilerType arg_type(
SwiftASTContext::GetSwiftASTContext(&swift_arg_type->getASTContext()),
swift_arg_type.getPointer());

llvm::Optional<uint64_t> opt_arg_size = arg_type.GetByteSize(nullptr);
if (!opt_arg_size)
Expand Down
9 changes: 7 additions & 2 deletions source/Plugins/Language/Swift/SwiftLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1317,9 +1317,14 @@ std::unique_ptr<Language::TypeScavenger> SwiftLanguage::GetTypeScavenger() {
results.insert(result);
} else if (local_results.empty() && module &&
name_parts.size() == 1 &&
name_parts.front() == module->getName().str())
name_parts.front() ==
module->getName().str()) {
auto module_type = swift::ModuleType::get(module);
results.insert(
CompilerType(swift::ModuleType::get(module)));
CompilerType(SwiftASTContext::GetSwiftASTContext(
&module_type->getASTContext()),
module_type));
}
return true;
});

Expand Down
4 changes: 3 additions & 1 deletion source/Plugins/SymbolFile/DWARF/DWARFASTParserSwift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ lldb::TypeSP DWARFASTParserSwift::ParseTypeFromDWARF(const SymbolContext &sc,
return {};
}
preferred_name = name;
compiler_type = {swift_ast_ctx->TheRawPointerType};
compiler_type =
CompilerType(SwiftASTContext::GetSwiftASTContext(swift_ast_ctx),
swift_ast_ctx->TheRawPointerType.getPointer());
}
}

Expand Down
9 changes: 0 additions & 9 deletions source/Symbol/CompilerType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "lldb/Core/Debugger.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Symbol/SwiftASTContext.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
Expand All @@ -24,21 +23,13 @@
#include <iterator>
#include <mutex>

#include "swift/AST/Type.h"
#include "swift/AST/Types.h"

using namespace lldb;
using namespace lldb_private;

CompilerType::CompilerType(TypeSystem *type_system,
lldb::opaque_compiler_type_t type)
: m_type(type), m_type_system(type_system) {}

CompilerType::CompilerType(swift::Type qual_type)
: m_type(qual_type.getPointer()),
m_type_system(
SwiftASTContext::GetSwiftASTContext(&qual_type->getASTContext())) {}

CompilerType::~CompilerType() {}

// Tests
Expand Down
Loading

0 comments on commit 5894f26

Please sign in to comment.