[PATCH] D106361: [clang-tidy] Fix crash and handle AttributedTypes in 'bugprone-easily-swappable-parameters'

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 21 09:21:09 PDT 2021


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!



================
Comment at: clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:476-477
+
+    QualType NewCoreType = CoreType;
+    NewCoreType.addFastQualifiers(Quals.getFastQualifiers());
+    NewCoreType.getQualifiers().addQualifiers(Quals);
----------------
whisperity wrote:
> whisperity wrote:
> > aaron.ballman wrote:
> > > 
> > Actually, the suggestion is also bad. `getQualifiers()` returns a **copy** on which adding is a moot operation... Turns out you can use `ASTContext` to //create// a specifically qualified type for you.
> > 
> > Now if there was a way to express this in the type of `getQualifiers()`, to warn you //"Don't make the mistake of thinking this would CHANGE anything!"//...
> Sorry, I mean, not the suggestion per se, but these 4 new lines of code contained multiple issues.
Ah, this looks much better, thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106361/new/

https://reviews.llvm.org/D106361



More information about the cfe-commits mailing list