clang-cc: Coalesce frontend options further.
llvm-svn: 86988
This commit is contained in:
parent
f8fcac7470
commit
91cd960d50
|
@ -76,26 +76,53 @@
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Global options.
|
// Code Completion Options
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// ClangFrontendTimer - The front-end activities should charge time to it with
|
enum CodeCompletionPrinter {
|
||||||
/// TimeRegion. The -ftime-report option controls whether this will do
|
CCP_Debug,
|
||||||
/// anything.
|
CCP_CIndex
|
||||||
llvm::Timer *ClangFrontendTimer = 0;
|
};
|
||||||
|
|
||||||
|
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>
|
static llvm::cl::opt<bool>
|
||||||
Verbose("v", llvm::cl::desc("Enable verbose output"));
|
CodeCompletionWantsMacros("code-completion-macros",
|
||||||
static llvm::cl::opt<bool>
|
llvm::cl::desc("Include macros in code-completion results"));
|
||||||
Stats("print-stats",
|
|
||||||
llvm::cl::desc("Print performance metrics and statistics"));
|
/// \brief Buld a new code-completion consumer that prints the results of
|
||||||
static llvm::cl::opt<bool>
|
/// code completion to standard output.
|
||||||
DisableFree("disable-free",
|
static CodeCompleteConsumer *BuildPrintingCodeCompleter(Sema &S, void *) {
|
||||||
llvm::cl::desc("Disable freeing of memory on exit"),
|
switch (CodeCompletionPrinter.getValue()) {
|
||||||
llvm::cl::init(false));
|
case CCP_Debug:
|
||||||
static llvm::cl::opt<bool>
|
return new PrintingCodeCompleteConsumer(S, CodeCompletionWantsMacros,
|
||||||
EmptyInputOnly("empty-input-only",
|
llvm::outs());
|
||||||
llvm::cl::desc("Force running on an empty input file"));
|
|
||||||
|
case CCP_CIndex:
|
||||||
|
return new CIndexCodeCompleteConsumer(S, CodeCompletionWantsMacros,
|
||||||
|
llvm::outs());
|
||||||
|
};
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// Frontend Actions
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
enum ProgActions {
|
enum ProgActions {
|
||||||
RewriteObjC, // ObjC->C Rewriter.
|
RewriteObjC, // ObjC->C Rewriter.
|
||||||
|
@ -183,74 +210,55 @@ ProgAction(llvm::cl::desc("Choose output type:"), llvm::cl::ZeroOrMore,
|
||||||
"Rewrite Blocks to C"),
|
"Rewrite Blocks to C"),
|
||||||
clEnumValEnd));
|
clEnumValEnd));
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
enum CodeCompletionPrinter {
|
// Frontend Options
|
||||||
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>
|
static llvm::cl::opt<bool>
|
||||||
CodeCompletionWantsMacros("code-completion-macros",
|
DisableFree("disable-free",
|
||||||
llvm::cl::desc("Include macros in code-completion results"));
|
llvm::cl::desc("Disable freeing of memory on exit"),
|
||||||
|
llvm::cl::init(false));
|
||||||
|
|
||||||
/// \brief Buld a new code-completion consumer that prints the results of
|
static llvm::cl::opt<bool>
|
||||||
/// code completion to standard output.
|
EmptyInputOnly("empty-input-only",
|
||||||
static CodeCompleteConsumer *BuildPrintingCodeCompleter(Sema &S, void *) {
|
llvm::cl::desc("Force running on an empty input file"));
|
||||||
switch (CodeCompletionPrinter.getValue()) {
|
|
||||||
case CCP_Debug:
|
|
||||||
return new PrintingCodeCompleteConsumer(S, CodeCompletionWantsMacros,
|
|
||||||
llvm::outs());
|
|
||||||
|
|
||||||
case CCP_CIndex:
|
static llvm::cl::list<std::string>
|
||||||
return new CIndexCodeCompleteConsumer(S, CodeCompletionWantsMacros,
|
InputFilenames(llvm::cl::Positional, llvm::cl::desc("<input files>"));
|
||||||
llvm::outs());
|
|
||||||
};
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
// C++ Visualization.
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
static llvm::cl::opt<std::string>
|
static llvm::cl::opt<std::string>
|
||||||
InheritanceViewCls("cxx-inheritance-view",
|
InheritanceViewCls("cxx-inheritance-view",
|
||||||
llvm::cl::value_desc("class name"),
|
llvm::cl::value_desc("class name"),
|
||||||
llvm::cl::desc("View C++ inheritance for a specified class"));
|
llvm::cl::desc("View C++ inheritance for a specified class"));
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
static llvm::cl::opt<bool>
|
||||||
// Frontend Options
|
FixItAll("fixit", llvm::cl::desc("Apply fix-it advice to the input source"));
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
static llvm::cl::list<std::string>
|
static llvm::cl::list<ParsedSourceLocation>
|
||||||
InputFilenames(llvm::cl::Positional, llvm::cl::desc("<input files>"));
|
FixItAtLocations("fixit-at", llvm::cl::value_desc("source-location"),
|
||||||
|
llvm::cl::desc("Perform Fix-It modifications at the given source location"));
|
||||||
|
|
||||||
static llvm::cl::opt<std::string>
|
static llvm::cl::opt<std::string>
|
||||||
OutputFile("o",
|
OutputFile("o",
|
||||||
llvm::cl::value_desc("path"),
|
llvm::cl::value_desc("path"),
|
||||||
llvm::cl::desc("Specify output file"));
|
llvm::cl::desc("Specify output file"));
|
||||||
|
|
||||||
|
static llvm::cl::opt<bool>
|
||||||
|
RelocatablePCH("relocatable-pch",
|
||||||
|
llvm::cl::desc("Whether to build a relocatable precompiled "
|
||||||
|
"header"));
|
||||||
|
static llvm::cl::opt<bool>
|
||||||
|
Stats("print-stats",
|
||||||
|
llvm::cl::desc("Print performance metrics and statistics"));
|
||||||
|
|
||||||
static llvm::cl::opt<bool>
|
static llvm::cl::opt<bool>
|
||||||
TimeReport("ftime-report",
|
TimeReport("ftime-report",
|
||||||
llvm::cl::desc("Print the amount of time each "
|
llvm::cl::desc("Print the amount of time each "
|
||||||
"phase of compilation takes"));
|
"phase of compilation takes"));
|
||||||
|
|
||||||
|
static llvm::cl::opt<bool>
|
||||||
|
Verbose("v", llvm::cl::desc("Enable verbose output"));
|
||||||
|
|
||||||
static llvm::cl::opt<bool>
|
static llvm::cl::opt<bool>
|
||||||
VerifyDiagnostics("verify",
|
VerifyDiagnostics("verify",
|
||||||
llvm::cl::desc("Verify emitted diagnostics and warnings"));
|
llvm::cl::desc("Verify emitted diagnostics and warnings"));
|
||||||
|
@ -331,16 +339,6 @@ static bool InitializeSourceManager(Preprocessor &PP,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
// Preprocessor Initialization
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
static llvm::cl::opt<bool>
|
|
||||||
RelocatablePCH("relocatable-pch",
|
|
||||||
llvm::cl::desc("Whether to build a relocatable precompiled "
|
|
||||||
"header"));
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Preprocessor construction
|
// Preprocessor construction
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -416,17 +414,6 @@ static void ParseFile(Preprocessor &PP, MinimalAction *PA) {
|
||||||
delete PA;
|
delete PA;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
// Fix-It Options
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
static llvm::cl::opt<bool>
|
|
||||||
FixItAll("fixit", llvm::cl::desc("Apply fix-it advice to the input source"));
|
|
||||||
|
|
||||||
static llvm::cl::list<ParsedSourceLocation>
|
|
||||||
FixItAtLocations("fixit-at", llvm::cl::value_desc("source-location"),
|
|
||||||
llvm::cl::desc("Perform Fix-It modifications at the given source location"));
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Dump Build Information
|
// Dump Build Information
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -459,6 +446,11 @@ static void SetUpBuildDumpLog(const DiagnosticOptions &DiagOpts,
|
||||||
// Main driver
|
// Main driver
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
/// ClangFrontendTimer - The front-end activities should charge time to it with
|
||||||
|
/// TimeRegion. The -ftime-report option controls whether this will do
|
||||||
|
/// anything.
|
||||||
|
llvm::Timer *ClangFrontendTimer = 0;
|
||||||
|
|
||||||
static llvm::raw_ostream *ComputeOutFile(const CompilerInvocation &CompOpts,
|
static llvm::raw_ostream *ComputeOutFile(const CompilerInvocation &CompOpts,
|
||||||
const std::string &InFile,
|
const std::string &InFile,
|
||||||
const char *Extension,
|
const char *Extension,
|
||||||
|
@ -1120,18 +1112,15 @@ int main(int argc, char **argv) {
|
||||||
// Get information about the target being compiled for.
|
// Get information about the target being compiled for.
|
||||||
llvm::OwningPtr<TargetInfo>
|
llvm::OwningPtr<TargetInfo>
|
||||||
Target(TargetInfo::CreateTargetInfo(Triple.getTriple()));
|
Target(TargetInfo::CreateTargetInfo(Triple.getTriple()));
|
||||||
|
|
||||||
if (Target == 0) {
|
if (Target == 0) {
|
||||||
Diags->Report(diag::err_fe_unknown_triple) << Triple.getTriple().c_str();
|
Diags->Report(diag::err_fe_unknown_triple) << Triple.getTriple().c_str();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the target ABI if specified.
|
// Set the target ABI if specified.
|
||||||
if (!TargetABI.empty()) {
|
if (!TargetABI.empty() &&!Target->setABI(TargetABI)) {
|
||||||
if (!Target->setABI(TargetABI)) {
|
Diags->Report(diag::err_fe_unknown_target_abi) << TargetABI;
|
||||||
Diags->Report(diag::err_fe_unknown_target_abi) << TargetABI;
|
return 1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!InheritanceViewCls.empty()) // C++ visualization?
|
if (!InheritanceViewCls.empty()) // C++ visualization?
|
||||||
|
|
Loading…
Reference in New Issue