[Driver] Change -fmax-tokens $arg to -fmax-tokens=$arg

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D73937
This commit is contained in:
Fangrui Song 2020-02-03 17:07:41 -08:00
parent a05566c994
commit 2513118afa
6 changed files with 10 additions and 11 deletions

View File

@ -1168,14 +1168,14 @@ the token limit, which can be set in three ways:
.. code-block: c++
#pragma clang max_tokens_here 1234
2. As a per-translation unit limit, using the ``-fmax-tokens`` command-line
2. As a per-translation unit limit, using the ``-fmax-tokens=`` command-line
flag:
.. code-block: console
clang -c a.cpp -fmax-tokens 1234
clang -c a.cpp -fmax-tokens=1234
3. As a per-translation unit limit using the ``clang max_tokens_total`` pragma,
which works like and overrides the ``-fmax-tokens`` flag:
which works like and overrides the ``-fmax-tokens=`` flag:
.. code-block: c++
#pragma clang max_file_tokens 1234

View File

@ -646,9 +646,8 @@ def emit_merged_ifs : Flag<["-"], "emit-merged-ifs">,
def interface_stub_version_EQ : JoinedOrSeparate<["-"], "interface-stub-version=">, Flags<[CC1Option]>;
def exported__symbols__list : Separate<["-"], "exported_symbols_list">;
def e : JoinedOrSeparate<["-"], "e">, Group<Link_Group>;
def fmax_tokens : Separate<["-"], "fmax-tokens">,
HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">,
Group<f_Group>, Flags<[CC1Option]>;
def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group<f_Group>, Flags<[CC1Option]>,
HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">;
def fPIC : Flag<["-"], "fPIC">, Group<f_Group>;
def fno_PIC : Flag<["-"], "fno-PIC">, Group<f_Group>;
def fPIE : Flag<["-"], "fPIE">, Group<f_Group>;

View File

@ -5731,7 +5731,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddLastArg(CmdArgs, options::OPT_dM);
Args.AddLastArg(CmdArgs, options::OPT_dD);
Args.AddLastArg(CmdArgs, options::OPT_fmax_tokens);
Args.AddLastArg(CmdArgs, options::OPT_fmax_tokens_EQ);
// Handle serialized diagnostics.
if (Arg *A = Args.getLastArg(options::OPT__serialize_diags)) {

View File

@ -3320,7 +3320,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.CompleteMemberPointers = Args.hasArg(OPT_fcomplete_member_pointers);
Opts.BuildingPCHWithObjectFile = Args.hasArg(OPT_building_pch_with_obj);
Opts.MaxTokens = getLastArgIntValue(Args, OPT_fmax_tokens, 0, Diags);
Opts.MaxTokens = getLastArgIntValue(Args, OPT_fmax_tokens_EQ, 0, Diags);
}
static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {

View File

@ -650,7 +650,7 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result, bool IsFirstDecl) {
return false;
case tok::eof:
// Check whether -fmax-tokens was reached.
// Check whether -fmax-tokens= was reached.
if (PP.getMaxTokens() != 0 && PP.getTokenCount() > PP.getMaxTokens()) {
PP.Diag(Tok.getLocation(), diag::warn_max_tokens_total)
<< PP.getTokenCount() << PP.getMaxTokens();

View File

@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS -fmax-tokens 2
// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS_OVERRIDE -fmax-tokens 9
// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS -fmax-tokens=2
// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS_OVERRIDE -fmax-tokens=9
int x, y, z;