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 21, 2019
1 parent 0b370bc commit 177cd3b
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 111 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
2 changes: 2 additions & 0 deletions include/lldb/Symbol/SwiftASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,8 @@ class SwiftASTContext : public TypeSystem {
lldb::StackFrameWP &stack_frame_wp,
swift::SourceFile *source_file, Status &error);

static CompilerType GetSwiftCompilerType(swift::Type swift_type);

protected:
/// This map uses the string value of ConstStrings as the key, and the TypeBase
/// * as the value. Since the ConstString strings are uniqued, we can use
Expand Down
12 changes: 7 additions & 5 deletions source/Plugins/ExpressionParser/Swift/SwiftASTManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ 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 = SwiftASTContext::GetSwiftCompilerType(type);
persistent_info.m_decl = var_decl;

m_variables.push_back(persistent_info);
Expand Down Expand Up @@ -814,7 +814,7 @@ 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::GetSwiftCompilerType(result_type);

result_var->overwriteAccess(swift::AccessLevel::Public);
result_var->overwriteSetterAccess(swift::AccessLevel::Public);
Expand Down Expand Up @@ -855,7 +855,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::GetSwiftCompilerType(error_type);

error_var->overwriteAccess(swift::AccessLevel::Public);
error_var->overwriteSetterAccess(swift::AccessLevel::Public);
Expand Down Expand Up @@ -955,7 +956,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::GetSwiftCompilerType(result_type);
swift::Identifier result_var_name =
ast_context.getIdentifier(GetResultName());
SwiftASTManipulatorBase::VariableMetadataSP metadata_sp(
Expand Down Expand Up @@ -999,7 +1001,7 @@ 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::GetSwiftCompilerType(error_type);
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
2 changes: 1 addition & 1 deletion source/Plugins/Language/Swift/SwiftFormatters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ 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::GetSwiftCompilerType(swift_arg_type);

llvm::Optional<uint64_t> opt_arg_size = arg_type.GetByteSize(nullptr);
if (!opt_arg_size)
Expand Down
7 changes: 5 additions & 2 deletions source/Plugins/Language/Swift/SwiftLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1317,9 +1317,12 @@ 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)));
SwiftASTContext::GetSwiftCompilerType(module_type));
}
return true;
});

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

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 177cd3b

Please sign in to comment.