Skip to content

Commit 2345796

Browse files
committed
Revert "[-Wunsafe-buffer-usage] Warning Libc functions (#101583)"
This reverts commit 0fffdeb. Will re-land this commit soon with a way to opt-out
1 parent aecbc92 commit 2345796

8 files changed

+4
-716
lines changed

clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#define LLVM_CLANG_ANALYSIS_ANALYSES_UNSAFEBUFFERUSAGE_H
1616

1717
#include "clang/AST/Decl.h"
18-
#include "clang/AST/Expr.h"
1918
#include "clang/AST/Stmt.h"
2019
#include "clang/Basic/SourceLocation.h"
2120
#include "llvm/Support/Debug.h"
@@ -107,20 +106,6 @@ class UnsafeBufferUsageHandler {
107106
virtual void handleUnsafeOperation(const Stmt *Operation,
108107
bool IsRelatedToDecl, ASTContext &Ctx) = 0;
109108

110-
/// Invoked when a call to an unsafe libc function is found.
111-
/// \param PrintfInfo
112-
/// is 0 if the callee function is not a member of the printf family;
113-
/// is 1 if the callee is `sprintf`;
114-
/// is 2 if arguments of the call have `__size_by` relation but are not in a
115-
/// safe pattern;
116-
/// is 3 if string arguments do not guarantee null-termination
117-
/// is 4 if the callee takes va_list
118-
/// \param UnsafeArg one of the actual arguments that is unsafe, non-null
119-
/// only when `2 <= PrintfInfo <= 3`
120-
virtual void handleUnsafeLibcCall(const CallExpr *Call, unsigned PrintfInfo,
121-
ASTContext &Ctx,
122-
const Expr *UnsafeArg = nullptr) = 0;
123-
124109
/// Invoked when an unsafe operation with a std container is found.
125110
virtual void handleUnsafeOperationInContainer(const Stmt *Operation,
126111
bool IsRelatedToDecl,

clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ WARNING_GADGET(PointerArithmetic)
3838
WARNING_GADGET(UnsafeBufferUsageAttr)
3939
WARNING_GADGET(UnsafeBufferUsageCtorAttr)
4040
WARNING_GADGET(DataInvocation)
41-
WARNING_GADGET(UnsafeLibcFunctionCall)
4241
WARNING_CONTAINER_GADGET(SpanTwoParamConstructor) // Uses of `std::span(arg0, arg1)`
4342
FIXABLE_GADGET(ULCArraySubscript) // `DRE[any]` in an Unspecified Lvalue Context
4443
FIXABLE_GADGET(DerefSimplePtrArithFixable)

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12412,13 +12412,6 @@ def warn_unsafe_buffer_operation : Warning<
1241212412
"unsafe buffer access|function introduces unsafe buffer manipulation|unsafe invocation of span::data|"
1241312413
"field %1 prone to unsafe buffer manipulation}0">,
1241412414
InGroup<UnsafeBufferUsage>, DefaultIgnore;
12415-
def warn_unsafe_buffer_libc_call : Warning<
12416-
"function %0 is unsafe">,
12417-
InGroup<UnsafeBufferUsage>, DefaultIgnore;
12418-
def note_unsafe_buffer_printf_call : Note<
12419-
"%select{|change to 'snprintf' for explicit bounds checking | buffer pointer and size may not match"
12420-
"|string argument is not guaranteed to be null-terminated"
12421-
"|'va_list' is unsafe}0">;
1242212415
def note_unsafe_buffer_operation : Note<
1242312416
"used%select{| in pointer arithmetic| in buffer access}0 here">;
1242412417
def note_unsafe_buffer_variable_fixit_group : Note<

0 commit comments

Comments
 (0)