Fix build with LLVM top-of-tree (various changes to clang entrypoints).

This commit is contained in:
Matt Pharr
2012-11-16 11:04:11 -08:00
parent d3b86dcc90
commit e82b649ec0

View File

@@ -1753,11 +1753,22 @@ Module::execPreprocessor(const char* infilename, llvm::raw_string_ostream* ostre
llvm::raw_fd_ostream stderrRaw(2, false);
#if defined(LLVM_3_0) || defined(LLVM_3_1)
clang::TextDiagnosticPrinter *diagPrinter =
new clang::TextDiagnosticPrinter(stderrRaw, clang::DiagnosticOptions());
#else
clang::DiagnosticOptions diagOptions;
clang::TextDiagnosticPrinter *diagPrinter =
new clang::TextDiagnosticPrinter(stderrRaw, &diagOptions);
#endif
llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagIDs(new clang::DiagnosticIDs);
#if defined(LLVM_3_0) || defined(LLVM_3_1)
clang::DiagnosticsEngine *diagEngine =
new clang::DiagnosticsEngine(diagIDs, diagPrinter);
#else
clang::DiagnosticsEngine *diagEngine =
new clang::DiagnosticsEngine(diagIDs, &diagOptions, diagPrinter);
#endif
inst.setDiagnostics(diagEngine);
clang::TargetOptions &options = inst.getTargetOpts();
@@ -1771,12 +1782,22 @@ Module::execPreprocessor(const char* infilename, llvm::raw_string_ostream* ostre
}
options.Triple = triple.getTriple();
#if defined(LLVM_3_0) || defined(LLVM_3_1)
clang::TargetInfo *target =
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options);
#else
clang::TargetInfo *target =
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), &options);
#endif
inst.setTarget(target);
inst.createSourceManager(inst.getFileManager());
#if defined(LLVM_3_0) || defined(LLVM_3_1)
inst.InitializeSourceManager(infilename);
#else
clang::FrontendInputFile inputFile(infilename, clang::IK_None);
inst.InitializeSourceManager(inputFile);
#endif
// Don't remove comments in the preprocessor, so that we can accurately
// track the source file position by handling them ourselves.