================
@@ -50,38 +50,52 @@ void FoldInitTypeCheck::registerMatchers(MatchFinder
*Finder) {
hasType(hasCanonicalType(IteratorWithValueType("Iter2ValueType"))));
const auto InitParam = parmVarDecl(hasType(BuiltinTypeWithId("InitType")));
+ // Transparent standard functors that preserve arithmetic conversion
semantics
+ const auto TransparentFunctor = expr(hasType(
+ hasCanonicalType(recordType(hasDeclaration(cxxRecordDecl(hasAnyName(
+ "::std::plus", "::std::minus", "::std::multiplies", "::std::divides",
----------------
zeyi2 wrote:
Here is my rationale of introducing a hard-coded list:
- People use custom lambdas for intentional and safe type conversions. So we
will see tricky cases like `[](int acc, float val) { return acc + (val > 0.5f ?
1 : 0); }`, IMO they would be hard to analyze in AST. (This is also an
limitation of the original implementation, so fully supporting them should be a
different PR.)
- If we ignore the problem and blindly match any callable, we would trigger *a
lot of* False Positives, which could possibly make users to disable this check
entirely. IMHO the current way is an acceptable trade-off, we limit the scope
of bug detection to catch common bugs without degrading the check's reliability.
https://github.com/llvm/llvm-project/pull/183300
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits