@@ -34,19 +34,17 @@ TypeTranslator::TypeTranslator(clang::ASTContext *ctx_, IR &ir)
3434}
3535
3636std::shared_ptr<Type>
37- TypeTranslator::translateFunctionPointer (const clang::QualType &qtpe,
38- const std::string *avoid) {
37+ TypeTranslator::translateFunctionPointer (const clang::QualType &qtpe) {
3938 const auto *ptr = qtpe.getTypePtr ()->getAs <clang::PointerType>();
4039 const clang::QualType &inner = ptr->getPointeeType ();
4140
4241 if (inner->isFunctionProtoType ()) {
4342 const auto *fc = inner->getAs <clang::FunctionProtoType>();
44- std::shared_ptr<Type> returnType =
45- translate (fc->getReturnType (), avoid);
43+ std::shared_ptr<Type> returnType = translate (fc->getReturnType ());
4644 std::vector<std::shared_ptr<const Type>> parametersTypes;
4745
4846 for (const clang::QualType ¶m : fc->param_types ()) {
49- parametersTypes.push_back (translate (param, avoid ));
47+ parametersTypes.push_back (translate (param));
5048 }
5149
5250 return std::make_shared<FunctionPointerType>(
@@ -61,8 +59,7 @@ TypeTranslator::translateFunctionPointer(const clang::QualType &qtpe,
6159}
6260
6361std::shared_ptr<Type>
64- TypeTranslator::translatePointer (const clang::QualType &pte,
65- const std::string *avoid) {
62+ TypeTranslator::translatePointer (const clang::QualType &pte) {
6663
6764 if (pte->isBuiltinType ()) {
6865 const clang::BuiltinType *as = pte->getAs <clang::BuiltinType>();
@@ -81,7 +78,7 @@ TypeTranslator::translatePointer(const clang::QualType &pte,
8178 }
8279 }
8380
84- return std::make_shared<PointerType>(translate (pte, avoid ));
81+ return std::make_shared<PointerType>(translate (pte));
8582}
8683
8784std::shared_ptr<Type>
@@ -120,10 +117,9 @@ TypeTranslator::translateStructOrUnion(const clang::QualType &qtpe) {
120117}
121118
122119std::shared_ptr<Type>
123- TypeTranslator::translateConstantArray (const clang::ConstantArrayType *ar,
124- const std::string *avoid) {
120+ TypeTranslator::translateConstantArray (const clang::ConstantArrayType *ar) {
125121 const uint64_t size = ar->getSize ().getZExtValue ();
126- std::shared_ptr<Type> elementType = translate (ar->getElementType (), avoid );
122+ std::shared_ptr<Type> elementType = translate (ar->getElementType ());
127123 if (elementType == nullptr ) {
128124 llvm::errs () << " Failed to translate array type "
129125 << ar->getElementType ().getAsString () << " \n " ;
@@ -133,30 +129,20 @@ TypeTranslator::translateConstantArray(const clang::ConstantArrayType *ar,
133129 return std::make_shared<ArrayType>(elementType, size);
134130}
135131
136- std::shared_ptr<Type> TypeTranslator::translate (const clang::QualType &qtpe,
137- const std::string *avoid) {
132+ std::shared_ptr<Type> TypeTranslator::translate (const clang::QualType &qtpe) {
138133
139134 const clang::Type *tpe = qtpe.getTypePtr ();
140135
141- if (typeEquals (tpe, avoid)) {
142- // This is a type that we want to avoid the usage.
143- // Êxample: A struct that has a pointer to itself
144- uint64_t sizeInBits = ctx->getTypeSize (tpe);
145- assert (sizeInBits % 8 == 0 );
146- return std::make_shared<ArrayType>(
147- std::make_shared<PrimitiveType>(" Byte" ), sizeInBits / 8 );
148- }
149-
150136 if (tpe->isFunctionType ()) {
151137 return nullptr ;
152138 }
153139
154140 if (tpe->isFunctionPointerType ()) {
155- return translateFunctionPointer (qtpe, avoid );
141+ return translateFunctionPointer (qtpe);
156142
157143 } else if (tpe->isPointerType ()) {
158144 return translatePointer (
159- tpe->getAs <clang::PointerType>()->getPointeeType (), avoid );
145+ tpe->getAs <clang::PointerType>()->getPointeeType ());
160146
161147 } else if (qtpe->isStructureType ()) {
162148 return translateStructOrUnion (qtpe);
@@ -168,10 +154,9 @@ std::shared_ptr<Type> TypeTranslator::translate(const clang::QualType &qtpe,
168154 return translateStructOrUnionOrEnum (qtpe);
169155
170156 } else if (qtpe->isConstantArrayType ()) {
171- return translateConstantArray (ctx->getAsConstantArrayType (qtpe), avoid );
157+ return translateConstantArray (ctx->getAsConstantArrayType (qtpe));
172158 } else if (qtpe->isArrayType ()) {
173- return translatePointer (ctx->getAsArrayType (qtpe)->getElementType (),
174- avoid);
159+ return translatePointer (ctx->getAsArrayType (qtpe)->getElementType ());
175160 } else {
176161
177162 auto found = typeMap.find (qtpe.getUnqualifiedType ().getAsString ());
0 commit comments