[cfe-commits] r87050 - in /cfe/trunk: include/clang/Frontend/FrontendOptions.h tools/CIndex/CIndex.cpp tools/clang-cc/Options.cpp tools/clang-cc/clang-cc.cpp
Daniel Dunbar
daniel at zuster.org
Thu Nov 12 17:02:10 PST 2009
Author: ddunbar
Date: Thu Nov 12 19:02:10 2009
New Revision: 87050
URL: http://llvm.org/viewvc/llvm-project?rev=87050&view=rev
Log:
Move code completion options to clang-cc
Modified:
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/tools/CIndex/CIndex.cpp
cfe/trunk/tools/clang-cc/Options.cpp
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=87050&r1=87049&r2=87050&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Thu Nov 12 19:02:10 2009
@@ -19,14 +19,23 @@
/// FrontendOptions - Options for controlling the behavior of the frontend.
class FrontendOptions {
public:
- unsigned DisableFree : 1; ///< Disable freeing of memory on exit.
- unsigned EmptyInputOnly : 1; ///< Force input files to be treated as if they
- /// were empty, for timing the frontend startup.
- unsigned FixItAll : 1; ///< Apply FIX-IT advice to the input source files.
- unsigned RelocatablePCH : 1; ///< When generating PCH files, instruct the
- /// PCH writer to create relocatable PCH files.
- unsigned ShowStats : 1; ///< Show frontend performance metrics and statistics.
- unsigned ShowTimers : 1; ///< Show timers for individual actions.
+ unsigned DebugCodeCompletionPrinter : 1; ///< Use the debug printer for code
+ /// completion results.
+ unsigned DisableFree : 1; ///< Disable memory freeing on exit.
+ unsigned EmptyInputOnly : 1; ///< Force input files to be treated
+ /// as if they were empty, for timing
+ /// the frontend startup.
+ unsigned FixItAll : 1; ///< Apply FIX-IT advice to the input
+ /// source files.
+ unsigned RelocatablePCH : 1; ///< When generating PCH files,
+ /// instruct the PCH writer to create
+ /// relocatable PCH files.
+ unsigned ShowMacrosInCodeCompletion : 1; ///< Show macros in code completion
+ /// results.
+ unsigned ShowStats : 1; ///< Show frontend performance
+ /// metrics and statistics.
+ unsigned ShowTimers : 1; ///< Show timers for individual
+ /// actions.
/// The input files.
std::vector<std::string> InputFilenames;
@@ -40,12 +49,17 @@
/// A list of locations to apply fix-its at.
std::vector<ParsedSourceLocation> FixItLocations;
+ /// If given, enable code completion at the provided location.
+ ParsedSourceLocation CodeCompletionAt;
+
public:
FrontendOptions() {
+ DebugCodeCompletionPrinter = 0;
DisableFree = 0;
EmptyInputOnly = 0;
FixItAll = 0;
RelocatablePCH = 0;
+ ShowMacrosInCodeCompletion = 0;
ShowStats = 0;
ShowTimers = 0;
}
Modified: cfe/trunk/tools/CIndex/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=87050&r1=87049&r2=87050&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndex.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndex.cpp Thu Nov 12 19:02:10 2009
@@ -1202,7 +1202,7 @@
argv.push_back("-Xclang");
argv.push_back(code_complete_at.c_str());
argv.push_back("-Xclang");
- argv.push_back("-code-completion-printer=cindex");
+ argv.push_back("-code-completion-debug-printer=0");
// Add the source file name (FIXME: later, we'll want to build temporary
// file from the buffer, or just feed the source text via standard input).
Modified: cfe/trunk/tools/clang-cc/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/Options.cpp?rev=87050&r1=87049&r2=87050&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/Options.cpp (original)
+++ cfe/trunk/tools/clang-cc/Options.cpp Thu Nov 12 19:02:10 2009
@@ -293,6 +293,20 @@
namespace frontendoptions {
+static llvm::cl::opt<ParsedSourceLocation>
+CodeCompletionAt("code-completion-at",
+ llvm::cl::value_desc("file:line:column"),
+ llvm::cl::desc("Dump code-completion information at a location"));
+
+static llvm::cl::opt<bool>
+CodeCompletionDebugPrinter("code-completion-debug-printer",
+ llvm::cl::desc("Use the \"debug\" code-completion print"),
+ llvm::cl::init(true));
+
+static llvm::cl::opt<bool>
+CodeCompletionWantsMacros("code-completion-macros",
+ llvm::cl::desc("Include macros in code-completion results"));
+
static llvm::cl::opt<bool>
DisableFree("disable-free",
llvm::cl::desc("Disable freeing of memory on exit"),
@@ -758,15 +772,18 @@
void clang::InitializeFrontendOptions(FrontendOptions &Opts) {
using namespace frontendoptions;
+ Opts.CodeCompletionAt = CodeCompletionAt;
+ Opts.DebugCodeCompletionPrinter = CodeCompletionDebugPrinter;
Opts.DisableFree = DisableFree;
Opts.EmptyInputOnly = EmptyInputOnly;
Opts.FixItAll = FixItAll;
Opts.FixItLocations = FixItAtLocations;
+ Opts.InputFilenames = InputFilenames;
+ Opts.OutputFile = OutputFile;
Opts.RelocatablePCH = RelocatablePCH;
+ Opts.ShowMacrosInCodeCompletion = CodeCompletionWantsMacros;
Opts.ShowStats = Stats;
Opts.ShowTimers = TimeReport;
- Opts.InputFilenames = InputFilenames;
- Opts.OutputFile = OutputFile;
Opts.ViewClassInheritance = InheritanceViewCls;
// '-' is the default input if none is given.
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=87050&r1=87049&r2=87050&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Thu Nov 12 19:02:10 2009
@@ -76,51 +76,6 @@
using namespace clang;
//===----------------------------------------------------------------------===//
-// Code Completion Options
-//===----------------------------------------------------------------------===//
-
-enum CodeCompletionPrinter {
- CCP_Debug,
- CCP_CIndex
-};
-
-static llvm::cl::opt<ParsedSourceLocation>
-CodeCompletionAt("code-completion-at",
- llvm::cl::value_desc("file:line:column"),
- llvm::cl::desc("Dump code-completion information at a location"));
-
-static llvm::cl::opt<CodeCompletionPrinter>
-CodeCompletionPrinter("code-completion-printer",
- llvm::cl::desc("Choose output type:"),
- llvm::cl::init(CCP_Debug),
- llvm::cl::values(
- clEnumValN(CCP_Debug, "debug",
- "Debug code-completion results"),
- clEnumValN(CCP_CIndex, "cindex",
- "Code-completion results for the CIndex library"),
- clEnumValEnd));
-
-static llvm::cl::opt<bool>
-CodeCompletionWantsMacros("code-completion-macros",
- llvm::cl::desc("Include macros in code-completion results"));
-
-/// \brief Buld a new code-completion consumer that prints the results of
-/// code completion to standard output.
-static CodeCompleteConsumer *BuildPrintingCodeCompleter(Sema &S, void *) {
- switch (CodeCompletionPrinter.getValue()) {
- case CCP_Debug:
- return new PrintingCodeCompleteConsumer(S, CodeCompletionWantsMacros,
- llvm::outs());
-
- case CCP_CIndex:
- return new CIndexCodeCompleteConsumer(S, CodeCompletionWantsMacros,
- llvm::outs());
- };
-
- return 0;
-}
-
-//===----------------------------------------------------------------------===//
// Frontend Actions
//===----------------------------------------------------------------------===//
@@ -253,7 +208,7 @@
llvm::cl::desc("Target a particular ABI type"));
//===----------------------------------------------------------------------===//
-// SourceManager initialization.
+// Utility Methods
//===----------------------------------------------------------------------===//
static bool InitializeSourceManager(Preprocessor &PP,
@@ -287,10 +242,6 @@
return false;
}
-//===----------------------------------------------------------------------===//
-// Preprocessor construction
-//===----------------------------------------------------------------------===//
-
std::string GetBuiltinIncludePath(const char *Argv0) {
llvm::sys::Path P =
llvm::sys::Path::GetMainExecutable(Argv0,
@@ -349,6 +300,19 @@
return PP;
}
+/// \brief Buld a new code-completion consumer that prints the results of
+/// code completion to standard output.
+static CodeCompleteConsumer *BuildPrintingCodeCompleter(Sema &S,
+ void *UserData) {
+ const FrontendOptions &Opts = *(FrontendOptions*)UserData;
+ if (Opts.DebugCodeCompletionPrinter)
+ return new PrintingCodeCompleteConsumer(S, Opts.ShowMacrosInCodeCompletion,
+ llvm::outs());
+
+ return new CIndexCodeCompleteConsumer(S, Opts.ShowMacrosInCodeCompletion,
+ llvm::outs());
+}
+
//===----------------------------------------------------------------------===//
// Basic Parser driver
//===----------------------------------------------------------------------===//
@@ -696,22 +660,23 @@
return;
CodeCompleteConsumer *(*CreateCodeCompleter)(Sema &, void *) = 0;
- void *CreateCodeCompleterData = 0;
+ void *CreateCodeCompleterData = (void*) &FEOpts;
- if (!CodeCompletionAt.FileName.empty()) {
+ 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(CodeCompletionAt.FileName)) {
+ = PP.getFileManager().getFile(FEOpts.CodeCompletionAt.FileName)) {
// Truncate the named file at the given line/column.
- PP.getSourceManager().truncateFileAt(Entry, CodeCompletionAt.Line,
- CodeCompletionAt.Column);
+ PP.getSourceManager().truncateFileAt(Entry,
+ FEOpts.CodeCompletionAt.Line,
+ FEOpts.CodeCompletionAt.Column);
// Set up the creation routine for code-completion.
CreateCodeCompleter = BuildPrintingCodeCompleter;
} else {
PP.getDiagnostics().Report(diag::err_fe_invalid_code_complete_file)
- << CodeCompletionAt.FileName;
+ << FEOpts.CodeCompletionAt.FileName;
}
}
More information about the cfe-commits
mailing list