[cfe-commits] r105577 - in /cfe/trunk: include/clang/Frontend/FrontendAction.h include/clang/Frontend/FrontendOptions.h lib/Frontend/ASTUnit.cpp lib/Frontend/CompilerInstance.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/FrontendOptions.cpp
Daniel Dunbar
daniel at zuster.org
Mon Jun 7 16:22:09 PDT 2010
Author: ddunbar
Date: Mon Jun 7 18:22:09 2010
New Revision: 105577
URL: http://llvm.org/viewvc/llvm-project?rev=105577&view=rev
Log:
Frontend: Lift InputKind enumeration to top level.
Modified:
cfe/trunk/include/clang/Frontend/FrontendAction.h
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/FrontendOptions.cpp
Modified: cfe/trunk/include/clang/Frontend/FrontendAction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendAction.h?rev=105577&r1=105576&r2=105577&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendAction.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendAction.h Mon Jun 7 18:22:09 2010
@@ -20,6 +20,22 @@
class CompilerInstance;
class ASTMergeAction;
+enum InputKind {
+ IK_None,
+ IK_Asm,
+ IK_C,
+ IK_CXX,
+ IK_ObjC,
+ IK_ObjCXX,
+ IK_PreprocessedC,
+ IK_PreprocessedCXX,
+ IK_PreprocessedObjC,
+ IK_PreprocessedObjCXX,
+ IK_OpenCL,
+ IK_AST
+};
+
+
/// FrontendAction - Abstract base class for actions which can be performed by
/// the frontend.
class FrontendAction {
Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=105577&r1=105576&r2=105577&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Mon Jun 7 18:22:09 2010
@@ -11,6 +11,7 @@
#define LLVM_CLANG_FRONTEND_FRONTENDOPTIONS_H
#include "clang/Frontend/CommandLineSourceLoc.h"
+#include "clang/Frontend/FrontendAction.h"
#include "llvm/ADT/StringRef.h"
#include <string>
#include <vector>
@@ -55,21 +56,6 @@
/// FrontendOptions - Options for controlling the behavior of the frontend.
class FrontendOptions {
public:
- enum InputKind {
- IK_None,
- IK_Asm,
- IK_C,
- IK_CXX,
- IK_ObjC,
- IK_ObjCXX,
- IK_PreprocessedC,
- IK_PreprocessedCXX,
- IK_PreprocessedObjC,
- IK_PreprocessedObjCXX,
- IK_OpenCL,
- IK_AST
- };
-
unsigned DebugCodeCompletionPrinter : 1; ///< Use the debug printer for code
/// completion results.
unsigned DisableFree : 1; ///< Disable memory freeing on exit.
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=105577&r1=105576&r2=105577&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Jun 7 18:22:09 2010
@@ -332,7 +332,7 @@
assert(Clang.getFrontendOpts().Inputs.size() == 1 &&
"Invocation must have exactly one source file!");
- assert(Clang.getFrontendOpts().Inputs[0].first != FrontendOptions::IK_AST &&
+ assert(Clang.getFrontendOpts().Inputs[0].first != IK_AST &&
"FIXME: AST inputs not yet supported here!");
// Create the AST unit.
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=105577&r1=105576&r2=105577&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Jun 7 18:22:09 2010
@@ -491,7 +491,7 @@
// If we aren't using an AST file, setup the file and source managers and
// the preprocessor.
- bool IsAST = getFrontendOpts().Inputs[i].first == FrontendOptions::IK_AST;
+ bool IsAST = getFrontendOpts().Inputs[i].first == IK_AST;
if (!IsAST) {
if (!i) {
// Create a file manager object to provide access to and cache the
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=105577&r1=105576&r2=105577&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Jun 7 18:22:09 2010
@@ -280,20 +280,20 @@
Res.push_back("-W" + Opts.Warnings[i]);
}
-static const char *getInputKindName(FrontendOptions::InputKind Kind) {
+static const char *getInputKindName(InputKind Kind) {
switch (Kind) {
- case FrontendOptions::IK_None: break;
- case FrontendOptions::IK_AST: return "ast";
- case FrontendOptions::IK_Asm: return "assembler-with-cpp";
- case FrontendOptions::IK_C: return "c";
- case FrontendOptions::IK_CXX: return "c++";
- case FrontendOptions::IK_ObjC: return "objective-c";
- case FrontendOptions::IK_ObjCXX: return "objective-c++";
- case FrontendOptions::IK_OpenCL: return "cl";
- case FrontendOptions::IK_PreprocessedC: return "cpp-output";
- case FrontendOptions::IK_PreprocessedCXX: return "c++-cpp-output";
- case FrontendOptions::IK_PreprocessedObjC: return "objective-c-cpp-output";
- case FrontendOptions::IK_PreprocessedObjCXX:return "objective-c++-cpp-output";
+ case IK_None: break;
+ case IK_AST: return "ast";
+ case IK_Asm: return "assembler-with-cpp";
+ case IK_C: return "c";
+ case IK_CXX: return "c++";
+ case IK_ObjC: return "objective-c";
+ case IK_ObjCXX: return "objective-c++";
+ case IK_OpenCL: return "cl";
+ case IK_PreprocessedC: return "cpp-output";
+ case IK_PreprocessedCXX: return "c++-cpp-output";
+ case IK_PreprocessedObjC: return "objective-c-cpp-output";
+ case IK_PreprocessedObjCXX:return "objective-c++-cpp-output";
}
llvm_unreachable("Unexpected language kind!");
@@ -903,8 +903,8 @@
Opts.Warnings = Args.getAllArgValues(OPT_W);
}
-static FrontendOptions::InputKind
-ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, Diagnostic &Diags) {
+static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
+ Diagnostic &Diags) {
using namespace cc1options;
Opts.ProgramAction = frontend::ParseSyntaxOnly;
if (const Arg *A = Args.getLastArg(OPT_Action_Group)) {
@@ -1002,28 +1002,28 @@
Opts.ASTMergeFiles = Args.getAllArgValues(OPT_ast_merge);
Opts.LLVMArgs = Args.getAllArgValues(OPT_mllvm);
- FrontendOptions::InputKind DashX = FrontendOptions::IK_None;
+ InputKind DashX = IK_None;
if (const Arg *A = Args.getLastArg(OPT_x)) {
- DashX = llvm::StringSwitch<FrontendOptions::InputKind>(A->getValue(Args))
- .Case("c", FrontendOptions::IK_C)
- .Case("cl", FrontendOptions::IK_OpenCL)
- .Case("c", FrontendOptions::IK_C)
- .Case("cl", FrontendOptions::IK_OpenCL)
- .Case("c++", FrontendOptions::IK_CXX)
- .Case("objective-c", FrontendOptions::IK_ObjC)
- .Case("objective-c++", FrontendOptions::IK_ObjCXX)
- .Case("cpp-output", FrontendOptions::IK_PreprocessedC)
- .Case("assembler-with-cpp", FrontendOptions::IK_Asm)
- .Case("c++-cpp-output", FrontendOptions::IK_PreprocessedCXX)
- .Case("objective-c-cpp-output", FrontendOptions::IK_PreprocessedObjC)
- .Case("objective-c++-cpp-output", FrontendOptions::IK_PreprocessedObjCXX)
- .Case("c-header", FrontendOptions::IK_C)
- .Case("objective-c-header", FrontendOptions::IK_ObjC)
- .Case("c++-header", FrontendOptions::IK_CXX)
- .Case("objective-c++-header", FrontendOptions::IK_ObjCXX)
- .Case("ast", FrontendOptions::IK_AST)
- .Default(FrontendOptions::IK_None);
- if (DashX == FrontendOptions::IK_None)
+ DashX = llvm::StringSwitch<InputKind>(A->getValue(Args))
+ .Case("c", IK_C)
+ .Case("cl", IK_OpenCL)
+ .Case("c", IK_C)
+ .Case("cl", IK_OpenCL)
+ .Case("c++", IK_CXX)
+ .Case("objective-c", IK_ObjC)
+ .Case("objective-c++", IK_ObjCXX)
+ .Case("cpp-output", IK_PreprocessedC)
+ .Case("assembler-with-cpp", IK_Asm)
+ .Case("c++-cpp-output", IK_PreprocessedCXX)
+ .Case("objective-c-cpp-output", IK_PreprocessedObjC)
+ .Case("objective-c++-cpp-output", IK_PreprocessedObjCXX)
+ .Case("c-header", IK_C)
+ .Case("objective-c-header", IK_ObjC)
+ .Case("c++-header", IK_CXX)
+ .Case("objective-c++-header", IK_ObjCXX)
+ .Case("ast", IK_AST)
+ .Default(IK_None);
+ if (DashX == IK_None)
Diags.Report(diag::err_drv_invalid_value)
<< A->getAsString(Args) << A->getValue(Args);
}
@@ -1034,8 +1034,8 @@
if (Inputs.empty())
Inputs.push_back("-");
for (unsigned i = 0, e = Inputs.size(); i != e; ++i) {
- FrontendOptions::InputKind IK = DashX;
- if (IK == FrontendOptions::IK_None) {
+ InputKind IK = DashX;
+ if (IK == IK_None) {
IK = FrontendOptions::getInputKindForExtension(
llvm::StringRef(Inputs[i]).rsplit('.').second);
// FIXME: Remove this hack.
@@ -1108,20 +1108,19 @@
// FIXME: Need options for the various environment variables!
}
-static void ParseLangArgs(LangOptions &Opts, ArgList &Args,
- FrontendOptions::InputKind IK,
+static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Diagnostic &Diags) {
// FIXME: Cleanup per-file based stuff.
// Set some properties which depend soley on the input kind; it would be nice
// to move these to the language standard, and have the driver resolve the
// input kind + language standard.
- if (IK == FrontendOptions::IK_Asm) {
+ if (IK == IK_Asm) {
Opts.AsmPreprocessor = 1;
- } else if (IK == FrontendOptions::IK_ObjC ||
- IK == FrontendOptions::IK_ObjCXX ||
- IK == FrontendOptions::IK_PreprocessedObjC ||
- IK == FrontendOptions::IK_PreprocessedObjCXX) {
+ } else if (IK == IK_ObjC ||
+ IK == IK_ObjCXX ||
+ IK == IK_PreprocessedObjC ||
+ IK == IK_PreprocessedObjCXX) {
Opts.ObjC1 = Opts.ObjC2 = 1;
}
@@ -1140,23 +1139,23 @@
if (LangStd == LangStandard::lang_unspecified) {
// Based on the base language, pick one.
switch (IK) {
- case FrontendOptions::IK_None:
- case FrontendOptions::IK_AST:
+ case IK_None:
+ case IK_AST:
assert(0 && "Invalid input kind!");
- case FrontendOptions::IK_OpenCL:
+ case IK_OpenCL:
LangStd = LangStandard::lang_opencl;
break;
- case FrontendOptions::IK_Asm:
- case FrontendOptions::IK_C:
- case FrontendOptions::IK_PreprocessedC:
- case FrontendOptions::IK_ObjC:
- case FrontendOptions::IK_PreprocessedObjC:
+ case IK_Asm:
+ case IK_C:
+ case IK_PreprocessedC:
+ case IK_ObjC:
+ case IK_PreprocessedObjC:
LangStd = LangStandard::lang_gnu99;
break;
- case FrontendOptions::IK_CXX:
- case FrontendOptions::IK_PreprocessedCXX:
- case FrontendOptions::IK_ObjCXX:
- case FrontendOptions::IK_PreprocessedObjCXX:
+ case IK_CXX:
+ case IK_PreprocessedCXX:
+ case IK_ObjCXX:
+ case IK_PreprocessedObjCXX:
LangStd = LangStandard::lang_gnucxx98;
break;
}
@@ -1400,10 +1399,9 @@
ParseCodeGenArgs(Res.getCodeGenOpts(), *Args, Diags);
ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), *Args);
ParseDiagnosticArgs(Res.getDiagnosticOpts(), *Args, Diags);
- FrontendOptions::InputKind DashX =
- ParseFrontendArgs(Res.getFrontendOpts(), *Args, Diags);
+ InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), *Args, Diags);
ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), *Args);
- if (DashX != FrontendOptions::IK_AST)
+ if (DashX != IK_AST)
ParseLangArgs(Res.getLangOpts(), *Args, DashX, Diags);
ParsePreprocessorArgs(Res.getPreprocessorOpts(), *Args, Diags);
ParsePreprocessorOutputArgs(Res.getPreprocessorOutputOpts(), *Args);
Modified: cfe/trunk/lib/Frontend/FrontendOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendOptions.cpp?rev=105577&r1=105576&r2=105577&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendOptions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendOptions.cpp Mon Jun 7 18:22:09 2010
@@ -11,8 +11,7 @@
#include "llvm/ADT/StringSwitch.h"
using namespace clang;
-FrontendOptions::InputKind
-FrontendOptions::getInputKindForExtension(llvm::StringRef Extension) {
+InputKind FrontendOptions::getInputKindForExtension(llvm::StringRef Extension) {
return llvm::StringSwitch<InputKind>(Extension)
.Case("ast", IK_AST)
.Case("c", IK_C)
More information about the cfe-commits
mailing list