8000 [DO NOT MERGE] Apply Rust patches on release/8.x by cuviper · Pull Request #1 · rust-lang/llvm-project · GitHub
[go: up one dir, main page]

Skip to content

[DO NOT MERGE] Apply Rust patches on release/8.x #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
865c1f7
Add accessors for MCSubtargetInfo CPU and Feature tables
bitshifter Jul 10, 2016
122c3dc
Fix compile on dist-i686-linux builder
alexcrichton Jul 28, 2017
b73884a
Disable checks for libatomic for now
alexcrichton Jan 24, 2018
392947a
Add knowledge of __rust_{alloc,realloc,dealloc}
nagisa Jun 3, 2017
bd18bd8
Fix compile on dist-x86_64-linux builder
alexcrichton Jul 2, 2018
b1ec4cb
Compile with /MT on MSVC
alexcrichton Feb 11, 2018
1ecf8ed
Add Rust support to Mangled
tromey Jun 25, 2018
9fa3339
Add DIERef::operator==
tromey Jun 25, 2018
e6a7452
Add a missing TypeAndOrName constructor
tromey Jun 25, 2018
ea4ac97
Add Rust support to the Python test harness
tromey Jun 25, 2018
df47965
The Rust plugin
tromey Jun 25, 2018
b8bd5dc
Compute Python library suffix in CMakeLists.txt
tromey Jul 9, 2018
02ddf76
Do not crash when enum discriminant is not recognized
tromey Aug 7, 2018
0e77fbd
Use correct include path for State.h
tromey Sep 5, 2018
0322285
Add "rust-enabled" to --version output
tromey Oct 2, 2018
d957e27
Fix handling of variant parts
tromey Oct 22, 2018
463cd70
Give names to tuple fields
tromey Oct 25, 2018
945de34
Rename tuple fields after discriminant is removed
tromey Oct 26, 2018
ff0a15a
Fix field names when emitting a C structure
tromey Nov 9, 2018
28e0138
Remove by-name cache from RustASTContext
tromey Nov 9, 2018
af32307
Disable enum type test
tromey Nov 14, 2018
2ed5e5d
Read template parameters for structure types
tromey Nov 14, 2018
8027847
Read template parameters for function types
tromey Nov 14, 2018
0fb81ce
Fix the build after the rebase
tromey Nov 27, 2018
a27fbee
Fix DWARFASTParserRust::ParseFunctionFromDWARF for r350943
cuviper Jan 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove by-name cache from RustASTContext
Remove the by-name cache from RustASTContext.  This was not needed and
could interact badly with the DWARF parser.  Closes #22
  • Loading branch information
