diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2500,6 +2500,8 @@ def Wlarger_than_EQ : Joined<["-"], "Wlarger-than=">, Group; def Wlarger_than_ : Joined<["-"], "Wlarger-than-">, Alias; def Wframe_larger_than_EQ : Joined<["-"], "Wframe-larger-than=">, Group, Flags<[NoXarchOption]>; +def Wstack_stack_usage_EQ : Joined<["-"], "Wstack-usage=">, Flags<[NoXarchOption]>, + Alias; def : Flag<["-"], "fterminated-vtables">, Alias; defm threadsafe_statics : BoolFOption<"threadsafe-statics", diff --git a/clang/lib/Basic/Warnings.cpp b/clang/lib/Basic/Warnings.cpp --- a/clang/lib/Basic/Warnings.cpp +++ b/clang/lib/Basic/Warnings.cpp @@ -94,6 +94,11 @@ if (Opt == "format=0") Opt = "no-format"; + // -Wstack-usage is aliased to -Wframe-larger-than, this handles + // the negative case, as table gen does not. + if (Opt == "no-stack-usage=") + Opt = "no-frame-larger-than="; + // Check to see if this warning starts with "no-", if so, this is a // negative form of the option. bool isPositive = true; diff --git a/clang/test/Frontend/backend-stack-usage-diagnostic.c b/clang/test/Frontend/backend-stack-usage-diagnostic.c new file mode 100644 --- /dev/null +++ b/clang/test/Frontend/backend-stack-usage-diagnostic.c @@ -0,0 +1,17 @@ +// RUN: %clang -Wstack-usage=0 -o /dev/null -c %s 2> %t.err +// RUN: FileCheck < %t.err %s --check-prefix=WARN +// RUN: %clang -Wno-stack-usage= -w -o /dev/null -c %s 2> %t.err +// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty +// RUN: %clang -Wstack-usage=0 -w -o /dev/null -c %s 2> %t.err +// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty +// RUN: %clang -Wstack-usage=3 -o /dev/null -c %s 2> %t.err +// RUN: FileCheck < %t.err %s --check-prefix=WARN +// RUN: %clang -Wstack-usage=100 -o /dev/null -c %s 2> %t.err +// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty + +// WARN: warning: stack frame size of {{[0-9]+}} bytes in function 'test_square' +// IGNORE-NOT: stack frame size of {{[0-9]+}} bytes in function 'test_square' +int test_square(int num) { + return num * num; +} +