Update slang for LLVM rebase to r212749.
Change-Id: I5819f9df3212ffcfa8f34c11d3cea29f1fd04878
diff --git a/llvm-rs-as.cpp b/llvm-rs-as.cpp
index 9e61395..b176002 100644
--- a/llvm-rs-as.cpp
+++ b/llvm-rs-as.cpp
@@ -15,7 +15,6 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Verifier.h"
#include "llvm/AsmParser/Parser.h"
@@ -89,7 +88,7 @@
}
std::string ErrorInfo;
- OwningPtr<tool_output_file> Out
+ std::unique_ptr<tool_output_file> Out
(new tool_output_file(OutputFilename.c_str(), ErrorInfo,
llvm::sys::fs::F_None));
if (!ErrorInfo.empty()) {
@@ -128,7 +127,7 @@
// Parse the file now...
SMDiagnostic Err;
- OwningPtr<Module> M(ParseAssemblyFile(InputFilename, Err, Context));
+ std::unique_ptr<Module> M(ParseAssemblyFile(InputFilename, Err, Context));
if (M.get() == 0) {
Err.print(argv[0], errs());
return 1;
diff --git a/llvm-rs-cc.cpp b/llvm-rs-cc.cpp
index e7300d2..72db214 100644
--- a/llvm-rs-cc.cpp
+++ b/llvm-rs-cc.cpp
@@ -22,7 +22,6 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/Option/OptTable.h"
#include "llvm/Support/CommandLine.h"
@@ -30,7 +29,6 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/system_error.h"
#include "llvm/Target/TargetMachine.h"
#include "rs_cc_options.h"
@@ -181,7 +179,7 @@
IOFiles->push_back(std::make_pair(InputFile, OutputFile));
}
- llvm::OwningPtr<slang::SlangRS> Compiler(new slang::SlangRS());
+ std::unique_ptr<slang::SlangRS> Compiler(new slang::SlangRS());
Compiler->init(Opts.mBitWidth, DiagEngine, DiagClient);
int CompileFailed = !Compiler->compile(*IOFiles, *IOFiles32, DepFiles, Opts);
Compiler->reset();
@@ -242,7 +240,7 @@
}
if (Opts.mShowHelp) {
- llvm::OwningPtr<llvm::opt::OptTable> OptTbl(slang::createRSCCOptTable());
+ std::unique_ptr<llvm::opt::OptTable> OptTbl(slang::createRSCCOptTable());
OptTbl->PrintHelp(llvm::outs(), Argv0.c_str(),
"Renderscript source compiler");
return 0;
@@ -284,12 +282,14 @@
llvm::SmallVectorImpl<const char*> &ArgVector,
std::set<std::string> &SavedStrings) {
const char *FName = Arg + 1;
- std::unique_ptr<llvm::MemoryBuffer> MemBuf;
- if (llvm::MemoryBuffer::getFile(FName, MemBuf)) {
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> MBOrErr =
+ llvm::MemoryBuffer::getFile(FName);
+ if (MBOrErr.getError()) {
// Unable to open the file
ArgVector.push_back(SaveStringInSet(SavedStrings, Arg));
return;
}
+ std::unique_ptr<llvm::MemoryBuffer> MemBuf = std::move(MBOrErr.get());
const char *Buf = MemBuf->getBufferStart();
char InQuote = ' ';
diff --git a/rs_cc_options.cpp b/rs_cc_options.cpp
index 987313b..a1f3762 100644
--- a/rs_cc_options.cpp
+++ b/rs_cc_options.cpp
@@ -19,7 +19,6 @@
#include "clang/Driver/Options.h"
#include "clang/Frontend/Utils.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Option/Option.h"
@@ -87,8 +86,8 @@
const char **ArgBegin = ArgVector.data() + 1;
const char **ArgEnd = ArgVector.data() + ArgVector.size();
unsigned MissingArgIndex, MissingArgCount;
- llvm::OwningPtr<llvm::opt::OptTable> OptParser(slang::createRSCCOptTable());
- llvm::OwningPtr<llvm::opt::InputArgList> Args(OptParser->ParseArgs(
+ std::unique_ptr<llvm::opt::OptTable> OptParser(slang::createRSCCOptTable());
+ std::unique_ptr<llvm::opt::InputArgList> Args(OptParser->ParseArgs(
ArgBegin, ArgEnd, MissingArgIndex, MissingArgCount));
// Check for missing argument error.
diff --git a/slang.cpp b/slang.cpp
index d982e4d..7810695 100644
--- a/slang.cpp
+++ b/slang.cpp
@@ -183,7 +183,7 @@
}
mTarget.reset(clang::TargetInfo::CreateTargetInfo(*mDiagEngine,
- mTargetOpts.getPtr()));
+ mTargetOpts));
}
void Slang::createFileManager() {
@@ -218,7 +218,7 @@
// Initialize the preprocessor
mPP->Initialize(getTargetInfo());
clang::FrontendOptions FEOpts;
- clang::InitializePreprocessor(*mPP, *PPOpts, *HSOpts, FEOpts);
+ clang::InitializePreprocessor(*mPP, *PPOpts, FEOpts);
mPragmas.clear();
mPP->AddPragmaHandler(new PragmaRecorder(&mPragmas));
@@ -258,8 +258,8 @@
&mPragmas, OS, OT);
}
-Slang::Slang() : mInitialized(false), mDiagClient(NULL), mOT(OT_Default) {
- mTargetOpts = new clang::TargetOptions();
+Slang::Slang() : mInitialized(false), mDiagClient(NULL),
+ mTargetOpts(new clang::TargetOptions()), mOT(OT_Default) {
GlobalInitialization();
}
diff --git a/slang.h b/slang.h
index c733a52..39cfb56 100644
--- a/slang.h
+++ b/slang.h
@@ -28,7 +28,6 @@
#include "clang/Basic/TargetOptions.h"
#include "clang/Lex/ModuleLoader.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Target/TargetMachine.h"
@@ -82,7 +81,7 @@
bool mInitialized;
// Diagnostics Mediator (An interface for both Producer and Consumer)
- llvm::OwningPtr<clang::Diagnostic> mDiag;
+ std::unique_ptr<clang::Diagnostic> mDiag;
// Diagnostics Engine (Producer and Diagnostics Reporter)
clang::DiagnosticsEngine *mDiagEngine;
@@ -92,34 +91,34 @@
DiagnosticBuffer *mDiagClient;
// The target being compiled for
- llvm::IntrusiveRefCntPtr<clang::TargetOptions> mTargetOpts;
- llvm::OwningPtr<clang::TargetInfo> mTarget;
+ std::shared_ptr<clang::TargetOptions> mTargetOpts;
+ std::unique_ptr<clang::TargetInfo> mTarget;
void createTarget(uint32_t BitWidth);
// File manager (for prepocessor doing the job such as header file search)
- llvm::OwningPtr<clang::FileManager> mFileMgr;
- llvm::OwningPtr<clang::FileSystemOptions> mFileSysOpt;
+ std::unique_ptr<clang::FileManager> mFileMgr;
+ std::unique_ptr<clang::FileSystemOptions> mFileSysOpt;
void createFileManager();
// Source manager (responsible for the source code handling)
- llvm::OwningPtr<clang::SourceManager> mSourceMgr;
+ std::unique_ptr<clang::SourceManager> mSourceMgr;
void createSourceManager();
// Preprocessor (source code preprocessor)
- llvm::OwningPtr<clang::Preprocessor> mPP;
+ std::unique_ptr<clang::Preprocessor> mPP;
void createPreprocessor();
// AST context (the context to hold long-lived AST nodes)
- llvm::OwningPtr<clang::ASTContext> mASTContext;
+ std::unique_ptr<clang::ASTContext> mASTContext;
void createASTContext();
// AST consumer, responsible for code generation
- llvm::OwningPtr<clang::ASTConsumer> mBackend;
+ std::unique_ptr<clang::ASTConsumer> mBackend;
// File names
@@ -135,10 +134,10 @@
OutputType mOT;
// Output stream
- llvm::OwningPtr<llvm::tool_output_file> mOS;
+ std::unique_ptr<llvm::tool_output_file> mOS;
// Dependency output stream
- llvm::OwningPtr<llvm::tool_output_file> mDOS;
+ std::unique_ptr<llvm::tool_output_file> mDOS;
std::vector<std::string> mIncludePaths;
@@ -153,7 +152,7 @@
clang::ASTContext &getASTContext() { return *mASTContext; }
inline clang::TargetOptions const &getTargetOptions() const
- { return *mTargetOpts.getPtr(); }
+ { return *mTargetOpts.get(); }
virtual void initDiagnostic() {}
virtual void initPreprocessor() {}
diff --git a/slang_diagnostic_buffer.h b/slang_diagnostic_buffer.h
index 66a0c9c..56fa0a0 100644
--- a/slang_diagnostic_buffer.h
+++ b/slang_diagnostic_buffer.h
@@ -21,7 +21,6 @@
#include "clang/Basic/Diagnostic.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/Support/raw_ostream.h"
namespace llvm {
@@ -34,7 +33,7 @@
class DiagnosticBuffer : public clang::DiagnosticConsumer {
private:
std::string mDiags;
- llvm::OwningPtr<llvm::raw_string_ostream> mSOS;
+ std::unique_ptr<llvm::raw_string_ostream> mSOS;
public:
DiagnosticBuffer();
diff --git a/slang_rs.cpp b/slang_rs.cpp
index bc46972..6bb5798 100644
--- a/slang_rs.cpp
+++ b/slang_rs.cpp
@@ -165,8 +165,7 @@
}
} else {
llvm::StringMapEntry<ReflectedDefinitionTy> *ME =
- llvm::StringMapEntry<ReflectedDefinitionTy>::Create(RDKey.begin(),
- RDKey.end());
+ llvm::StringMapEntry<ReflectedDefinitionTy>::Create(RDKey);
ME->setValue(std::make_pair(ERT, CurInputFile));
if (!ReflectedDefinitions.insert(ME))
@@ -182,14 +181,14 @@
void SlangRS::initDiagnostic() {
clang::DiagnosticsEngine &DiagEngine = getDiagnostics();
- if (DiagEngine.setDiagnosticGroupMapping("implicit-function-declaration",
- clang::diag::MAP_ERROR))
+ if (DiagEngine.setSeverityForGroup("implicit-function-declaration",
+ clang::diag::Severity::Error))
DiagEngine.Report(clang::diag::warn_unknown_warning_option)
<< "implicit-function-declaration";
- DiagEngine.setDiagnosticMapping(
+ DiagEngine.setSeverity(
clang::diag::ext_typecheck_convert_discards_qualifiers,
- clang::diag::MAP_ERROR,
+ clang::diag::Severity::Error,
clang::SourceLocation());
mDiagErrorInvalidOutputDepParameter =
diff --git a/slang_rs_context.cpp b/slang_rs_context.cpp
index e9bb008..6935b68 100644
--- a/slang_rs_context.cpp
+++ b/slang_rs_context.cpp
@@ -264,8 +264,7 @@
bool RSContext::insertExportType(const llvm::StringRef &TypeName,
RSExportType *ET) {
ExportTypeMap::value_type *NewItem =
- ExportTypeMap::value_type::Create(TypeName.begin(),
- TypeName.end(),
+ ExportTypeMap::value_type::Create(TypeName,
mExportTypes.getAllocator(),
ET);
diff --git a/slang_rs_context.h b/slang_rs_context.h
index 41f5979..166bdbc 100644
--- a/slang_rs_context.h
+++ b/slang_rs_context.h
@@ -25,7 +25,6 @@
#include "clang/Lex/Preprocessor.h"
#include "clang/AST/Mangle.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/StringMap.h"
@@ -85,7 +84,7 @@
int version;
- llvm::OwningPtr<clang::MangleContext> mMangleCtx;
+ std::unique_ptr<clang::MangleContext> mMangleCtx;
bool mIs64Bit;
diff --git a/slang_rs_export_element.cpp b/slang_rs_export_element.cpp
index 6985053..00d5a53 100644
--- a/slang_rs_export_element.cpp
+++ b/slang_rs_export_element.cpp
@@ -62,7 +62,7 @@
EI->vsize = DataElementInfoTable[i].vsize;
llvm::StringRef Name(DataElementInfoTable[i].name);
ElementInfoMap.insert(ElementInfoMapTy::value_type::Create(
- Name.begin(), Name.end(), ElementInfoMap.getAllocator(), EI));
+ Name, ElementInfoMap.getAllocator(), EI));
}
Initialized = true;
}
diff --git a/slang_rs_pragma_handler.cpp b/slang_rs_pragma_handler.cpp
index c562ec3..b150ad6 100644
--- a/slang_rs_pragma_handler.cpp
+++ b/slang_rs_pragma_handler.cpp
@@ -250,7 +250,7 @@
PP.LexUnexpandedToken(PragmaToken);
if (PragmaToken.isNot(clang::tok::r_paren)) {
// Eat the whole string literal
- clang::StringLiteralParser StringLiteral(&PragmaToken, 1, PP);
+ clang::StringLiteralParser StringLiteral(PragmaToken, PP);
if (StringLiteral.hadError) {
// Diagnostics will be generated automatically
return;
diff --git a/slang_utils.cpp b/slang_utils.cpp
index b4fa052..45d1b93 100644
--- a/slang_utils.cpp
+++ b/slang_utils.cpp
@@ -20,14 +20,13 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/system_error.h"
namespace slang {
bool SlangUtils::CreateDirectoryWithParents(llvm::StringRef Dir,
std::string* Error) {
- llvm::error_code EC = llvm::sys::fs::create_directories(Dir);
- if (EC != llvm::errc::success) {
+ std::error_code EC = llvm::sys::fs::create_directories(Dir);
+ if (EC) {
Error->assign(EC.message());
return false;
}