cc1as: consolidate option flags with cc1 and eliminate duplication

The clang -cc1as options are nearly a strict subset of -cc1. Instead of
duplicating the definitions and documentation, let's go ahead and share the
definitions in a similar way the current handling of combined driver and
frontend flags, eliminating some of the vestigial legacy surrounding the
assembler subcommand.

llvm-svn: 212620
This commit is contained in:
Alp Toker 2014-07-09 14:05:11 +00:00
parent 9500d2d751
commit 61dad75b10
9 changed files with 130 additions and 235 deletions

View File

@ -1,37 +0,0 @@
//===--- CC1AsOptions.h - Clang Assembler Options Table ---------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef CLANG_DRIVER_CC1ASOPTIONS_H
#define CLANG_DRIVER_CC1ASOPTIONS_H
namespace llvm {
namespace opt {
class OptTable;
}
}
namespace clang {
namespace driver {
namespace cc1asoptions {
enum ID {
OPT_INVALID = 0, // This is not an option ID.
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
HELPTEXT, METAVAR) OPT_##ID,
#include "clang/Driver/CC1AsOptions.inc"
LastOption
#undef OPTION
};
}
llvm::opt::OptTable *createCC1AsOptTable();
}
}
#endif

View File

@ -1,105 +0,0 @@
//===--- CC1AsOptions.td - Options for clang -cc1as -----------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the options accepted by clang -cc1as.
//
//===----------------------------------------------------------------------===//
// Include the common option parsing interfaces.
include "llvm/Option/OptParser.td"
//===----------------------------------------------------------------------===//
// Target Options
//===----------------------------------------------------------------------===//
def triple : Separate<["-"], "triple">,
HelpText<"Specify target triple (e.g. x86_64-pc-linux-gnu)">;
def target_cpu : Separate<["-"], "target-cpu">,
HelpText<"Target a specific cpu type">;
def target_feature : Separate<["-"], "target-feature">,
HelpText<"Target specific attributes">;
//===----------------------------------------------------------------------===//
// Language Options
//===----------------------------------------------------------------------===//
def I : JoinedOrSeparate<["-"], "I">, MetaVarName<"<directory>">,
HelpText<"Add directory to include search path">;
def n : Flag<["-"], "n">,
HelpText<"Don't automatically start assembly file with a text section">;
def msave_temp_labels : Flag<["-"], "msave-temp-labels">,
HelpText<"Save temporary labels in the symbol table. "
"Note this may change .s semantics, it should almost never be used "
"on compiler generated code!">;
def main_file_name : Separate<["-"], "main-file-name">,
HelpText<"Main file name to use for debug info">;
//===----------------------------------------------------------------------===//
// Frontend Options
//===----------------------------------------------------------------------===//
def o : Separate<["-"], "o">, MetaVarName<"<path>">,
HelpText<"Specify output file">;
def filetype : Separate<["-"], "filetype">,
HelpText<"Specify the output file type ('asm', 'null', or 'obj')">;
def help : Flag<["-", "--"], "help">,
HelpText<"Print this help text">;
def version : Flag<["-", "--"], "version">,
HelpText<"Print the assembler version">;
def v : Flag<["-"], "v">, Alias<version>;
// Generic forwarding to LLVM options. This should only be used for debugging
// and experimental features.
def mllvm : Separate<["-"], "mllvm">,
HelpText<"Additional arguments to forward to LLVM's option processing">;
//===----------------------------------------------------------------------===//
// Transliterate Options
//===----------------------------------------------------------------------===//
def output_asm_variant : Separate<["-"], "output-asm-variant">,
HelpText<"Select the asm variant index to use for output">;
def show_encoding : Flag<["-"], "show-encoding">,
HelpText<"Show instruction encoding information in transliterate mode">;
def show_inst : Flag<["-"], "show-inst">,
HelpText<"Show internal instruction representation in transliterate mode">;
//===----------------------------------------------------------------------===//
// Assemble Options
//===----------------------------------------------------------------------===//
def mrelax_all : Flag<["-"], "mrelax-all">,
HelpText<"Relax all fixups (for performance testing)">;
def mno_exec_stack : Flag<["-"], "mnoexecstack">,
HelpText<"Mark the file as not needing an executable stack">;
def compress_debug_sections : Flag<["-"], "compress-debug-sections">,
HelpText<"Compress DWARF debug sections using zlib">;
def g : Flag<["-"], "g">, HelpText<"Generate source level debug information">;
def gdwarf_2 : Flag<["-"], "gdwarf-2">,
HelpText<"Generate source level debug information with dwarf version 2">;
def gdwarf_3 : Flag<["-"], "gdwarf-3">,
HelpText<"Generate source level debug information with dwarf version 3">;
def gdwarf_4 : Flag<["-"], "gdwarf-4">,
HelpText<"Generate source level debug information with dwarf version 4">;
def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">,
HelpText<"The compilation directory to embed in the debug info.">;
def dwarf_debug_flags : Separate<["-"], "dwarf-debug-flags">,
HelpText<"The string to embed in the Dwarf debug flags record.">;
def dwarf_debug_producer : Separate<["-"], "dwarf-debug-producer">,
HelpText<"The string to embed in the Dwarf debug AT_producer record.">;

