[clang] [-Wunsafe-buffer-usage] Fix AST matcher of UUCAddAssignGadget (PR #79392)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 24 16:25:43 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-analysis
Author: None (jkorous-apple)
<details>
<summary>Changes</summary>
We are not interested in nonpointers being added to.
---
Full diff: https://github.com/llvm/llvm-project/pull/79392.diff
1 Files Affected:
- (modified) clang/lib/Analysis/UnsafeBufferUsage.cpp (+6-1)
``````````diff
diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 7df706beb22662c..fd7a76d511862ec 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -1081,11 +1081,16 @@ class UUCAddAssignGadget : public FixableGadget {
}
static Matcher matcher() {
+// clang-format off
return stmt(isInUnspecifiedUntypedContext(expr(ignoringImpCasts(
binaryOperator(hasOperatorName("+="),
- hasLHS(declRefExpr(toSupportedVariable())),
+ hasLHS(
+ declRefExpr(
+ hasPointerType(),
+ toSupportedVariable())),
hasRHS(expr().bind(OffsetTag)))
.bind(UUCAddAssignTag)))));
+// clang-format on
}
virtual std::optional<FixItList> getFixits(const Strategy &S) const override;
``````````
</details>
https://github.com/llvm/llvm-project/pull/79392
More information about the cfe-commits
mailing list