[PATCH] D141338: [WIP][-Wunsafe-buffer-usage] Filter out conflicting fix-its
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 12 21:32:27 PST 2023
NoQ added a comment.
Looks awesome!
================
Comment at: clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h:45-48
+// Tests if any two `FixItHint`s in `FixIts` conflict. Two `FixItHint`s
+// conflict if they have overlapping source ranges.
+bool anyConflict(const SourceManager &SM, const llvm::SmallVectorImpl<FixItHint> &FixIts);
+
----------------
Maybe we should put it into some namespace, so that it didn't look like it's part of our public interface?
================
Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:695-696
+ const llvm::SmallVectorImpl<FixItHint> &FixIts) {
+ // A simple interval overlap detecting algorithm. Sorts all ranges by their
+ // begin location then find any overlap in one pass.
+ std::vector<const FixItHint *> All; // a copy of `FixIts`
----------------
Nitpicks.
================
Comment at: clang/unittests/Analysis/UnsafeBufferUsageTest.cpp:17
+ Diags(DiagID, new DiagnosticOptions, new IgnoringDiagConsumer()),
+ SourceMgr(Diags, FileMgr) {}
+
----------------
Oh my, you constructed it just like that and it worked? This is awesome!
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141338/new/
https://reviews.llvm.org/D141338
More information about the cfe-commits
mailing list