View File

@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
// This file defines the options accepted by clang -cc1.
// This file defines the options accepted by clang -cc1 and clang -cc1as.
//
//===----------------------------------------------------------------------===//
@ -17,19 +17,24 @@ let Flags = [CC1Option, NoDriverOption] in {
// Target Options
//===----------------------------------------------------------------------===//
def target_abi : Separate<["-"], "target-abi">,
HelpText<"Target a particular ABI type">;
let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
def target_cpu : Separate<["-"], "target-cpu">,
HelpText<"Target a specific cpu type">;
def mfpmath : Separate<["-"], "mfpmath">,
HelpText<"Which unit to use for fp math">;
def target_feature : Separate<["-"], "target-feature">,
HelpText<"Target specific attributes">;
def target_linker_version : Separate<["-"], "target-linker-version">,
HelpText<"Target linker version">;
def triple : Separate<["-"], "triple">,
HelpText<"Specify target triple (e.g. i686-apple-darwin9)">;
}
def target_abi : Separate<["-"], "target-abi">,
HelpText<"Target a particular ABI type">;
def target_linker_version : Separate<["-"], "target-linker-version">,
HelpText<"Target linker version">;
def triple_EQ : Joined<["-"], "triple=">, Alias<triple>;
def mfpmath : Separate<["-"], "mfpmath">,
HelpText<"Which unit to use for fp math">;
//===----------------------------------------------------------------------===//
// Analyzer Options
@ -122,16 +127,29 @@ def migrator_no_finalize_removal : Flag<["-"], "no-finalize-removal">,
// CodeGen Options
//===----------------------------------------------------------------------===//
let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">,
HelpText<"The compilation directory to embed in the debug info.">;
def dwarf_debug_flags : Separate<["-"], "dwarf-debug-flags">,
HelpText<"The string to embed in the Dwarf debug flags record.">;
def mno_exec_stack : Flag<["-"], "mnoexecstack">,
HelpText<"Mark the file as not needing an executable stack">;
def compress_debug_sections : Flag<["-"], "compress-debug-sections">,
HelpText<"Compress DWARF debug sections using zlib">;
def msave_temp_labels : Flag<["-"], "msave-temp-labels">,
HelpText<"Save temporary labels in the symbol table. "
"Note this may change .s semantics and shouldn't generally be used "
"on compiler-generated code.">;
}
def disable_llvm_optzns : Flag<["-"], "disable-llvm-optzns">,
HelpText<"Don't run LLVM optimization passes">;
def disable_llvm_verifier : Flag<["-"], "disable-llvm-verifier">,
HelpText<"Don't run the LLVM IR verifier pass">;
def disable_red_zone : Flag<["-"], "disable-red-zone">,
HelpText<"Do not emit code that uses the red zone.">;
def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">,
HelpText<"The compilation directory to embed in the debug info.">;
def dwarf_debug_flags : Separate<["-"], "dwarf-debug-flags">,
HelpText<"The string to embed in the Dwarf debug flags record.">;
def dwarf_column_info : Flag<["-"], "dwarf-column-info">,
HelpText<"Turn on column location information.">;
def split_dwarf : Flag<["-"], "split-dwarf">,
@ -188,10 +206,6 @@ def mfloat_abi : Separate<["-"], "mfloat-abi">,
HelpText<"The float ABI to use">;
def mlimit_float_precision : Separate<["-"], "mlimit-float-precision">,
HelpText<"Limit float precision to the given value">;
def mno_exec_stack : Flag<["-"], "mnoexecstack">,
HelpText<"Mark the file as not needing an executable stack">;
def compress_debug_sections : Flag<["-"], "compress-debug-sections">,
HelpText<"Compress DWARF debug sections using zlib">;
def split_stacks : Flag<["-"], "split-stacks">,
HelpText<"Try to use a split stack if possible.">;
def mno_zero_initialized_in_bss : Flag<["-"], "mno-zero-initialized-in-bss">,
@ -200,8 +214,6 @@ def backend_option : Separate<["-"], "backend-option">,
HelpText<"Additional arguments to forward to LLVM backend (during code gen)">;
def mregparm : Separate<["-"], "mregparm">,
HelpText<"Limit the number of registers available for integer arguments">;
def msave_temp_labels : Flag<["-"], "msave-temp-labels">,
HelpText<"(integrated-as) Save temporary labels">;
def mrelocation_model : Separate<["-"], "mrelocation-model">,
HelpText<"The relocation model to use">;
def munwind_tables : Flag<["-"], "munwind-tables">,
@ -272,6 +284,7 @@ def Wno_rewrite_macros : Flag<["-"], "Wno-rewrite-macros">,
// This isn't normally used, it is just here so we can parse a
// CompilerInvocation out of a driver-derived argument vector.
def cc1 : Flag<["-"], "cc1">;
def cc1as : Flag<["-"], "cc1as">;
def ast_merge : Separate<["-"], "ast-merge">,
MetaVarName<"<ast file>">,
@ -303,8 +316,6 @@ def plugin_arg : JoinedAndSeparate<["-"], "plugin-arg-">,
HelpText<"Pass <arg> to plugin <name>">;
def add_plugin : Separate<["-"], "add-plugin">, MetaVarName<"<name>">,
HelpText<"Use the named plugin action in addition to the default action">;
def version : Flag<["-"], "version">,
HelpText<"Print the compiler version">;
def ast_dump_filter : Separate<["-"], "ast-dump-filter">,
MetaVarName<"<dump_filter>">,
HelpText<"Use with -ast-dump or -ast-print to dump/print only AST declaration"
@ -401,12 +412,19 @@ def foverride_record_layout_EQ : Joined<["-"], "foverride-record-layout=">,
// Language Options
//===----------------------------------------------------------------------===//
let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
def version : Flag<["-"], "version">,
HelpText<"Print the compiler version">;
def main_file_name : Separate<["-"], "main-file-name">,
HelpText<"Main file name to use for debug info">;
}
def fblocks_runtime_optional : Flag<["-"], "fblocks-runtime-optional">,
HelpText<"Weakly link in the blocks runtime">;
def fsjlj_exceptions : Flag<["-"], "fsjlj-exceptions">,
HelpText<"Use SjLj style exceptions">;
def main_file_name : Separate<["-"], "main-file-name">,
HelpText<"Main file name to use for debug info">;
def split_dwarf_file : Separate<["-"], "split-dwarf-file">,
HelpText<"File name to use for split dwarf debug info output">;
def fno_wchar : Flag<["-"], "fno-wchar">,
@ -560,3 +578,32 @@ def fcuda_is_device : Flag<["-"], "fcuda-is-device">,
HelpText<"Generate code for CUDA device">;
} // let Flags = [CC1Option]
//===----------------------------------------------------------------------===//
// cc1as-only Options
//===----------------------------------------------------------------------===//
let Flags = [CC1AsOption, NoDriverOption] in {
// Language Options
def n : Flag<["-"], "n">,
HelpText<"Don't automatically start assembly file with a text section">;
// Frontend Options
def filetype : Separate<["-"], "filetype">,
HelpText<"Specify the output file type ('asm', 'null', or 'obj')">;
// Transliterate Options
def output_asm_variant : Separate<["-"], "output-asm-variant">,
HelpText<"Select the asm variant index to use for output">;
def show_encoding : Flag<["-"], "show-encoding">,
HelpText<"Show instruction encoding information in transliterate mode">;
def show_inst : Flag<["-"], "show-inst">,
HelpText<"Show internal instruction representation in transliterate mode">;
// Assemble Options
def dwarf_debug_producer : Separate<["-"], "dwarf-debug-producer">,
HelpText<"The string to embed in the Dwarf debug AT_producer record.">;
} // let Flags = [CC1AsOption]

