Skip to content

Commit 5fc4828

Browse files
committed
[clang] Don't generate warn-stack-size when the warning is ignored
8ace121 introduced a regression for code that explicitly ignores the -Wframe-larger-than= warning. Make sure we don't generate the warn-stack-size attribute for that case. Differential Revision: https://reviews.llvm.org/D108686
1 parent 323a6bf commit 5fc4828

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,8 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
10491049
Fn->addFnAttr("packed-stack");
10501050
}
10511051

1052-
if (CGM.getCodeGenOpts().WarnStackSize != UINT_MAX)
1052+
if (CGM.getCodeGenOpts().WarnStackSize != UINT_MAX &&
1053+
!CGM.getDiags().isIgnored(diag::warn_fe_backend_frame_larger_than, Loc))
10531054
Fn->addFnAttr("warn-stack-size",
10541055
std::to_string(CGM.getCodeGenOpts().WarnStackSize));
10551056

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Test the warn-stack-size function attribute is not generated when -Wframe-larger-than is ignored
2+
// through pragma.
3+
4+
// RUN: %clang_cc1 -fwarn-stack-size=70 -emit-llvm -o - %s | FileCheck %s
5+
// CHECK: "warn-stack-size"="70"
6+
7+
// RUN: %clang_cc1 -DIGNORED -fwarn-stack-size=70 -emit-llvm -o - %s | FileCheck %s --check-prefix=IGNORED
8+
// IGNORED-NOT: "warn-stack-size"="70"
9+
10+
extern void doIt(char *);
11+
12+
#ifdef IGNORED
13+
#pragma GCC diagnostic push
14+
#pragma GCC diagnostic ignored "-Wframe-larger-than"
15+
#endif
16+
17+
void frameSizeAttr() {
18+
char buffer[80];
19+
doIt(buffer);
20+
}
21+
22+
#ifdef IGNORED
23+
#pragma GCC diagnostic pop
24+
#endif

0 commit comments

Comments
 (0)