tromey authored and cuviper committed Jan 16, 2019
commit 28e01380f206c6a17f2487b3b1be2f336b2d060e
6 changes: 2 additions & 4 deletions lldb/include/lldb/Symbol/RustASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,12 @@ class RustASTContext : public TypeSystem {

private:
int m_pointer_byte_size;
std::map<ConstString, std::unique_ptr<RustType>> m_types;
std::set<std::unique_ptr<RustType>> m_anon_types;
std::set<std::unique_ptr<RustType>> m_types;
std::unique_ptr<DWARFASTParser> m_dwarf_ast_parser_ap;

std::unique_ptr<RustDeclContext> m_tu_decl;

RustType *FindCachedType(const lldb_private::ConstString &name);
CompilerType CacheType(const lldb_private::ConstString &name, RustType *new_type);
CompilerType CacheType(RustType *new_type);

RustASTContext(const RustASTContext &) = delete;
const RustASTContext &operator=(const RustASTContext &) = delete;
Expand Down
3 changes: 3 additions & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserRust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ TypeSP DWARFASTParserRust::ParseSimpleType(lldb_private::Log *log, const DWARFDI
compiler_type = m_ast.CreateBoolType(type_name_const_str);
else if (encoding == DW_ATE_float)
compiler_type = m_ast.CreateFloatType(type_name_const_str, byte_size);
else if (byte_size == 0 && type_name_const_str &&
strcmp(type_name_const_str.AsCString(), "()") == 0)
compiler_type = m_ast.CreateTupleType(type_name_const_str, byte_size, false);
else if (encoding == DW_ATE_signed || encoding == DW_ATE_unsigned ||
// DW_ATE_UCS seems to be less used (perhaps
// Fortran-specific?) and since I'm not planning to have
Expand Down
70 changes: 15 additions & 55 deletions lldb/source/Symbol/RustASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1802,40 +1802,22 @@ void RustASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type, Stre
s->PutCString(name.AsCString());
}

RustType *RustASTContext::FindCachedType(const lldb_private::ConstString &name) {
if (name.IsEmpty())
return nullptr;
auto result = m_types.find(name);
if (result == m_types.end ())
return nullptr;
return result->second.get();
}

CompilerType RustASTContext::CacheType(const ConstString &name, RustType *new_type) {
if (name.IsEmpty()) {
// Be sure to keep nameless types alive.
m_anon_types.insert(std::unique_ptr<RustType>(new_type));
} else {
m_types[name].reset(new_type);
}
CompilerType RustASTContext::CacheType(RustType *new_type) {
m_types.insert(std::unique_ptr<RustType>(new_type));
return CompilerType(this, new_type);
}

CompilerType RustASTContext::CreateBoolType(const lldb_private::ConstString &name) {
if (RustType *cached = FindCachedType(name))
return CompilerType(this, cached);
RustType *type = new RustBool(name);
return CacheType(name, type);
return CacheType(type);
}

CompilerType RustASTContext::CreateIntegralType(const lldb_private::ConstString &name,
bool is_signed,
uint64_t byte_size,
bool is_char_type) {
if (RustType *cached = FindCachedType(name))
return CompilerType(this, cached);
RustType *type = new RustIntegral(name, is_signed, byte_size, is_char_type);
return CacheType(name, type);
return CacheType(type);
}

CompilerType RustASTContext::CreateIntrinsicIntegralType(bool is_signed, uint64_t byte_size) {
Expand All @@ -1853,10 +1835,8 @@ CompilerType RustASTContext::CreateCharType() {

CompilerType RustASTContext::CreateFloatType(const lldb_private::ConstString &name,
uint64_t byte_size) {
if (RustType *cached = FindCachedType(name))
return CompilerType(this, cached);
RustType *type = new RustFloat(name, byte_size);
return CacheType(name, type);
return CacheType(type);
}

CompilerType RustASTContext::CreateArrayType(const CompilerType &element_type,
Expand All @@ -1868,53 +1848,41 @@ CompilerType RustASTContext::CreateArrayType(const CompilerType &element_type,
name += "]";
ConstString newname(name);

if (RustType *cached = FindCachedType(newname))
return CompilerType(this, cached);
RustType *type = new RustArray(newname, length, element_type);
return CacheType(newname, type);
return CacheType(type);
}

CompilerType RustASTContext::CreateTypedefType(const ConstString &name, CompilerType impl) {
if (RustType *cached = FindCachedType(name))
return CompilerType(this, cached);
RustType *type = new RustTypedef(name, impl);
return CacheType(name, type);
return CacheType(type);
}

CompilerType
RustASTContext::CreateStructType(const lldb_private::ConstString &name, uint32_t byte_size,
bool has_discriminant) {
if (RustType *cached = FindCachedType(name))
return CompilerType(this, cached);
RustType *type = new RustStruct(name, byte_size, has_discriminant);
return CacheType(name, type);
return CacheType(type);
}

CompilerType
RustASTContext::CreateTupleType(const lldb_private::ConstString &name, uint32_t byte_size,
bool has_discriminant) {
if (RustType *cached = FindCachedType(name))
return CompilerType(this, cached);
RustType *type = new RustTuple(name, byte_size, has_discriminant);
return CacheType(name, type);
return CacheType(type);
}

CompilerType
RustASTContext::CreateUnionType(const lldb_private::ConstString &name, uint32_t byte_size) {
if (RustType *cached = FindCachedType(name))
return CompilerType(this, cached);
RustType *type = new RustUnion(name, byte_size);
return CacheType(name, type);
return CacheType(type);
}

CompilerType
RustASTContext::CreatePointerType(const lldb_private::ConstString &name,
const CompilerType &pointee_type,
uint32_t byte_size) {
if (RustType *cached = FindCachedType(name))
return CompilerType(this, cached);
RustType *type = new RustPointer(name, pointee_type, byte_size);
return CacheType(name, type);
return CacheType(type);
}

void RustASTContext::AddFieldToStruct(const CompilerType &struct_type,
Expand All @@ -1941,39 +1909,31 @@ CompilerType
RustASTContext::CreateFunctionType(const lldb_private::ConstString &name,
const CompilerType &return_type,
const std::vector<CompilerType> &&params) {
if (RustType *cached = FindCachedType(name))
return CompilerType(this, cached);
RustType *type = new RustFunction(name, m_pointer_byte_size, return_type, std::move(params));
return CacheType(name, type);
return CacheType(type);
}

CompilerType
RustASTContext::CreateVoidType() {
ConstString name("()");
if (RustType *cached = FindCachedType(name))
return CompilerType(this, cached);
RustType *type = new RustTuple(name, 0, false);
return CacheType(name, type);
return CacheType(type);
}

CompilerType
RustASTContext::CreateEnumType(const lldb_private::ConstString &name,
uint64_t byte_size, uint32_t discr_offset,
uint32_t discr_byte_size) {
if (RustType *cached = FindCachedType(name))
return CompilerType(this, cached);
RustType *type = new RustEnum(name, byte_size, discr_offset, discr_byte_size);
return CacheType(name, type);
return CacheType(type);
}

CompilerType
RustASTContext::CreateCLikeEnumType(const lldb_private::ConstString &name,
const CompilerType &underlying_type,
std::map<uint64_t, std::string> &&values) {
if (RustType *cached = FindCachedType(name))
return CompilerType(this, cached);
RustType *type = new RustCLikeEnum(name, underlying_type, std::move(values) 4C63 );
return CacheType(name, type);
return CacheType(type);
}

bool
Expand Down
0