Author: Fangrui Song Date: 2020-02-04T09:39:48-08:00 New Revision: 2513118afa385b9df3662050e3aa0a1e3f5e2a8a
URL: https://github.com/llvm/llvm-project/commit/2513118afa385b9df3662050e3aa0a1e3f5e2a8a DIFF: https://github.com/llvm/llvm-project/commit/2513118afa385b9df3662050e3aa0a1e3f5e2a8a.diff LOG: [Driver] Change -fmax-tokens $arg to -fmax-tokens=$arg Reviewed By: hans Differential Revision: https://reviews.llvm.org/D73937 Added: Modified: clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Parse/Parser.cpp clang/test/Parser/max-tokens.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 12551b13e7bb..2dcedcb60340 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -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 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index dcec7e6fde1e..388ff094ae44 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -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>; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 64bba78ac26f..aa599b02e44a 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -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)) { diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index a71145202052..9f51c8478327 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -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) { diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index fd05b760cc90..f23742f67e3b 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -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(); diff --git a/clang/test/Parser/max-tokens.cpp b/clang/test/Parser/max-tokens.cpp index 982432e8a65c..5be892773fe4 100644 --- a/clang/test/Parser/max-tokens.cpp +++ b/clang/test/Parser/max-tokens.cpp @@ -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; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits