Apply API changes to migrate to CLANG upstream.
Change-Id: I376a8a24c238c4e27d37c4f846b93e2f6e38d79c
diff --git a/slang_backend.cpp b/slang_backend.cpp
index 3877d0f..ac4dd14 100644
--- a/slang_backend.cpp
+++ b/slang_backend.cpp
@@ -251,9 +251,11 @@
Pragma.push_back(llvm::MDString::get(mLLVMContext, I->first));
// And then value
Pragma.push_back(llvm::MDString::get(mLLVMContext, I->second));
+
// Create MDNode and insert into PragmaMetadata
+ llvm::ArrayRef<llvm::Value*> PragmaArray(Pragma);
PragmaMetadata->addOperand(
- llvm::MDNode::get(mLLVMContext, Pragma.data(), Pragma.size()));
+ llvm::MDNode::get(mLLVMContext, PragmaArray));
}
}
diff --git a/slang_rs_backend.cpp b/slang_rs_backend.cpp
index 8ff78d8..b5b50ee 100644
--- a/slang_rs_backend.cpp
+++ b/slang_rs_backend.cpp
@@ -250,10 +250,12 @@
}
}
+ llvm::ArrayRef<llvm::Value*> ExportVarInfoArray(ExportVarInfo);
+ llvm::ArrayRef<llvm::Value*> SlotVarInfoArray(SlotVarInfo);
+
mExportVarMetadata->addOperand(
llvm::MDNode::get(mLLVMContext,
- ExportVarInfo.data(),
- ExportVarInfo.size()) );
+ ExportVarInfoArray));
ExportVarInfo.clear();
@@ -268,8 +270,7 @@
mRSObjectSlotsMetadata->addOperand(
llvm::MDNode::get(mLLVMContext,
- SlotVarInfo.data(),
- SlotVarInfo.size()));
+ SlotVarInfoArray));
}
slotCount++;
@@ -403,10 +404,10 @@
llvm::MDString::get(mLLVMContext, HelperFunctionName.c_str()));
}
+ llvm::ArrayRef<llvm::Value*> ExportFuncInfoArray(ExportFuncInfo);
mExportFuncMetadata->addOperand(
llvm::MDNode::get(mLLVMContext,
- ExportFuncInfo.data(),
- ExportFuncInfo.size()));
+ ExportFuncInfoArray));
ExportFuncInfo.clear();
}
@@ -437,10 +438,10 @@
mExportTypeMetadata =
M->getOrInsertNamedMetadata(RS_EXPORT_TYPE_MN);
+ llvm::ArrayRef<llvm::Value*> ExportTypeInfoArray(ExportTypeInfo);
mExportTypeMetadata->addOperand(
llvm::MDNode::get(mLLVMContext,
- ExportTypeInfo.data(),
- ExportTypeInfo.size()));
+ ExportTypeInfoArray));
// Now, export struct field information to %[struct name]
std::string StructInfoMetadataName("%");
@@ -487,9 +488,9 @@
}
}
+ llvm::ArrayRef<llvm::Value*> FieldInfoArray(FieldInfo);
StructInfoMetadata->addOperand(llvm::MDNode::get(mLLVMContext,
- FieldInfo.data(),
- FieldInfo.size()));
+ FieldInfoArray));
FieldInfo.clear();
}
diff --git a/slang_rs_export_element.cpp b/slang_rs_export_element.cpp
index 2d83652..842e92e 100644
--- a/slang_rs_export_element.cpp
+++ b/slang_rs_export_element.cpp
@@ -139,7 +139,7 @@
break;
} else {
const clang::TypedefType *TT = static_cast<const clang::TypedefType*>(T);
- const clang::TypedefDecl *TD = TT->getDecl();
+ const clang::TypedefNameDecl *TD = TT->getDecl();
EI = GetElementInfo(TD->getName());
if (EI != NULL)
break;
diff --git a/slang_rs_export_type.cpp b/slang_rs_export_type.cpp
index 0364f7b..3a615cd 100644
--- a/slang_rs_export_type.cpp
+++ b/slang_rs_export_type.cpp
@@ -477,21 +477,23 @@
llvm::StringRef Name = RD->getName();
if (Name.empty()) {
- if (RD->getTypedefForAnonDecl() != NULL)
- Name = RD->getTypedefForAnonDecl()->getName();
+ if (RD->getTypedefNameForAnonDecl() != NULL) {
+ Name = RD->getTypedefNameForAnonDecl()->getName();
+ }
- if (Name.empty())
- // Try to find a name from redeclaration (i.e. typedef)
- for (clang::TagDecl::redecl_iterator RI = RD->redecls_begin(),
- RE = RD->redecls_end();
- RI != RE;
- RI++) {
- slangAssert(*RI != NULL && "cannot be NULL object");
+ if (Name.empty()) {
+ // Try to find a name from redeclaration (i.e. typedef)
+ for (clang::TagDecl::redecl_iterator RI = RD->redecls_begin(),
+ RE = RD->redecls_end();
+ RI != RE;
+ RI++) {
+ slangAssert(*RI != NULL && "cannot be NULL object");
- Name = (*RI)->getName();
- if (!Name.empty())
- break;
- }
+ Name = (*RI)->getName();
+ if (!Name.empty())
+ break;
+ }
+ }
}
return Name;
}
diff --git a/slang_rs_metadata_spec_encoder.cpp b/slang_rs_metadata_spec_encoder.cpp
index 5d31aa2..75384c6 100644
--- a/slang_rs_metadata_spec_encoder.cpp
+++ b/slang_rs_metadata_spec_encoder.cpp
@@ -267,8 +267,9 @@
return 0;
if (!EncodeInteger(mModule->getContext(),
FieldName,
- FieldInfo))
+ FieldInfo)) {
return 0;
+ }
// 2. field type
unsigned FieldType = encodeRSType(RS_RECORD_TYPE_GET_FIELD_TYPE(T, i));
@@ -276,18 +277,20 @@
return 0;
if (!EncodeInteger(mModule->getContext(),
FieldType,
- FieldInfo))
+ FieldInfo)) {
return 0;
+ }
// 3. field data kind
if (!EncodeInteger(mModule->getContext(),
RS_RECORD_TYPE_GET_FIELD_DATA_KIND(T, i),
- FieldInfo))
+ FieldInfo)) {
return 0;
+ }
+ llvm::ArrayRef<llvm::Value*> FieldInfoArray(FieldInfo);
RecordInfoMetadata->addOperand(llvm::MDNode::get(mModule->getContext(),
- FieldInfo.data(),
- FieldInfo.size()));
+ FieldInfoArray));
FieldInfo.clear();
}
@@ -312,49 +315,55 @@
// 1. var name
unsigned VarName = joinString(V->name);
- if (!checkReturnIndex(&VarName))
+ if (!checkReturnIndex(&VarName)) {
return -2;
+ }
// 2. type
unsigned Type = encodeRSType(V->type);
llvm::SmallVector<llvm::Value*, 1> VarInfo;
- if (!EncodeInteger(mModule->getContext(), VarName, VarInfo))
+ if (!EncodeInteger(mModule->getContext(), VarName, VarInfo)) {
return -3;
- if (!EncodeInteger(mModule->getContext(), Type, VarInfo))
+ }
+ if (!EncodeInteger(mModule->getContext(), Type, VarInfo)) {
return -4;
+ }
if (mVarInfoMetadata == NULL)
mVarInfoMetadata = mModule->getOrInsertNamedMetadata(RS_EXPORT_VAR_MN);
+ llvm::ArrayRef<llvm::Value*> VarInfoArray(VarInfo);
mVarInfoMetadata->addOperand(llvm::MDNode::get(mModule->getContext(),
- VarInfo.data(),
- VarInfo.size()));
+ VarInfoArray));
return 0;
}
int RSMetadataEncoderInternal::encodeRSFunc(const RSFunction *F) {
// check parameter
- if ((F == NULL) || (F->name == NULL))
+ if ((F == NULL) || (F->name == NULL)) {
return -1;
+ }
// 1. var name
unsigned FuncName = joinString(F->name);
- if (!checkReturnIndex(&FuncName))
+ if (!checkReturnIndex(&FuncName)) {
return -2;
+ }
llvm::SmallVector<llvm::Value*, 1> FuncInfo;
- if (!EncodeInteger(mModule->getContext(), FuncName, FuncInfo))
+ if (!EncodeInteger(mModule->getContext(), FuncName, FuncInfo)) {
return -3;
+ }
if (mFuncInfoMetadata == NULL)
mFuncInfoMetadata = mModule->getOrInsertNamedMetadata(RS_EXPORT_FUNC_MN);
+ llvm::ArrayRef<llvm::Value*> FuncInfoArray(FuncInfo);
mFuncInfoMetadata->addOperand(llvm::MDNode::get(mModule->getContext(),
- FuncInfo.data(),
- FuncInfo.size()));
+ FuncInfoArray));
return 0;
}
@@ -431,9 +440,9 @@
llvm::SmallVector<llvm::Value*, 2> StrTabVal;
StrTabVal.push_back(StrTabMDS);
StrTabVal.push_back(StrIdxMDS);
+ llvm::ArrayRef<llvm::Value*> StrTabValArray(StrTabVal);
RSMetadataStrTab->addOperand(llvm::MDNode::get(mModule->getContext(),
- StrTabVal.data(),
- StrTabVal.size()));
+ StrTabValArray));
return 0;
}
@@ -441,8 +450,9 @@
// Write RS type stream
int RSMetadataEncoderInternal::flushTypeInfo() {
unsigned TypeInfoCount = mEncodedRSTypeInfo.size();
- if (TypeInfoCount <= 0)
+ if (TypeInfoCount <= 0) {
return 0;
+ }
llvm::NamedMDNode *RSTypeInfo =
mModule->getOrInsertNamedMetadata(RS_TYPE_INFO_MN);
@@ -470,8 +480,13 @@
return -1;
}
+ llvm::SmallVector<llvm::Value*, 1> TypeInfo;
+ TypeInfo.push_back(TypeInfoMDS);
+
+ llvm::ArrayRef<llvm::Value*> TypeInfoArray(TypeInfo);
+
RSTypeInfo->addOperand(llvm::MDNode::get(mModule->getContext(),
- &TypeInfoMDS, 1));
+ TypeInfoArray));
free(TypeInfos);
return 0;