Apply changes to migrate to LLVM upstream Oct 20th 2011.
- StructType::isAnonymous is renamed to StructType::isLiteral.
- PassManagerBuilder has been moved from
llvm/Support/PassManagerBuilder.h to
llvm/Transforms/IPO/PassManagerBuilder.h
- Include llvm/Transforms/IPO.h for llvm::createInternalizePass.
- clang::DiagClient has be renamed to clang::DiagnosticConsumer.
Besides, we have to implement one additional pure virtual method
'clone' for create a clone of slang::DiagnosticBuffer.
- llvm::Linker::LinkModules comes with one additional parameter.
Passing llvm::Linker::DestroySource should be equivalent to
the old code we were using.
- slang::Slang is now derived from clang::ModuleLoader and implemented
loadModule pure virtual method (though we will always return NULL.)
- clang::Preprocessor is taking one additional parameter for
clang::ModuleLoader.
- clang::Diagnostic has been changed. A lot of the method has been
moved to clang::DiagnosticsEngine, and we can no longer 'Report' a
diagnostic from clang::Diagnostic. We have to use
clang::DiagnosticEngine instead.
- llvm::setCodeModel has been removed.
Change-Id: I1f2a4cbeaf61a8ed1d0d635a5a0e1baa90d99d07
diff --git a/slang_rs_backend.cpp b/slang_rs_backend.cpp
index 0119cc9..d4a081b 100644
--- a/slang_rs_backend.cpp
+++ b/slang_rs_backend.cpp
@@ -43,7 +43,7 @@
namespace slang {
RSBackend::RSBackend(RSContext *Context,
- clang::Diagnostic *Diags,
+ clang::DiagnosticsEngine *DiagEngine,
const clang::CodeGenOptions &CodeGenOpts,
const clang::TargetOptions &TargetOpts,
PragmaList *Pragmas,
@@ -51,22 +51,16 @@
Slang::OutputType OT,
clang::SourceManager &SourceMgr,
bool AllowRSPrefix)
- : Backend(Diags,
- CodeGenOpts,
- TargetOpts,
- Pragmas,
- OS,
- OT),
- mContext(Context),
- mSourceMgr(SourceMgr),
- mAllowRSPrefix(AllowRSPrefix),
- mExportVarMetadata(NULL),
- mExportFuncMetadata(NULL),
- mExportForEachMetadata(NULL),
- mExportTypeMetadata(NULL),
- mRSObjectSlotsMetadata(NULL),
- mRefCount(mContext->getASTContext()) {
- return;
+ : Backend(DiagEngine, CodeGenOpts, TargetOpts, Pragmas, OS, OT),
+ mContext(Context),
+ mSourceMgr(SourceMgr),
+ mAllowRSPrefix(AllowRSPrefix),
+ mExportVarMetadata(NULL),
+ mExportFuncMetadata(NULL),
+ mExportForEachMetadata(NULL),
+ mExportTypeMetadata(NULL),
+ mRSObjectSlotsMetadata(NULL),
+ mRefCount(mContext->getASTContext()) {
}
// 1) Add zero initialization of local RS object types
@@ -92,11 +86,12 @@
if (!FD->getName().startswith("rs")) // Check prefix
continue;
if (!SlangRS::IsFunctionInRSHeaderFile(FD, mSourceMgr))
- mDiags.Report(clang::FullSourceLoc(FD->getLocation(), mSourceMgr),
- mDiags.getCustomDiagID(clang::Diagnostic::Error,
- "invalid function name prefix, "
- "\"rs\" is reserved: '%0'"))
- << FD->getName();
+ mDiagEngine.Report(
+ clang::FullSourceLoc(FD->getLocation(), mSourceMgr),
+ mDiagEngine.getCustomDiagID(clang::DiagnosticsEngine::Error,
+ "invalid function name prefix, "
+ "\"rs\" is reserved: '%0'"))
+ << FD->getName();
}
}
@@ -162,11 +157,13 @@
int version = mContext->getVersion();
if (version == 0) {
// Not setting a version is an error
- mDiags.Report(mDiags.getCustomDiagID(clang::Diagnostic::Error,
- "Missing pragma for version in source file"));
+ mDiagEngine.Report(mDiagEngine.getCustomDiagID(
+ clang::DiagnosticsEngine::Error,
+ "Missing pragma for version in source file"));
} else if (version > 1) {
- mDiags.Report(mDiags.getCustomDiagID(clang::Diagnostic::Error,
- "Pragma for version in source file must be set to 1"));
+ mDiagEngine.Report(mDiagEngine.getCustomDiagID(
+ clang::DiagnosticsEngine::Error,
+ "Pragma for version in source file must be set to 1"));
}
// Create a static global destructor if necessary (to handle RS object
@@ -370,12 +367,11 @@
// parameter .p
for (size_t i = 0; i < EF->getNumParameters(); i++) {
// getelementptr
- Idx[1] =
- llvm::ConstantInt::get(
- llvm::Type::getInt32Ty(mLLVMContext), i);
- llvm::Value *Ptr = IB->CreateInBoundsGEP(HelperFunctionParameter,
- Idx,
- Idx + 2);
+ Idx[1] = llvm::ConstantInt::get(
+ llvm::Type::getInt32Ty(mLLVMContext), i);
+
+ llvm::Value *Ptr =
+ IB->CreateInBoundsGEP(HelperFunctionParameter, Idx);
// load
llvm::Value *V = IB->CreateLoad(Ptr);