[PATCH] D65919: [clang-tidy] Add llvm-prefer-register-over-unsigned check and apply it to LLVM
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 8 13:48:52 PDT 2019
aaron.ballman added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp:40
+
+ diag(UserVarDecl->getLocation(), "var %0 is %1 but holds a register")
+ << UserVarDecl << *VarType;
----------------
How about `variable %0 declared as %1; use '%2' instead` and move it below to where the fix-it is issued?
================
Comment at: clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp:44
+ const DeclContext *Context = UserVarDecl->getDeclContext();
+ while((Context = Context->getParent()) != nullptr) {
+ if (const auto *Namespace = dyn_cast<NamespaceDecl>(Context))
----------------
Formatting looks off here, you should run the patch through clang-format.
================
Comment at: clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp:53
+ }
+ diag(UserVarDecl->getLocation(), "use '%0'", DiagnosticIDs::Note)
+ << Replacement
----------------
I don't think you should issue a second diagnostic on the same line. Instead, only issue the previous diagnostic with the fixit attached to it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65919/new/
https://reviews.llvm.org/D65919
More information about the cfe-commits
mailing list