De-virtualize the RSExportType::getClass().
diff --git a/slang_rs_export_type.cpp b/slang_rs_export_type.cpp
index e0f678c..9324c3d 100644
--- a/slang_rs_export_type.cpp
+++ b/slang_rs_export_type.cpp
@@ -391,8 +391,11 @@
ET->getLLVMType());
}
-RSExportType::RSExportType(RSContext *Context, const llvm::StringRef &Name)
+RSExportType::RSExportType(RSContext *Context,
+ ExportClass Class,
+ const llvm::StringRef &Name)
: mContext(Context),
+ mClass(Class),
// Make a copy on Name since memory stored @Name is either allocated in
// ASTContext or allocated in GetTypeName which will be destroyed later.
mName(Name.data(), Name.size()),
@@ -551,7 +554,8 @@
if ((DT == DataTypeUnknown) || TypeName.empty())
return NULL;
else
- return new RSExportPrimitiveType(Context, TypeName, DT, DK, Normalized);
+ return new RSExportPrimitiveType(Context, ExportClassPrimitive, TypeName,
+ DT, DK, Normalized);
}
RSExportPrimitiveType *RSExportPrimitiveType::Create(RSContext *Context,
@@ -564,10 +568,6 @@
return NULL;
}
-RSExportType::ExportClass RSExportPrimitiveType::getClass() const {
- return RSExportType::ExportClassPrimitive;
-}
-
const llvm::Type *RSExportPrimitiveType::convertToLLVMType() const {
llvm::LLVMContext &C = getRSContext()->getLLVMContext();
@@ -659,10 +659,6 @@
return new RSExportPointerType(Context, TypeName, PointeeET);
}
-RSExportType::ExportClass RSExportPointerType::getClass() const {
- return RSExportType::ExportClassPointer;
-}
-
const llvm::Type *RSExportPointerType::convertToLLVMType() const {
const llvm::Type *PointeeType = mPointeeType->getLLVMType();
return llvm::PointerType::getUnqual(PointeeType);
@@ -757,10 +753,6 @@
return NULL;
}
-RSExportType::ExportClass RSExportVectorType::getClass() const {
- return RSExportType::ExportClassVector;
-}
-
const llvm::Type *RSExportVectorType::convertToLLVMType() const {
const llvm::Type *ElementType = RSExportPrimitiveType::convertToLLVMType();
return llvm::VectorType::get(ElementType, getNumElement());
@@ -825,10 +817,6 @@
return new RSExportMatrixType(Context, TypeName, Dim);
}
-RSExportType::ExportClass RSExportMatrixType::getClass() const {
- return RSExportType::ExportClassMatrix;
-}
-
const llvm::Type *RSExportMatrixType::convertToLLVMType() const {
// Construct LLVM type:
// struct {
@@ -866,10 +854,6 @@
Size);
}
-RSExportType::ExportClass RSExportConstantArrayType::getClass() const {
- return RSExportType::ExportClassConstantArray;
-}
-
const llvm::Type *RSExportConstantArrayType::convertToLLVMType() const {
return llvm::ArrayType::get(mElementType->getLLVMType(), getSize());
}
@@ -945,10 +929,6 @@
return ERT;
}
-RSExportType::ExportClass RSExportRecordType::getClass() const {
- return RSExportType::ExportClassRecord;
-}
-
const llvm::Type *RSExportRecordType::convertToLLVMType() const {
std::vector<const llvm::Type*> FieldTypes;