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