[PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'
Piotr Padlewski via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 23 23:59:46 PDT 2016
Prazek added inline comments.
================
Comment at: clang-tidy/modernize/UseCopyCheck.cpp:49
@@ +48,3 @@
+ if (getLangOpts().CPlusPlus) {
+ Inserter.reset(new utils::IncludeInserter(
+ Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle));
----------------
there is actually llvm::make_shared somewhere
================
Comment at: clang-tidy/modernize/UseCopyCheck.cpp:59-61
@@ +58,5 @@
+
+ // Don't make replacements in macro
+ if (Loc.isMacroID())
+ return;
+
----------------
What you should do is you should print out the warning, but not make the replacement for macro (because you can't get the exact location)
So just move auto Diag = ... above this line.
Also finish comments with coma.
================
Comment at: test/clang-tidy/modernize-use-copy.cpp:17
@@ +16,3 @@
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcpy
+ // [modernize-use-copy]
+ // CHECK-FIXES: std::copy(foo, (foo) + (sizeof bar), bar);
----------------
This won't be checked. The long checking comments are ok in tests.
================
Comment at: test/clang-tidy/modernize-use-copy.cpp:34
@@ +33,3 @@
+
+#define memcpy(dest, src, len) std::memcpy((dest), (src), (len))
+void g() {
----------------
change it to MEMCPY, and maybe remove the last argument (so it will be set to sizeof dest), because this macro doesn't make much sense right now.
================
Comment at: test/clang-tidy/modernize-use-copy.cpp:37
@@ +36,3 @@
+ char foo[] = "foo", bar[3];
+ memcpy(bar, foo, sizeof bar);
+}
----------------
so ter should be a warning here.
Repository:
rL LLVM
https://reviews.llvm.org/D22725
More information about the cfe-commits
mailing list