@@ -1802,40 +1802,22 @@ void RustASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type, Stre
1802
1802
s->PutCString (name.AsCString ());
1803
1803
}
1804
1804
1805
- RustType *RustASTContext::FindCachedType (const lldb_private::ConstString &name) {
1806
- if (name.IsEmpty ())
1807
- return nullptr ;
1808
- auto result = m_types.find (name);
1809
- if (result == m_types.end ())
1810
- return nullptr ;
1811
- return result->second .get ();
1812
- }
1813
-
1814
- CompilerType RustASTContext::CacheType (const ConstString &name, RustType *new_type) {
1815
- if (name.IsEmpty ()) {
1816
- // Be sure to keep nameless types alive.
1817
- m_anon_types.insert (std::unique_ptr<RustType>(new_type));
1818
- } else {
1819
- m_types[name].reset (new_type);
1820
- }
1805
+ CompilerType RustASTContext::CacheType (RustType *new_type) {
1806
+ m_types.insert (std::unique_ptr<RustType>(new_type));
1821
1807
return CompilerType (this , new_type);
1822
1808
}
1823
1809
1824
1810
CompilerType RustASTContext::CreateBoolType (const lldb_private::ConstString &name) {
1825
- if (RustType *cached = FindCachedType (name))
1826
- return CompilerType (this , cached);
1827
1811
RustType *type = new RustBool (name);
1828
- return CacheType (name, type);
1812
+ return CacheType (type);
1829
1813
}
1830
1814
1831
1815
CompilerType RustASTContext::CreateIntegralType (const lldb_private::ConstString &name,
1832
1816
bool is_signed,
1833
1817
uint64_t byte_size,
1834
1818
bool is_char_type) {
1835
- if (RustType *cached = FindCachedType (name))
1836
- return CompilerType (this , cached);
1837
1819
RustType *type = new RustIntegral (name, is_signed, byte_size, is_char_type);
1838
- return CacheType (name, type);
1820
+ return CacheType (type);
1839
1821
}
1840
1822
1841
1823
CompilerType RustASTContext::CreateIntrinsicIntegralType (bool is_signed, uint64_t byte_size) {
@@ -1853,10 +1835,8 @@ CompilerType RustASTContext::CreateCharType() {
1853
1835
1854
1836
CompilerType RustASTContext::CreateFloatType (const lldb_private::ConstString &name,
1855
1837
uint64_t byte_size) {
1856
- if (RustType *cached = FindCachedType (name))
1857
- return CompilerType (this , cached);
1858
1838
RustType *type = new RustFloat (name, byte_size);
1859
- return CacheType (name, type);
1839
+ return CacheType (type);
1860
1840
}
1861
1841
1862
1842
CompilerType RustASTContext::CreateArrayType (const CompilerType &element_type,
@@ -1868,53 +1848,41 @@ CompilerType RustASTContext::CreateArrayType(const CompilerType &element_type,
1868
1848
name += " ]" ;
1869
1849
ConstString newname (name);
1870
1850
1871
- if (RustType *cached = FindCachedType (newname))
1872
- return CompilerType (this , cached);
1873
1851
RustType *type = new RustArray (newname, length, element_type);
1874
- return CacheType (newname, type);
1852
+ return CacheType (type);
1875
1853
}
1876
1854
1877
1855
CompilerType RustASTContext::CreateTypedefType (const ConstString &name, CompilerType impl) {
1878
- if (RustType *cached = FindCachedType (name))
1879
- return CompilerType (this , cached);
1880
1856
RustType *type = new RustTypedef (name, impl);
1881
- return CacheType (name, type);
1857
+ return CacheType (type);
1882
1858
}
1883
1859
1884
1860
CompilerType
1885
1861
RustASTContext::CreateStructType (const lldb_private::ConstString &name, uint32_t byte_size,
1886
1862
bool has_discriminant) {
1887
- if (RustType *cached = FindCachedType (name))
1888
- return CompilerType (this , cached);
1889
1863
RustType *type = new RustStruct (name, byte_size, has_discriminant);
1890
- return CacheType (name, type);
1864
+ return CacheType (type);
1891
1865
}
1892
1866
1893
1867
CompilerType
1894
1868
RustASTContext::CreateTupleType (const lldb_private::ConstString &name, uint32_t byte_size,
1895
1869
bool has_discriminant) {
1896
- if (RustType *cached = FindCachedType (name))
1897
- return CompilerType (this , cached);
1898
1870
RustType *type = new RustTuple (name, byte_size, has_discriminant);
1899
- return CacheType (name, type);
1871
+ return CacheType (type);
1900
1872
}
1901
1873
1902
1874
CompilerType
1903
1875
RustASTContext::CreateUnionType (const lldb_private::ConstString &name, uint32_t byte_size) {
1904
- if (RustType *cached = FindCachedType (name))
1905
- return CompilerType (this , cached);
1906
1876
RustType *type = new RustUnion (name, byte_size);
1907
- return CacheType (name, type);
1877
+ return CacheType (type);
1908
1878
}
1909
1879
1910
1880
CompilerType
1911
1881
RustASTContext::CreatePointerType (const lldb_private::ConstString &name,
1912
1882
const CompilerType &pointee_type,
1913
1883
uint32_t byte_size) {
1914
- if (RustType *cached = FindCachedType (name))
1915
- return CompilerType (this , cached);
1916
1884
RustType *type = new RustPointer (name, pointee_type, byte_size);
1917
- return CacheType (name, type);
1885
+ return CacheType (type);
1918
1886
}
1919
1887
1920
1888
void RustASTContext::AddFieldToStruct (const CompilerType &struct_type,
@@ -1941,39 +1909,31 @@ CompilerType
1941
1909
RustASTContext::CreateFunctionType (const lldb_private::ConstString &name,
1942
1910
const CompilerType &return_type,
1943
1911
const std::vector<CompilerType> &¶ms) {
1944
- if (RustType *cached = FindCachedType (name))
1945
- return CompilerType (this , cached);
1946
1912
RustType *type = new RustFunction (name, m_pointer_byte_size, return_type, std::move (params));
1947
- return CacheType (name, type);
1913
+ return CacheType (type);
1948
1914
}
1949
1915
1950
1916
CompilerType
1951
1917
RustASTContext::CreateVoidType () {
1952
1918
ConstString name (" ()" );
1953
- if (RustType *cached = FindCachedType (name))
1954
- return CompilerType (this , cached);
1955
1919
RustType *type = new RustTuple (name, 0 , false );
1956
- return CacheType (name, type);
1920
+ return CacheType (type);
1957
1921
}
1958
1922
1959
1923
CompilerType
1960
1924
RustASTContext::CreateEnumType (const lldb_private::ConstString &name,
1961
1925
uint64_t byte_size, uint32_t discr_offset,
1962
1926
uint32_t discr_byte_size) {
1963
- if (RustType *cached = FindCachedType (name))
1964
- return CompilerType (this , cached);
1965
1927
RustType *type = new RustEnum (name, byte_size, discr_offset, discr_byte_size);
1966
- return CacheType (name, type);
1928
+ return CacheType (type);
1967
1929
}
1968
1930
1969
1931
CompilerType
1970
1932
RustASTContext::CreateCLikeEnumType (const lldb_private::ConstString &name,
1971
1933
const CompilerType &underlying_type,
1972
1934
std::map<uint64_t , std::string> &&values) {
1973
- if (RustType *cached = FindCachedType (name))
1974
- return CompilerType (this , cached);
1975
1935
RustType *type = new RustCLikeEnum (name, underlying_type, std::move (values));
1976
- return CacheType (name, type);
1936
+ return CacheType (type);
1977
1937
}
1978
1938
1979
1939
bool
0 commit comments