View File

@ -1,7 +1,3 @@
set(LLVM_TARGET_DEFINITIONS Options.td)
tablegen(LLVM Options.inc -gen-opt-parser-defs)
add_public_tablegen_target(ClangDriverOptions)
set(LLVM_TARGET_DEFINITIONS CC1AsOptions.td)
tablegen(LLVM CC1AsOptions.inc -gen-opt-parser-defs)
add_public_tablegen_target(ClangCC1AsOptions)

View File

@ -30,7 +30,8 @@ enum ClangFlags {
CoreOption = (1 << 8),
CLOption = (1 << 9),
CC1Option = (1 << 10),
NoDriverOption = (1 << 11)
CC1AsOption = (1 << 11),
NoDriverOption = (1 << 12)
};
enum ID {

View File

@ -44,6 +44,9 @@ def CLOption : OptionFlag;
// CC1Option - This option should be accepted by clang -cc1.
def CC1Option : OptionFlag;
// CC1AsOption - This option should be accepted by clang -cc1as.
def CC1AsOption : OptionFlag;
// NoDriverOption - This option should not be accepted by the driver.
def NoDriverOption : OptionFlag;
@ -216,7 +219,7 @@ def G_EQ : Joined<["-"], "G=">, Flags<[DriverOption]>;
def H : Flag<["-"], "H">, Flags<[CC1Option]>,
HelpText<"Show header includes and nesting depth">;
def I_ : Flag<["-"], "I-">, Group<I_Group>;
def I : JoinedOrSeparate<["-"], "I">, Group<I_Group>, Flags<[CC1Option]>,
def I : JoinedOrSeparate<["-"], "I">, Group<I_Group>, Flags<[CC1Option,CC1AsOption]>,
HelpText<"Add directory to include search path">;
def L : JoinedOrSeparate<["-"], "L">, Flags<[RenderJoined]>;
def MD : Flag<["-"], "MD">, Group<M_Group>,
@ -922,7 +925,7 @@ def fdebug_types_section: Flag <["-"], "fdebug-types-section">, Group<f_Group>,
def fno_debug_types_section: Flag<["-"], "fno-debug-types-section">, Group<f_Group>,
Flags<[CC1Option]>;
def g_Flag : Flag<["-"], "g">, Group<g_Group>,
HelpText<"Generate source level debug information">, Flags<[CC1Option]>;
HelpText<"Generate source level debug information">, Flags<[CC1Option,CC1AsOption]>;
def gline_tables_only : Flag<["-"], "gline-tables-only">, Group<g_Group>,
HelpText<"Emit debug line number tables only">, Flags<[CC1Option]>;
def gmlt : Flag<["-"], "gmlt">, Alias<gline_tables_only>;
@ -936,11 +939,11 @@ def ggdb1 : Flag<["-"], "ggdb1">, Group<g_Group>;
def ggdb2 : Flag<["-"], "ggdb2">, Group<g_Group>;
def ggdb3 : Flag<["-"], "ggdb3">, Group<g_Group>;
def gdwarf_2 : Flag<["-"], "gdwarf-2">, Group<g_Group>,
HelpText<"Generate source level debug information with dwarf version 2">, Flags<[CC1Option]>;
HelpText<"Generate source level debug information with dwarf version 2">, Flags<[CC1Option,CC1AsOption]>;
def gdwarf_3 : Flag<["-"], "gdwarf-3">, Group<g_Group>,
HelpText<"Generate source level debug information with dwarf version 3">, Flags<[CC1Option]>;
HelpText<"Generate source level debug information with dwarf version 3">, Flags<[CC1Option,CC1AsOption]>;
def gdwarf_4 : Flag<["-"], "gdwarf-4">, Group<g_Group>,
HelpText<"Generate source level debug information with dwarf version 4">, Flags<[CC1Option]>;
HelpText<"Generate source level debug information with dwarf version 4">, Flags<[CC1Option,CC1AsOption]>;
def gfull : Flag<["-"], "gfull">, Group<g_Group>;
def gused : Flag<["-"], "gused">, Group<g_Group>;
def gstabs : Joined<["-"], "gstabs">, Group<g_Group>, Flags<[Unsupported]>;
@ -958,7 +961,7 @@ def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group<g_flags_Group>;
def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group<g_flags_Group>;
def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group<g_flags_Group>;
def headerpad__max__install__names : Joined<["-"], "headerpad_max_install_names">;
def help : Flag<["-", "--"], "help">, Flags<[CC1Option]>,
def help : Flag<["-", "--"], "help">, Flags<[CC1Option,CC1AsOption]>,
HelpText<"Display available options">;
def index_header_map : Flag<["-"], "index-header-map">, Flags<[CC1Option]>,
HelpText<"Make the next included directory (-I or -F) an indexer header map">;
@ -1037,7 +1040,7 @@ def mios_simulator_version_min_EQ : Joined<["-"], "mios-simulator-version-min=">
def mkernel : Flag<["-"], "mkernel">, Group<m_Group>;
def mlinker_version_EQ : Joined<["-"], "mlinker-version=">,
Flags<[DriverOption]>;
def mllvm : Separate<["-"], "mllvm">, Flags<[CC1Option, CoreOption]>,
def mllvm : Separate<["-"], "mllvm">, Flags<[CC1Option,CC1AsOption,CoreOption]>,
HelpText<"Additional arguments to forward to LLVM's option processing">;
def mmacosx_version_min_EQ : Joined<["-"], "mmacosx-version-min=">, Group<m_Group>;
def mms_bitfields : Flag<["-"], "mms-bitfields">, Group<m_Group>, Flags<[CC1Option]>,
@ -1144,7 +1147,7 @@ def moslib_EQ : Joined<["-"], "moslib=">, Group<m_Group>;
def mpascal_strings : Flag<["-"], "mpascal-strings">, Alias<fpascal_strings>;
def mred_zone : Flag<["-"], "mred-zone">, Group<m_Group>;
def mregparm_EQ : Joined<["-"], "mregparm=">, Group<m_Group>;
def mrelax_all : Flag<["-"], "mrelax-all">, Group<m_Group>, Flags<[CC1Option]>,
def mrelax_all : Flag<["-"], "mrelax-all">, Group<m_Group>, Flags<[CC1Option,CC1AsOption]>,
HelpText<"(integrated-as) Relax all machine instructions">;
def mrtd : Flag<["-"], "mrtd">, Group<m_Group>, Flags<[CC1Option]>,
HelpText<"Make StdCall calling convention the default">;
@ -1267,7 +1270,7 @@ def nostdincxx : Flag<["-"], "nostdinc++">, Flags<[CC1Option]>,
HelpText<"Disable standard #include directories for the C++ standard library">;
def nostdlib : Flag<["-"], "nostdlib">;
def object : Flag<["-"], "object">;
def o : JoinedOrSeparate<["-"], "o">, Flags<[DriverOption, RenderAsInput, CC1Option]>,
def o : JoinedOrSeparate<["-"], "o">, Flags<[DriverOption, RenderAsInput, CC1Option, CC1AsOption]>,
HelpText<"Write output to <file>">, MetaVarName<"<file>">;
def pagezero__size : JoinedOrSeparate<["-"], "pagezero_size">;
def pass_exit_codes : Flag<["-", "--"], "pass-exit-codes">, Flags<[Unsupported]>;

View File

@ -1,44 +0,0 @@
//===--- CC1AsOptions.cpp - Clang Assembler Options Table -----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/Driver/CC1AsOptions.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Option/OptTable.h"
#include "llvm/Option/Option.h"
using namespace clang;
using namespace clang::driver;
using namespace llvm::opt;
using namespace clang::driver::cc1asoptions;
#define PREFIX(NAME, VALUE) static const char *const NAME[] = VALUE;
#include "clang/Driver/CC1AsOptions.inc"
#undef PREFIX
static const OptTable::Info CC1AsInfoTable[] = {
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
HELPTEXT, METAVAR) \
{ PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, PARAM, \
FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS },
#include "clang/Driver/CC1AsOptions.inc"
#undef OPTION
};
namespace {
class CC1AsOptTable : public OptTable {
public:
CC1AsOptTable()
: OptTable(CC1AsInfoTable, llvm::array_lengthof(CC1AsInfoTable)) {}
};
}
OptTable *clang::driver::createCC1AsOptTable() {
return new CC1AsOptTable();
}

