pfultz2 added a comment. > Can you elaborate a bit more about this?
This catches problems when calling `sizeof(f())` when `f` returns an integer(or enum). This is because, most likely, the integer represents the type to be chosen, however, `sizeof` is being computed for an integer and not the type the integer represents. That is, the user has an enum for the `data_type`: enum data_type { float_type, double_type }; At some point the user may call a function to get the data type(perhaps `x.GetType()`) and pass it on to `sizeof`, like `sizeof(x.GetType())`, which is incorrect. > I think we also need to update the check document (adding proper section of > this new behavior, and the new option). I will update the doc. ================ Comment at: clang-tidy/misc/SizeofExpressionCheck.cpp:220 + Result.Nodes.getNodeAs<Expr>("sizeof-integer-call")) { + diag(E->getLocStart(), "suspicious usage of 'sizeof(expr)' to an integer"); } else if (const auto *E = Result.Nodes.getNodeAs<Expr>("sizeof-this")) { ---------------- alexfh wrote: > I'm not sure I understand the message "suspicious usage of ... to an > integer". Specifically, what does the "to an integer" part mean? That could probably be worded better. It means the `expr` is an integer type. Maybe I should say `suspicious usage of 'sizeof() on an expression that results in an integer`? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D44231 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits