It seems we need a different matcher for binary operator
in a template context.
Fixes this issue:
https://bugs.llvm.org/show_bug.cgi?id=44499
Differential D76990
[clang-tidy]: fix false positive of cert-oop54-cpp check. ztamas on Mar 28 2020, 8:12 AM. Authored by
Details It seems we need a different matcher for binary operator Fixes this issue:
Diff Detail
Event TimelineComment Actions I'm not entirely sure this is where the fix needs to be for this. The test case code is whacky as hell, but from what I can see clang should always emit a BinaryOperator for dependent type operators. No idea why it is spewing out a CXXOperatorCallExpr instead. Would need someone with more knowledge on Sema to confirm(or deny) this though.
Comment Actions I agree, it seems suspicious that a BinaryOperator matcher does not work in this case. However, I'm working on this level of the code, I'm looking at the matchers like an API, what I'm just using in the clang-tidy code, without changing them. So that's why I added this workaround. I don't know how much time it would take to fix this issue in the matcher code or whether it will be fixed in the near future or not, but until then I think it useful to have this workaround in the caller code, so this clang-tidy check works better. I added a TODO comment, so it's more visible that we have an issue here, so it's more probable somebody will fix that working with the matchers. Comment Actions It's not the matchers fault, that's working as intended. its the AST that clang has generated for that source code that looks suspicious. Comment Actions LGTM with a testing request. I agree that the Clang AST is a bit surprising, but not so surprising that I could definitely call it a bug.
|
Thank you for this! Can you also add a test case where the diagnostic should trigger? e.g.,