summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2019-07-25 22:23:40 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2019-07-25 22:23:40 +0000
commit9d045a5c1e6b7b32cec8bcf140e5bffa5ac812bd (patch)
tree9a9d76c2f39b252b739eb5c8812fb638f0f77c03 /clang/lib/Sema/SemaChecking.cpp
parent29af3b4e67713e929b3022d96c8e54408ed9cf46 (diff)
downloadbcm5719-llvm-9d045a5c1e6b7b32cec8bcf140e5bffa5ac812bd.tar.gz
bcm5719-llvm-9d045a5c1e6b7b32cec8bcf140e5bffa5ac812bd.zip
[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
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index f9f82cdeef4..436e17a0e39 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1179,6 +1179,10 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
case Builtin::BI__builtin_alloca_with_align:
if (SemaBuiltinAllocaWithAlign(TheCall))
return ExprError();
+ LLVM_FALLTHROUGH;
+ case Builtin::BI__builtin_alloca:
+ Diag(TheCall->getBeginLoc(), diag::warn_alloca)
+ << TheCall->getDirectCallee();
break;
case Builtin::BI__assume:
case Builtin::BI__builtin_assume:
OpenPOWER on IntegriCloud