Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Sema] add -Walloca to flag uses of
alloca
This CL adds an optional warning to diagnose uses of the `__builtin_alloca` family of functions. The use of these functions is discouraged by many, so it seems like a good idea to allow clang to warn about it. Patch by Elaina Guan! Differential Revision: https://reviews.llvm.org/D64883 llvm-svn: 367067
- Loading branch information
1 parent
29af3b4
commit 9d045a5
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// RUN: %clang_cc1 -DSILENCE -fsyntax-only -verify -Wall %s | ||
// RUN: %clang_cc1 -fsyntax-only -verify -Walloca %s | ||
|
||
#ifdef SILENCE | ||
// expected-no-diagnostics | ||
#endif | ||
|
||
void test1(int a) { | ||
__builtin_alloca(a); | ||
#ifndef SILENCE | ||
// expected-warning@-2 {{use of function '__builtin_alloca' is discouraged; there is no way to check for failure but failure may still occur, resulting in a possibly exploitable security vulnerability}} | ||
#endif | ||
} | ||
|
||
void test2(int a) { | ||
__builtin_alloca_with_align(a, 32); | ||
#ifndef SILENCE | ||
// expected-warning@-2 {{use of function '__builtin_alloca_with_align' is discouraged; there is no way to check for failure but failure may still occur, resulting in a possibly exploitable security vulnerability}} | ||
#endif | ||
} |