diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 41dfafd9594fd..879f12fe3a1e3 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1502,8 +1502,12 @@ defm constant_cfstrings : BoolFOption<"constant-cfstrings", NegFlag, PosFlag>; def fconstant_string_class_EQ : Joined<["-"], "fconstant-string-class=">, Group; -def fconstexpr_depth_EQ : Joined<["-"], "fconstexpr-depth=">, Group; -def fconstexpr_steps_EQ : Joined<["-"], "fconstexpr-steps=">, Group; +def fconstexpr_depth_EQ : Joined<["-"], "fconstexpr-depth=">, Group, Flags<[CC1Option]>, + HelpText<"Set the maximum depth of recursive constexpr function calls">, + MarshallingInfoInt, "512">; +def fconstexpr_steps_EQ : Joined<["-"], "fconstexpr-steps=">, Group, Flags<[CC1Option]>, + HelpText<"Set the maximum number of steps in constexpr function evaluation">, + MarshallingInfoInt, "1048576">; def fexperimental_new_constant_interpreter : Flag<["-"], "fexperimental-new-constant-interpreter">, Group, HelpText<"Enable the experimental new constant interpreter">, Flags<[CC1Option]>, MarshallingInfoFlag>; @@ -2974,8 +2978,9 @@ def : Joined<["-"], "ftemplate-depth-">, Group, Alias, MarshallingInfoInt, "DiagnosticOptions::DefaultTemplateBacktraceLimit">; -def foperator_arrow_depth_EQ : Joined<["-"], "foperator-arrow-depth=">, - Group; +def foperator_arrow_depth_EQ : Joined<["-"], "foperator-arrow-depth=">, Group, Flags<[CC1Option]>, + HelpText<"Maximum number of 'operator->'s to call for a member access">, + MarshallingInfoInt, "256">; def fsave_optimization_record : Flag<["-"], "fsave-optimization-record">, Group, HelpText<"Generate a YAML optimization record file">; @@ -6391,15 +6396,6 @@ def ftype_visibility : Joined<["-"], "ftype-visibility=">, def fapply_global_visibility_to_externs : Flag<["-"], "fapply-global-visibility-to-externs">, HelpText<"Apply global symbol visibility to external declarations without an explicit visibility">, MarshallingInfoFlag>; -def foperator_arrow_depth : Separate<["-"], "foperator-arrow-depth">, - HelpText<"Maximum number of 'operator->'s to call for a member access">, - MarshallingInfoInt, "256">; -def fconstexpr_depth : Separate<["-"], "fconstexpr-depth">, - HelpText<"Maximum depth of recursive constexpr function calls">, - MarshallingInfoInt, "512">; -def fconstexpr_steps : Separate<["-"], "fconstexpr-steps">, - HelpText<"Maximum number of steps in constexpr function evaluation">, - MarshallingInfoInt, "1048576">; def fbracket_depth : Separate<["-"], "fbracket-depth">, HelpText<"Maximum nesting level for parentheses, brackets, and braces">, MarshallingInfoInt, "256">; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index a832d32d43096..9089e655a13c5 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5970,21 +5970,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, addDebugPrefixMapArg(D, TC, Args, CmdArgs); Args.AddLastArg(CmdArgs, options::OPT_ftemplate_depth_EQ); - - if (Arg *A = Args.getLastArg(options::OPT_foperator_arrow_depth_EQ)) { - CmdArgs.push_back("-foperator-arrow-depth"); - CmdArgs.push_back(A->getValue()); - } - - if (Arg *A = Args.getLastArg(options::OPT_fconstexpr_depth_EQ)) { - CmdArgs.push_back("-fconstexpr-depth"); - CmdArgs.push_back(A->getValue()); - } - - if (Arg *A = Args.getLastArg(options::OPT_fconstexpr_steps_EQ)) { - CmdArgs.push_back("-fconstexpr-steps"); - CmdArgs.push_back(A->getValue()); - } + Args.AddLastArg(CmdArgs, options::OPT_foperator_arrow_depth_EQ); + Args.AddLastArg(CmdArgs, options::OPT_fconstexpr_depth_EQ); + Args.AddLastArg(CmdArgs, options::OPT_fconstexpr_steps_EQ); Args.AddLastArg(CmdArgs, options::OPT_fexperimental_library); diff --git a/clang/test/AST/Interp/depth-limit.cpp b/clang/test/AST/Interp/depth-limit.cpp index a6d5e56b141c3..6c21e5e65f0e0 100644 --- a/clang/test/AST/Interp/depth-limit.cpp +++ b/clang/test/AST/Interp/depth-limit.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fconstexpr-depth 100 -verify %s -// RUN: %clang_cc1 -fconstexpr-depth 100 -verify=ref %s +// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fconstexpr-depth=100 -verify %s +// RUN: %clang_cc1 -fconstexpr-depth=100 -verify=ref %s constexpr int f(int a) { if (a == 100) diff --git a/clang/test/AST/Interp/depth-limit2.cpp b/clang/test/AST/Interp/depth-limit2.cpp index 3f6e64a5cf67f..72285ae9ddae0 100644 --- a/clang/test/AST/Interp/depth-limit2.cpp +++ b/clang/test/AST/Interp/depth-limit2.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fconstexpr-depth 2 -verify %s -// RUN: %clang_cc1 -fconstexpr-depth 2 -verify=ref %s +// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fconstexpr-depth=2 -verify %s +// RUN: %clang_cc1 -fconstexpr-depth=2 -verify=ref %s constexpr int func() { diff --git a/clang/test/CXX/expr/expr.const/p2-0x.cpp b/clang/test/CXX/expr/expr.const/p2-0x.cpp index 9044844607e05..e3cd057baba75 100644 --- a/clang/test/CXX/expr/expr.const/p2-0x.cpp +++ b/clang/test/CXX/expr/expr.const/p2-0x.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -pedantic -verify=expected,cxx11 -fcxx-exceptions %s -fconstexpr-depth 128 -triple i686-pc-linux-gnu -// RUN: %clang_cc1 -fsyntax-only -std=c++2a -pedantic -verify=expected,cxx20 -fcxx-exceptions %s -fconstexpr-depth 128 -triple i686-pc-linux-gnu +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -pedantic -verify=expected,cxx11 -fcxx-exceptions %s -fconstexpr-depth=128 -triple i686-pc-linux-gnu +// RUN: %clang_cc1 -fsyntax-only -std=c++2a -pedantic -verify=expected,cxx20 -fcxx-exceptions %s -fconstexpr-depth=128 -triple i686-pc-linux-gnu // A conditional-expression is a core constant expression unless it involves one // of the following as a potentially evaluated subexpression [...]: diff --git a/clang/test/SemaCXX/constexpr-backtrace-limit.cpp b/clang/test/SemaCXX/constexpr-backtrace-limit.cpp index 61e810c817eb5..e867afdff5c3c 100644 --- a/clang/test/SemaCXX/constexpr-backtrace-limit.cpp +++ b/clang/test/SemaCXX/constexpr-backtrace-limit.cpp @@ -1,4 +1,4 @@ -// RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit=0 -fconstexpr-depth 4 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST1 +// RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit=0 -fconstexpr-depth=4 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST1 // TEST1: constant expression // TEST1-NEXT: exceeded maximum depth of 4 // TEST1-NEXT: in call to 'recurse(2)' @@ -6,21 +6,21 @@ // TEST1-NEXT: in call to 'recurse(4)' // TEST1-NEXT: in call to 'recurse(5)' -// RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit=2 -fconstexpr-depth 4 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST2 +// RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit=2 -fconstexpr-depth=4 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST2 // TEST2: constant expression // TEST2-NEXT: exceeded maximum depth of 4 // TEST2-NEXT: in call to 'recurse(2)' // TEST2-NEXT: skipping 2 calls // TEST2-NEXT: in call to 'recurse(5)' -// RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit=2 -fconstexpr-depth 8 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST3 +// RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit=2 -fconstexpr-depth=8 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST3 // TEST3: constant expression // TEST3-NEXT: reinterpret_cast // TEST3-NEXT: in call to 'recurse(0)' // TEST3-NEXT: skipping 4 calls // TEST3-NEXT: in call to 'recurse(5)' -// RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit=8 -fconstexpr-depth 8 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST4 +// RUN: not %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit=8 -fconstexpr-depth=8 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST4 // TEST4: constant expression // TEST4-NEXT: reinterpret_cast // TEST4-NEXT: in call to 'recurse(0)' diff --git a/clang/test/SemaCXX/constexpr-depth.cpp b/clang/test/SemaCXX/constexpr-depth.cpp index feba6fde3fbd7..9ce41ed287577 100644 --- a/clang/test/SemaCXX/constexpr-depth.cpp +++ b/clang/test/SemaCXX/constexpr-depth.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -DMAX=128 -fconstexpr-depth 128 -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -DMAX=2 -fconstexpr-depth 2 +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -DMAX=128 -fconstexpr-depth=128 +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -DMAX=2 -fconstexpr-depth=2 // RUN: %clang -std=c++11 -fsyntax-only -Xclang -verify %s -DMAX=10 -fconstexpr-depth=10 constexpr int depth(int n) { return n > 1 ? depth(n-1) : 0; } // expected-note {{exceeded maximum depth}} expected-note +{{}} diff --git a/clang/test/SemaCXX/constexpr-steps.cpp b/clang/test/SemaCXX/constexpr-steps.cpp index f7967eee9f78f..5ec4aa82b8cac 100644 --- a/clang/test/SemaCXX/constexpr-steps.cpp +++ b/clang/test/SemaCXX/constexpr-steps.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -std=c++1y -fsyntax-only -verify %s -DMAX=1234 -fconstexpr-steps 1234 -// RUN: %clang_cc1 -std=c++1y -fsyntax-only -verify %s -DMAX=10 -fconstexpr-steps 10 +// RUN: %clang_cc1 -std=c++1y -fsyntax-only -verify %s -DMAX=1234 -fconstexpr-steps=1234 +// RUN: %clang_cc1 -std=c++1y -fsyntax-only -verify %s -DMAX=10 -fconstexpr-steps=10 // RUN: %clang -std=c++1y -fsyntax-only -Xclang -verify %s -DMAX=12345 -fconstexpr-steps=12345 // This takes a total of n + 4 steps according to our current rules: diff --git a/clang/test/SemaCXX/operator-arrow-depth.cpp b/clang/test/SemaCXX/operator-arrow-depth.cpp index 769dae0d2461e..7db702620af38 100644 --- a/clang/test/SemaCXX/operator-arrow-depth.cpp +++ b/clang/test/SemaCXX/operator-arrow-depth.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX=128 -foperator-arrow-depth 128 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX=2 -foperator-arrow-depth 2 +// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX=128 -foperator-arrow-depth=128 +// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX=2 -foperator-arrow-depth=2 // RUN: %clang -fsyntax-only -Xclang -verify %s -DMAX=10 -foperator-arrow-depth=10 template struct B;