@@ -1834,40 +1834,22 @@ void RustASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type, Stre
1834
1834
s->PutCString (name.AsCString ());
1835
1835
}
1836
1836
1837
- RustType *RustASTContext::FindCachedType (const lldb_private::ConstString &name) {
1838
- if (name.IsEmpty ())
1839
- return nullptr ;
1840
- auto result = m_types.find (name);
1841
- if (result == m_types.end ())
1842
- return nullptr ;
1843
- return result->second .get ();
1844
- }
1845
-
1846
- CompilerType RustASTContext::CacheType (const ConstString &name, RustType *new_type) {
1847
- if (name.IsEmpty ()) {
1848
- // Be sure to keep nameless types alive.
1849
- m_anon_types.insert (std::unique_ptr<RustType>(new_type));
1850
- } else {
1851
- m_types[name].reset (new_type);
1852
- }
1837
+ CompilerType RustASTContext::CacheType (RustType *new_type) {
1838
+ m_types.insert (std::unique_ptr<RustType>(new_type));
1853
1839
return CompilerType (this , new_type);
1854
1840
}
1855
1841
1856
1842
CompilerType RustASTContext::CreateBoolType (const lldb_private::ConstString &name) {
1857
- if (RustType *cached = FindCachedType (name))
1858
- return CompilerType (this , cached);
1859
1843
RustType *type = new RustBool (name);
1860
- return CacheType (name, type);
1844
+ return CacheType (type);
1861
1845
}
1862
1846
1863
1847
CompilerType RustASTContext::CreateIntegralType (const lldb_private::ConstString &name,
1864
1848
bool is_signed,
1865
1849
uint64_t byte_size,
1866
1850
bool is_char_type) {
1867
- if (RustType *cached = FindCachedType (name))
1868
- return CompilerType (this , cached);
1869
1851
RustType *type = new RustIntegral (name, is_signed, byte_size, is_char_type);
1870
- return CacheType (name, type);
1852
+ return CacheType (type);
1871
1853
}
1872
1854
1873
1855
CompilerType RustASTContext::CreateIntrinsicIntegralType (bool is_signed, uint64_t byte_size) {
@@ -1885,10 +1867,8 @@ CompilerType RustASTContext::CreateCharType() {
1885
1867
1886
1868
CompilerType RustASTContext::CreateFloatType (const lldb_private::ConstString &name,
1887
1869
uint64_t byte_size) {
1888
- if (RustType *cached = FindCachedType (name))
1889
- return CompilerType (this , cached);
1890
1870
RustType *type = new RustFloat (name, byte_size);
1891
- return CacheType (name, type);
1871
+ return CacheType (type);
1892
1872
}
1893
1873
1894
1874
CompilerType RustASTContext::CreateArrayType (const CompilerType &element_type,
@@ -1900,53 +1880,41 @@ CompilerType RustASTContext::CreateArrayType(const CompilerType &element_type,
1900
1880
name += " ]" ;
1901
1881
ConstString newname (name);
1902
1882
1903
- if (RustType *cached = FindCachedType (newname))
1904
- return CompilerType (this , cached);
1905
1883
RustType *type = new RustArray (newname, length, element_type);
1906
- return CacheType (newname, type);
1884
+ return CacheType (type);
1907
1885
}
1908
1886
1909
1887
CompilerType RustASTContext::CreateTypedefType (const ConstString &name, CompilerType impl) {
1910
- if (RustType *cached = FindCachedType (name))
1911
- return CompilerType (this , cached);
1912
1888
RustType *type = new RustTypedef (name, impl);
1913
- return CacheType (name, type);
1889
+ return CacheType (type);
1914
1890
}
1915
1891
1916
1892
CompilerType
1917
1893
RustASTContext::CreateStructType (const lldb_private::ConstString &name, uint32_t byte_size,
1918
1894
bool has_discriminant) {
1919
- if (RustType *cached = FindCachedType (name))
1920
- return CompilerType (this , cached);
1921
1895
RustType *type = new RustStruct (name, byte_size, has_discriminant);
1922
- return CacheType (name, type);
1896
+ return CacheType (type);
1923
1897
}
1924
1898
1925
1899
CompilerType
1926
1900
RustASTContext::CreateTupleType (const lldb_private::ConstString &name, uint32_t byte_size,
1927
1901
bool has_discriminant) {
1928
- if (RustType *cached = FindCachedType (name))
1929
- return CompilerType (this , cached);
1930
1902
RustType *type = new RustTuple (name, byte_size, has_discriminant);
1931
- return CacheType (name, type);
1903
+ return CacheType (type);
1932
1904
}
1933
1905
1934
1906
CompilerType
1935
1907
RustASTContext::CreateUnionType (const lldb_private::ConstString &name, uint32_t byte_size) {
1936
- if (RustType *cached = FindCachedType (name))
1937
- return CompilerType (this , cached);
1938
1908
RustType *type = new RustUnion (name, byte_size);
1939
- return CacheType (name, type);
1909
+ return CacheType (type);
1940
1910
}
1941
1911
1942
1912
CompilerType
1943
1913
RustASTContext::CreatePointerType (const lldb_private::ConstString &name,
1944
1914
const CompilerType &pointee_type,
1945
1915
uint32_t byte_size) {
1946
- if (RustType *cached = FindCachedType (name))
1947
- return CompilerType (this , cached);
1948
1916
RustType *type = new RustPointer (name, pointee_type, byte_size);
1949
- return CacheType (name, type);
1917
+ return CacheType (type);
1950
1918
}
1951
1919
1952
1920
void RustASTContext::AddFieldToStruct (const CompilerType &struct_type,
@@ -1973,39 +1941,31 @@ CompilerType
1973
1941
RustASTContext::CreateFunctionType (const lldb_private::ConstString &name,
1974
1942
const CompilerType &return_type,
1975
1943
const std::vector<CompilerType> &¶ms) {
1976
- if (RustType *cached = FindCachedType (name))
1977
- return CompilerType (this , cached);
1978
1944
RustType *type = new RustFunction (name, m_pointer_byte_size, return_type, std::move (params));
1979
- return CacheType (name, type);
1945
+ return CacheType (type);
1980
1946
}
1981
1947
1982
1948
CompilerType
1983
1949
RustASTContext::CreateVoidType () {
1984
1950
ConstString name (" ()" );
1985
- if (RustType *cached = FindCachedType (name))
1986
- return CompilerType (this , cached);
1987
1951
RustType *type = new RustTuple (name, 0 , false );
1988
- return CacheType (name, type);
1952
+ return CacheType (type);
1989
1953
}
1990
1954
1991
1955
CompilerType
1992
1956
RustASTContext::CreateEnumType (const lldb_private::ConstString &name,
1993
1957
uint64_t byte_size, uint32_t discr_offset,
1994
1958
uint32_t discr_byte_size) {
1995
- if (RustType *cached = FindCachedType (name))
1996
- return CompilerType (this , cached);
1997
1959
RustType *type = new RustEnum (name, byte_size, discr_offset, discr_byte_size);
1998
- return CacheType (name, type);
1960
+ return CacheType (type);
1999
1961
}
2000
1962
2001
1963
CompilerType
2002
1964
RustASTContext::CreateCLikeEnumType (const lldb_private::ConstString &name,
2003
1965
const CompilerType &underlying_type,
2004
1966
std::map<uint64_t , std::string> &&values) {
2005
- if (RustType *cached = FindCachedType (name))
2006
- return CompilerType (this , cached);
2007
1967
RustType *type = new RustCLikeEnum (name, underlying_type, std::move (values));
2008
- return CacheType (name, type);
1968
+ return CacheType (type);
2009
1969
}
2010
1970
2011
1971
bool
0 commit comments