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

Daniel Jasper djasper at google.com
Thu May 15 02:11:01 PDT 2014


================
Comment at: clang-tidy/misc/UseOverride.cpp:32
@@ +31,3 @@
+  if (Method->getInstantiatedFromMemberFunction() != nullptr)
+    Method = Method->getInstantiatedFromMemberFunction();
+
----------------
Alexander Kornienko wrote:
> Does it make sense to check for getLocation().isMacroID() after this?
Changed order of the first two checks.

================
Comment at: clang-tidy/misc/UseOverride.cpp:41
@@ +40,3 @@
+
+  // Re-lex the tokens to get precise locations to insert 'override' and remove
+  // 'virtual'.
----------------
Alexander Kornienko wrote:
> 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.)
Only partially as I need to lex all the tokens of the function definition (to scan backwards for "= 0"). I guess we could pull out abstraction here, but I am not exactly sure what that should be.

================
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
----------------
Alexander Kornienko wrote:
> 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").
Done.

http://reviews.llvm.org/D3688






More information about the cfe-commits mailing list