Skip to content

Commit c5aaffa

Browse files
authored
Merge pull request #285 from Teemperor/RemoveSwiftCompilerTypeConstructor
[upstreaming] Move CompilerType(swift::Type) constructor to SwiftASTC…
2 parents 0fe4656 + 4cb6bb2 commit c5aaffa

File tree

11 files changed

+112
-103
lines changed

11 files changed

+112
-103
lines changed

lldb/include/lldb/Symbol/CompilerType.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <string>
1414
#include <vector>
1515

16-
#include "lldb/Core/SwiftForward.h"
1716
#include "lldb/lldb-private.h"
1817
#include "llvm/ADT/APSInt.h"
1918

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

3735
CompilerType(const CompilerType &rhs)
3836
: m_type(rhs.m_type), m_type_system(rhs.m_type_system) {}

lldb/include/lldb/Symbol/SwiftASTContext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "Plugins/ExpressionParser/Swift/SwiftPersistentExpressionState.h"
1717
#include "lldb/Core/ClangForward.h"
18+
#include "lldb/Core/SwiftForward.h"
1819
#include "lldb/Core/ThreadSafeDenseMap.h"
1920
#include "lldb/Core/ThreadSafeDenseSet.h"
2021
#include "lldb/Symbol/CompilerType.h"
@@ -66,6 +67,8 @@ namespace lldb_private {
6667

6768
struct SourceModule;
6869

70+
CompilerType ToCompilerType(swift::Type qual_type);
71+
6972
class SwiftASTContext : public TypeSystem {
7073
public:
7174
typedef lldb_utility::Either<CompilerType, swift::Decl *> TypeOrDecl;

lldb/source/Plugins/ExpressionParser/Swift/SwiftASTManipulator.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "lldb/Expression/ExpressionParser.h"
1616
#include "lldb/Expression/ExpressionSourceCode.h"
17+
#include "lldb/Symbol/SwiftASTContext.h"
1718
#include "lldb/Target/Target.h"
1819
#include "lldb/Utility/ConstString.h"
1920
#include "lldb/Utility/Log.h"
@@ -744,7 +745,7 @@ void SwiftASTManipulator::FindVariableDeclarations(
744745
auto type = var_decl->getDeclContext()->mapTypeIntoContext(
745746
var_decl->getInterfaceType());
746747
persistent_info.m_name = name;
747-
persistent_info.m_type = {type.getPointer()};
748+
persistent_info.m_type = ToCompilerType({type.getPointer()});
748749
persistent_info.m_decl = var_decl;
749750

750751
m_variables.push_back(persistent_info);
@@ -810,7 +811,7 @@ void SwiftASTManipulator::InsertResult(
810811
SwiftASTManipulator::ResultLocationInfo &result_info) {
811812
swift::ASTContext &ast_context = m_source_file.getASTContext();
812813

813-
CompilerType return_ast_type(result_type.getPointer());
814+
CompilerType return_ast_type = ToCompilerType(result_type.getPointer());
814815

815816
result_var->overwriteAccess(swift::AccessLevel::Public);
816817
result_var->overwriteSetterAccess(swift::AccessLevel::Public);
@@ -851,7 +852,7 @@ void SwiftASTManipulator::InsertError(swift::VarDecl *error_var,
851852

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

854-
CompilerType error_ast_type(error_type.getPointer());
855+
CompilerType error_ast_type = ToCompilerType(error_type.getPointer());
855856

856857
error_var->overwriteAccess(swift::AccessLevel::Public);
857858
error_var->overwriteSetterAccess(swift::AccessLevel::Public);
@@ -951,7 +952,7 @@ bool SwiftASTManipulator::FixupResultAfterTypeChecking(Status &error) {
951952

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

954-
CompilerType return_ast_type(result_type.getPointer());
955+
CompilerType return_ast_type = ToCompilerType(result_type.getPointer());
955956
swift::Identifier result_var_name =
956957
ast_context.getIdentifier(GetResultName());
957958
SwiftASTManipulatorBase::VariableMetadataSP metadata_sp(
@@ -995,7 +996,8 @@ bool SwiftASTManipulator::FixupResultAfterTypeChecking(Status &error) {
995996
continue;
996997

997998
swift::Type error_type = var_decl->getInterfaceType();
998-
CompilerType error_ast_type(error_type.getPointer());
999+
CompilerType error_ast_type =
1000+
ToCompilerType(error_type.getPointer());
9991001
SwiftASTManipulatorBase::VariableMetadataSP error_metadata_sp(
10001002
new VariableMetadataError());
10011003

lldb/source/Plugins/ExpressionParser/Swift/SwiftPersistentExpressionState.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "SwiftExpressionVariable.h"
1717

18+
#include "lldb/Core/SwiftForward.h"
1819
#include "lldb/Expression/ExpressionVariable.h"
1920

2021
#include "llvm/ADT/DenseMap.h"

lldb/source/Plugins/ExpressionParser/Swift/SwiftREPLMaterializer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef liblldb_SwiftREPLMaterializer_h
1414
#define liblldb_SwiftREPLMaterializer_h
1515

16+
#include "lldb/Core/SwiftForward.h"
1617
#include "lldb/Expression/Materializer.h"
1718

1819
namespace lldb_private {

lldb/source/Plugins/Language/Swift/SwiftFormatters.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ bool lldb_private::formatters::swift::SIMDVector_SummaryProvider(
10441044
if (generic_args.size() != 1)
10451045
return false;
10461046
auto swift_arg_type = generic_args[0];
1047-
CompilerType arg_type(swift_arg_type);
1047+
CompilerType arg_type = ToCompilerType(swift_arg_type);
10481048

10491049
llvm::Optional<uint64_t> opt_arg_size = arg_type.GetByteSize(nullptr);
10501050
if (!opt_arg_size)

lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ std::unique_ptr<Language::TypeScavenger> SwiftLanguage::GetTypeScavenger() {
13141314
name_parts.size() == 1 &&
13151315
name_parts.front() == module->getName().str())
13161316
results.insert(
1317-
CompilerType(swift::ModuleType::get(module)));
1317+
ToCompilerType(swift::ModuleType::get(module)));
13181318
}
13191319
};
13201320

@@ -1461,7 +1461,7 @@ LazyBool SwiftLanguage::IsLogicalTrue(ValueObject &valobj, Status &error) {
14611461
Scalar scalar_value;
14621462

14631463
auto swift_ty = GetCanonicalSwiftType(valobj.GetCompilerType());
1464-
CompilerType valobj_type(swift_ty);
1464+
CompilerType valobj_type = ToCompilerType(swift_ty);
14651465
Flags type_flags(valobj_type.GetTypeInfo());
14661466
if (llvm::isa<SwiftASTContext>(valobj_type.GetTypeSystem())) {
14671467
if (type_flags.AllSet(eTypeIsStructUnion) &&

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwift.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ lldb::TypeSP DWARFASTParserSwift::ParseTypeFromDWARF(const SymbolContext &sc,
206206
return {};
207207
}
208208
preferred_name = name;
209-
compiler_type = {swift_ast_ctx->TheRawPointerType};
209+
compiler_type = ToCompilerType({swift_ast_ctx->TheRawPointerType});
210210
}
211211
}
212212

lldb/source/Symbol/CompilerType.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include "lldb/Core/Debugger.h"
1212
#include "lldb/Core/StreamFile.h"
13-
#include "lldb/Symbol/SwiftASTContext.h"
1413
#include "lldb/Symbol/Type.h"
1514
#include "lldb/Target/ExecutionContext.h"
1615
#include "lldb/Target/Process.h"
@@ -24,21 +23,13 @@
2423
#include <iterator>
2524
#include <mutex>
2625

27-
#include "swift/AST/Type.h"
28-
#include "swift/AST/Types.h"
29-
3026
using namespace lldb;
3127
using namespace lldb_private;
3228

3329
CompilerType::CompilerType(TypeSystem *type_system,
3430
lldb::opaque_compiler_type_t type)
3531
: m_type(type), m_type_system(type_system) {}
3632

37-
CompilerType::CompilerType(swift::Type qual_type)
38-
: m_type(qual_type.getPointer()),
39-
m_type_system(
40-
SwiftASTContext::GetSwiftASTContext(&qual_type->getASTContext())) {}
41-
4233
CompilerType::~CompilerType() {}
4334

4435
// Tests

0 commit comments

Comments
 (0)