diff options
author | dim <dim@FreeBSD.org> | 2011-02-20 13:06:31 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-02-20 13:06:31 +0000 |
commit | 39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df (patch) | |
tree | a9243275843fbeaa590afc07ee888e006b8d54ea /lib/Frontend/FrontendActions.cpp | |
parent | 69b4eca4a4255ba43baa5c1d9bbdec3ec17f479e (diff) | |
download | FreeBSD-src-39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df.zip FreeBSD-src-39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df.tar.gz |
Vendor import of clang trunk r126079:
http://llvm.org/svn/llvm-project/cfe/trunk@126079
Diffstat (limited to 'lib/Frontend/FrontendActions.cpp')
-rw-r--r-- | lib/Frontend/FrontendActions.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp index 5bc6506..d8e7d29 100644 --- a/lib/Frontend/FrontendActions.cpp +++ b/lib/Frontend/FrontendActions.cpp @@ -59,6 +59,17 @@ ASTConsumer *ASTDumpAction::CreateASTConsumer(CompilerInstance &CI, return CreateASTDumper(); } +ASTConsumer *ASTDumpXMLAction::CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile) { + llvm::raw_ostream *OS; + if (CI.getFrontendOpts().OutputFile.empty()) + OS = &llvm::outs(); + else + OS = CI.createDefaultOutputFile(false, InFile); + if (!OS) return 0; + return CreateASTDumperXML(*OS); +} + ASTConsumer *ASTViewAction::CreateASTConsumer(CompilerInstance &CI, llvm::StringRef InFile) { return CreateASTViewer(); @@ -72,19 +83,21 @@ ASTConsumer *DeclContextPrintAction::CreateASTConsumer(CompilerInstance &CI, ASTConsumer *GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, llvm::StringRef InFile) { std::string Sysroot; + std::string OutputFile; llvm::raw_ostream *OS = 0; bool Chaining; - if (ComputeASTConsumerArguments(CI, InFile, Sysroot, OS, Chaining)) + if (ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile, OS, Chaining)) return 0; const char *isysroot = CI.getFrontendOpts().RelocatablePCH ? Sysroot.c_str() : 0; - return new PCHGenerator(CI.getPreprocessor(), Chaining, isysroot, OS); + return new PCHGenerator(CI.getPreprocessor(), OutputFile, Chaining, isysroot, OS); } bool GeneratePCHAction::ComputeASTConsumerArguments(CompilerInstance &CI, llvm::StringRef InFile, std::string &Sysroot, + std::string &OutputFile, llvm::raw_ostream *&OS, bool &Chaining) { Sysroot = CI.getHeaderSearchOpts().Sysroot; @@ -93,20 +106,19 @@ bool GeneratePCHAction::ComputeASTConsumerArguments(CompilerInstance &CI, return true; } - OS = CI.createDefaultOutputFile(true, InFile); + // We use createOutputFile here because this is exposed via libclang, and we + // must disable the RemoveFileOnSignal behavior. + OS = CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true, + /*RemoveFileOnSignal=*/false, InFile); if (!OS) return true; + OutputFile = CI.getFrontendOpts().OutputFile; Chaining = CI.getInvocation().getFrontendOpts().ChainedPCH && !CI.getPreprocessorOpts().ImplicitPCHInclude.empty(); return false; } -ASTConsumer *InheritanceViewAction::CreateASTConsumer(CompilerInstance &CI, - llvm::StringRef InFile) { - return CreateInheritanceViewer(CI.getFrontendOpts().ViewClassInheritance); -} - ASTConsumer *SyntaxOnlyAction::CreateASTConsumer(CompilerInstance &CI, llvm::StringRef InFile) { return new ASTConsumer(); @@ -193,6 +205,7 @@ void PrintPreambleAction::ExecuteAction() { case IK_ObjC: case IK_ObjCXX: case IK_OpenCL: + case IK_CUDA: break; case IK_None: @@ -207,7 +220,9 @@ void PrintPreambleAction::ExecuteAction() { return; } - llvm::MemoryBuffer *Buffer = llvm::MemoryBuffer::getFile(getCurrentFile()); + CompilerInstance &CI = getCompilerInstance(); + llvm::MemoryBuffer *Buffer + = CI.getFileManager().getBufferForFile(getCurrentFile()); if (Buffer) { unsigned Preamble = Lexer::ComputePreamble(Buffer).first; llvm::outs().write(Buffer->getBufferStart(), Preamble); |