[PATCH] Initial version of clang-tidy check to use override instead of virual.

Alexander Kornienko alexfh at google.com
Fri May 9 03:12:32 PDT 2014


This check (especially the fix part) would be really nice to have.

================
Comment at: clang-tidy/misc/UseOverride.cpp:32
@@ +31,3 @@
+  if (Method->getInstantiatedFromMemberFunction() != nullptr)
+    Method = Method->getInstantiatedFromMemberFunction();
+
----------------
Does it make sense to check for getLocation().isMacroID() after this?

================
Comment at: clang-tidy/misc/UseOverride.cpp:41
@@ +40,3 @@
+
+  // Re-lex the tokens to get precise locations to insert 'override' and remove
+  // 'virtual'.
----------------
Can you adapt FindToken from google/GoogleTidyModule.cpp to be usable here (and move it to a common place)? (Or maybe convert it to ParseTokens or something similar.)

================
Comment at: test/clang-tidy/use-override.cpp:1
@@ +1,2 @@
+// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-use-override %t
+// REQUIRES: shell
----------------
Please add tests with macros: when the whole class is defined in a macro and when a macro is used for "override" and for "virtual" (which is interesting, as the code removes "virtual").

http://reviews.llvm.org/D3688






More information about the cfe-commits mailing list