View File

@ -6,7 +6,6 @@ set(LLVM_LINK_COMPONENTS
add_clang_library(clangDriver
Action.cpp
CC1AsOptions.cpp
Compilation.cpp
Driver.cpp
DriverOptions.cpp
@ -22,7 +21,6 @@ add_clang_library(clangDriver
Types.cpp
DEPENDS
ClangCC1AsOptions
ClangDriverOptions
LINK_LIBS

View File

@ -14,7 +14,6 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Driver/CC1AsOptions.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/Options.h"
#include "clang/Frontend/FrontendDiagnostic.h"
@ -57,6 +56,7 @@
#include <system_error>
using namespace clang;
using namespace clang::driver;
using namespace clang::driver::options;
using namespace llvm;
using namespace llvm::opt;
@ -147,30 +147,64 @@ public:
}
#if 0
bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
const char *const *ArgBegin,
const char *const *ArgEnd,
DiagnosticsEngine &Diags) {
bool Success = true;
// Parse the arguments.
std::unique_ptr<OptTable> Opts(createDriverOptTable());
const unsigned IncludedFlagsBitmask = options::CC1Option;
unsigned MissingArgIndex, MissingArgCount;
std::unique_ptr<InputArgList> Args(
Opts->ParseArgs(ArgBegin, ArgEnd, MissingArgIndex, MissingArgCount,
IncludedFlagsBitmask));
// Check for missing argument error.
if (MissingArgCount) {
Diags.Report(diag::err_drv_missing_argument)
<< Args->getArgString(MissingArgIndex) << MissingArgCount;
Success = false;
}
// Issue errors on unknown arguments.
for (arg_iterator it = Args->filtered_begin(OPT_UNKNOWN),
ie = Args->filtered_end(); it != ie; ++it) {
Diags.Report(diag::err_drv_unknown_argument) << (*it)->getAsString(*Args);
Success = false;
}
}
#endif
bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
const char **ArgBegin,
const char **ArgEnd,
DiagnosticsEngine &Diags) {
using namespace clang::driver::cc1asoptions;
bool Success = true;
// Parse the arguments.
std::unique_ptr<OptTable> OptTbl(createCC1AsOptTable());
std::unique_ptr<OptTable> OptTbl(createDriverOptTable());
const unsigned IncludedFlagsBitmask = options::CC1AsOption;
unsigned MissingArgIndex, MissingArgCount;
std::unique_ptr<InputArgList> Args(
OptTbl->ParseArgs(ArgBegin, ArgEnd, MissingArgIndex, MissingArgCount));
OptTbl->ParseArgs(ArgBegin, ArgEnd, MissingArgIndex, MissingArgCount,
IncludedFlagsBitmask));
// Check for missing argument error.
if (MissingArgCount) {
Diags.Report(diag::err_drv_missing_argument)
<< Args->getArgString(MissingArgIndex) << MissingArgCount;
<< Args->getArgString(MissingArgIndex) << MissingArgCount;
Success = false;
}
// Issue errors on unknown arguments.
for (arg_iterator it = Args->filtered_begin(cc1asoptions::OPT_UNKNOWN),
ie = Args->filtered_end(); it != ie; ++it) {
Diags.Report(diag::err_drv_unknown_argument) << (*it) ->getAsString(*Args);
for (arg_iterator it = Args->filtered_begin(OPT_UNKNOWN),
ie = Args->filtered_end();
it != ie; ++it) {
Diags.Report(diag::err_drv_unknown_argument) << (*it)->getAsString(*Args);
Success = false;
}
@ -189,7 +223,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
Opts.IncludePaths = Args->getAllArgValues(OPT_I);
Opts.NoInitialTextSection = Args->hasArg(OPT_n);
Opts.SaveTemporaryLabels = Args->hasArg(OPT_msave_temp_labels);
Opts.GenDwarfForAssembly = Args->hasArg(OPT_g);
Opts.GenDwarfForAssembly = Args->hasArg(OPT_g_Flag);
Opts.CompressDebugSections = Args->hasArg(OPT_compress_debug_sections);
if (Args->hasArg(OPT_gdwarf_2))
Opts.DwarfVersion = 2;
@ -447,10 +481,11 @@ int cc1as_main(const char **ArgBegin, const char **ArgEnd,
if (!AssemblerInvocation::CreateFromArgs(Asm, ArgBegin, ArgEnd, Diags))
return 1;
// Honor -help.
if (Asm.ShowHelp) {
std::unique_ptr<OptTable> Opts(driver::createCC1AsOptTable());
Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler");
std::unique_ptr<OptTable> Opts(driver::createDriverOptTable());
Opts->PrintHelp(llvm::outs(), "clang -cc1as",
"Clang Integrated Assembler",
/*Include=*/ driver::options::CC1AsOption, /*Exclude=*/ 0);
return 0;
}
@ -484,3 +519,4 @@ int cc1as_main(const char **ArgBegin, const char **ArgEnd,
return !!Failed;
}