diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-11-13 09:36:05 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-11-13 09:36:05 +0000 |
commit | c2f484f1f05216a9a427ac84b5773789a4661111 (patch) | |
tree | 3b9e1de1b33953d81b692bd6c87da4a972ea9274 /tools/clang-cc | |
parent | 3a2838d14251427089c39caec90c8abbc27f7a14 (diff) |
Add CodeCompletion consumer to CompilerInvocation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87100 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/clang-cc')
-rw-r--r-- | tools/clang-cc/clang-cc.cpp | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp index 5092e1ab32..8e969479e7 100644 --- a/tools/clang-cc/clang-cc.cpp +++ b/tools/clang-cc/clang-cc.cpp @@ -481,36 +481,14 @@ static void ProcessInputFile(CompilerInstance &CI, const std::string &InFile, if (InitializeSourceManager(PP, CI.getFrontendOpts(), InFile)) return; - llvm::OwningPtr<CodeCompleteConsumer> CCConsumer; - if (!FEOpts.CodeCompletionAt.FileName.empty()) { - // Tell the source manager to chop off the given file at a specific - // line and column. - if (const FileEntry *Entry - = PP.getFileManager().getFile(FEOpts.CodeCompletionAt.FileName)) { - // Truncate the named file at the given line/column. - PP.getSourceManager().truncateFileAt(Entry, - FEOpts.CodeCompletionAt.Line, - FEOpts.CodeCompletionAt.Column); - - // Set up the creation routine for code-completion. - if (FEOpts.DebugCodeCompletionPrinter) - CCConsumer.reset( - new PrintingCodeCompleteConsumer(FEOpts.ShowMacrosInCodeCompletion, - llvm::outs())); - else - CCConsumer.reset( - new CIndexCodeCompleteConsumer(FEOpts.ShowMacrosInCodeCompletion, - llvm::outs())); - } else { - PP.getDiagnostics().Report(diag::err_fe_invalid_code_complete_file) - << FEOpts.CodeCompletionAt.FileName; - } - } + if (!FEOpts.CodeCompletionAt.FileName.empty()) + CI.createCodeCompletionConsumer(); // Run the AST consumer action. + CodeCompleteConsumer *CompletionConsumer = + CI.hasCodeCompletionConsumer() ? &CI.getCodeCompletionConsumer() : 0; ParseAST(PP, Consumer.get(), CI.getASTContext(), FEOpts.ShowStats, - CompleteTranslationUnit, - CCConsumer.get()); + CompleteTranslationUnit, CompletionConsumer); } else { // Initialize builtin info. PP.getBuiltinInfo().InitializeBuiltins(PP.getIdentifierTable(), |