[PATCH] D16517: ClangTidy check to flag uninitialized builtin and pointer fields.

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 11 05:23:48 PST 2016


alexfh added inline comments.

================
Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:206
@@ +205,3 @@
+  // Do not propose fixes in macros since we cannot place them correctly.
+  if (Ctor->getLocStart().isMacroID())
+    return;
----------------
IIUC what this is doing, the offset should be `0` instead of `Field->getName().size()`. I've tried `Lexer::getLocForEndOfToken(Field->getSourceRange().getEnd(), 0, *Result.SourceManager, Result.Context->getLangOpts())` and it seems to work fine on your tests.

================
Comment at: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp:96
@@ +95,3 @@
+UNINITIALIZED_FIELD_IN_MACRO_BODY(F);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these built-in/pointer fields: F
+UNINITIALIZED_FIELD_IN_MACRO_BODY(G);
----------------
We also need to check that the macro definition stays the same. The lack of CHECK-FIXES doesn't ensure the fix wasn't applied (probably, it should, but that's another story).


http://reviews.llvm.org/D16517





More information about the cfe-commits mailing list