зеркало из https://github.com/microsoft/clang-1.git
Update for LLVMContext+Module change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74615 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
a3844922f6
Коммит
42253cc3bc
|
@ -18,6 +18,7 @@
|
|||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
class LLVMContext;
|
||||
class Module;
|
||||
}
|
||||
|
||||
|
@ -34,7 +35,8 @@ namespace clang {
|
|||
|
||||
CodeGenerator *CreateLLVMCodeGen(Diagnostic &Diags,
|
||||
const std::string &ModuleName,
|
||||
const CompileOptions &CO);
|
||||
const CompileOptions &CO,
|
||||
llvm::LLVMContext* C);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace llvm {
|
||||
class Module;
|
||||
class LLVMContext;
|
||||
namespace sys { class Path; }
|
||||
}
|
||||
namespace clang {
|
||||
|
@ -79,7 +80,8 @@ ASTConsumer *CreateBackendConsumer(BackendAction Action,
|
|||
const LangOptions &Features,
|
||||
const CompileOptions &CompileOpts,
|
||||
const std::string &ModuleID,
|
||||
llvm::raw_ostream *OS);
|
||||
llvm::raw_ostream *OS,
|
||||
llvm::LLVMContext* C);
|
||||
|
||||
// HTML printer: uses the rewriter to convert source code to HTML with
|
||||
// syntax highlighting suitable for viewing in a web-browser.
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "clang/AST/Expr.h"
|
||||
#include "clang/Basic/Diagnostic.h"
|
||||
#include "clang/Basic/TargetInfo.h"
|
||||
#include "llvm/LLVMContext.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
|
@ -37,8 +38,8 @@ namespace {
|
|||
llvm::OwningPtr<CodeGen::CodeGenModule> Builder;
|
||||
public:
|
||||
CodeGeneratorImpl(Diagnostic &diags, const std::string& ModuleName,
|
||||
const CompileOptions &CO)
|
||||
: Diags(diags), CompileOpts(CO), M(new llvm::Module(ModuleName)) {}
|
||||
const CompileOptions &CO, llvm::LLVMContext* C)
|
||||
: Diags(diags), CompileOpts(CO), M(new llvm::Module(ModuleName, C)) {}
|
||||
|
||||
virtual ~CodeGeneratorImpl() {}
|
||||
|
||||
|
@ -95,6 +96,7 @@ namespace {
|
|||
|
||||
CodeGenerator *clang::CreateLLVMCodeGen(Diagnostic &Diags,
|
||||
const std::string& ModuleName,
|
||||
const CompileOptions &CO) {
|
||||
return new CodeGeneratorImpl(Diags, ModuleName, CO);
|
||||
const CompileOptions &CO,
|
||||
llvm::LLVMContext* C) {
|
||||
return new CodeGeneratorImpl(Diags, ModuleName, CO, C);
|
||||
}
|
||||
|
|
|
@ -75,13 +75,14 @@ namespace {
|
|||
public:
|
||||
BackendConsumer(BackendAction action, Diagnostic &Diags,
|
||||
const LangOptions &langopts, const CompileOptions &compopts,
|
||||
const std::string &infile, llvm::raw_ostream* OS) :
|
||||
const std::string &infile, llvm::raw_ostream* OS,
|
||||
LLVMContext* C) :
|
||||
Action(action),
|
||||
CompileOpts(compopts),
|
||||
AsmOutStream(OS),
|
||||
LLVMIRGeneration("LLVM IR Generation Time"),
|
||||
CodeGenerationTime("Code Generation Time"),
|
||||
Gen(CreateLLVMCodeGen(Diags, infile, compopts)),
|
||||
Gen(CreateLLVMCodeGen(Diags, infile, compopts, C)),
|
||||
TheModule(0), TheTargetData(0), ModuleProvider(0),
|
||||
CodeGenPasses(0), PerModulePasses(0), PerFunctionPasses(0) {
|
||||
|
||||
|
@ -359,6 +360,8 @@ ASTConsumer *clang::CreateBackendConsumer(BackendAction Action,
|
|||
const LangOptions &LangOpts,
|
||||
const CompileOptions &CompileOpts,
|
||||
const std::string& InFile,
|
||||
llvm::raw_ostream* OS) {
|
||||
return new BackendConsumer(Action, Diags, LangOpts, CompileOpts, InFile, OS);
|
||||
llvm::raw_ostream* OS,
|
||||
LLVMContext* C) {
|
||||
return new BackendConsumer(Action, Diags, LangOpts, CompileOpts,
|
||||
InFile, OS, C);
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "clang/Basic/SourceManager.h"
|
||||
#include "clang/Basic/TargetInfo.h"
|
||||
#include "clang/Basic/Version.h"
|
||||
#include "llvm/LLVMContext.h"
|
||||
#include "llvm/ADT/OwningPtr.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
|
@ -1746,7 +1747,8 @@ static llvm::raw_ostream* ComputeOutFile(const std::string& InFile,
|
|||
///
|
||||
static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
|
||||
const std::string &InFile, ProgActions PA,
|
||||
const llvm::StringMap<bool> &Features) {
|
||||
const llvm::StringMap<bool> &Features,
|
||||
llvm::LLVMContext* Context) {
|
||||
llvm::OwningPtr<llvm::raw_ostream> OS;
|
||||
llvm::OwningPtr<ASTConsumer> Consumer;
|
||||
bool ClearSourceMgr = false;
|
||||
|
@ -1813,7 +1815,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
|
|||
InitializeCompileOptions(Opts, PP.getLangOptions(), Features);
|
||||
Consumer.reset(CreateBackendConsumer(Act, PP.getDiagnostics(),
|
||||
PP.getLangOptions(), Opts, InFile,
|
||||
OS.get()));
|
||||
OS.get(), Context));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2105,9 +2107,10 @@ InputFilenames(llvm::cl::Positional, llvm::cl::desc("<input files>"));
|
|||
int main(int argc, char **argv) {
|
||||
llvm::sys::PrintStackTraceOnErrorSignal();
|
||||
llvm::PrettyStackTraceProgram X(argc, argv);
|
||||
llvm::LLVMContext Context;
|
||||
llvm::cl::ParseCommandLineOptions(argc, argv,
|
||||
"LLVM 'Clang' Compiler: http://clang.llvm.org\n");
|
||||
|
||||
|
||||
llvm::InitializeAllTargets();
|
||||
llvm::InitializeAllAsmPrinters();
|
||||
|
||||
|
@ -2281,7 +2284,7 @@ int main(int argc, char **argv) {
|
|||
((PathDiagnosticClient*)DiagClient.get())->SetPreprocessor(PP.get());
|
||||
|
||||
// Process the source file.
|
||||
ProcessInputFile(*PP, PPFactory, InFile, ProgAction, Features);
|
||||
ProcessInputFile(*PP, PPFactory, InFile, ProgAction, Features, &Context);
|
||||
|
||||
HeaderInfo.ClearFileInfo();
|
||||
DiagClient->setLangOptions(0);
|
||||
|
|
Загрузка…
Ссылка в новой задаче