[clang] f78c343 - [-Wunsafe-buffer-usage] Create Fix-Its only if they are emitted
Ziqing Luo via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 23 14:47:58 PST 2023
Author: Ziqing Luo
Date: 2023-02-23T14:47:43-08:00
New Revision: f78c34346635e25919e2777b1b1cbb9627d5ad43
URL: https://github.com/llvm/llvm-project/commit/f78c34346635e25919e2777b1b1cbb9627d5ad43
DIFF: https://github.com/llvm/llvm-project/commit/f78c34346635e25919e2777b1b1cbb9627d5ad43.diff
LOG: [-Wunsafe-buffer-usage] Create Fix-Its only if they are emitted
`-Wunsafe-buffer-usage` diagnostics shall not emit fix-its if fix-its
are globally disabled.
Commit on behalf of jkorous (Jan Korous)
Reviewed by: NoQ (Artem Dergachev)
Differential revision: https://reviews.llvm.org/D143697
Added:
Modified:
clang/lib/Analysis/UnsafeBufferUsage.cpp
clang/lib/Sema/AnalysisBasedWarnings.cpp
Removed:
################################################################################
diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 61c2c4e4b52ad..bfae5a6ea3351 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -1017,8 +1017,6 @@ void clang::checkUnsafeBufferUsage(const Decl *D,
DeclUseTracker Tracker;
{
- // FIXME: We could skip even matching Fixables' matchers if EmitFixits ==
- // false.
auto [FixableGadgets, WarningGadgets, TrackerRes] = findGadgets(D, Handler);
UnsafeOps = groupWarningGadgetsByVar(std::move(WarningGadgets));
FixablesForUnsafeVars = groupFixablesByVar(std::move(FixableGadgets));
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index 85dc3a7eb9507..07e17f9f71072 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2518,7 +2518,8 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings(
UnsafeBufferUsageReporter R(S);
checkUnsafeBufferUsage(
D, R,
- /*EmitFixits=*/S.getLangOpts().CPlusPlus20);
+ /*EmitFixits=*/S.getDiagnostics().getDiagnosticOptions().ShowFixits &&
+ S.getLangOpts().CPlusPlus20);
}
// If none of the previous checks caused a CFG build, trigger one here
More information about the cfe-commits
mailing list