@@ -87,22 +87,22 @@ TypeTranslator::translatePointer(const clang::QualType &pte,
8787std::shared_ptr<Type>
8888TypeTranslator::translateStructOrUnionOrEnum (const clang::QualType &qtpe) {
8989 std::string name = qtpe.getUnqualifiedType ().getAsString ();
90+ std::string nameWithoutSpace = replaceChar (name, " " , " _" );
9091
91- auto it = aliasesMap. find (name);
92- if (it != aliasesMap. end ()) {
93- /* name contains space: struct <name>.
94- * Use type alias instead struct type */
95- return (*it). second ;
96- }
97- std::shared_ptr<TypeDef> typeDef = ir.getTypeDefWithName (name );
92+ /* If the struct was already declared then there is a TypeDef instance
93+ * with appropriate name.
94+ *
95+ * If there is no such TypeDef then the type is opaque and TypeDef with
96+ * nullptr will be generated for the type. */
97+
98+ std::shared_ptr<TypeDef> typeDef = ir.getTypeDefWithName (nameWithoutSpace );
9899 if (typeDef) {
99- /* type has typedef alias */
100100 return typeDef;
101101 }
102102 /* type is not yet defined.
103- * nullptr will be replaced by actual type */
104- typeDef = ir. addTypeDef ( replaceChar (name, " " , " _ " ), nullptr );
105- addAlias (name, typeDef );
103+ * TypeDef with nullptr will be created.
104+ * nullptr will be replaced by actual type when the type is declared. */
105+ typeDef = ir. addTypeDef (nameWithoutSpace, nullptr );
106106 return typeDef;
107107}
108108
@@ -184,10 +184,6 @@ std::shared_ptr<Type> TypeTranslator::translate(const clang::QualType &qtpe,
184184 }
185185}
186186
187- void TypeTranslator::addAlias (std::string cName, std::shared_ptr<Type> type) {
188- aliasesMap[cName] = type;
189- }
190-
191187std::string TypeTranslator::getTypeFromTypeMap (std::string cType) {
192188 auto it = typeMap.find (cType);
193189 if (it != typeMap.end ()) {
0 commit comments