erichkeane wrote: I don't think there is codegen fixes to be done here. Self-assign like this is UB, and it would be an unnecessary amount of work to try to make this a 'no-op' instead. That said, as 'UB', self-assign's 'behavior' through LLVM-IR is effectively no effect, even if it is wasted instructions (that is, `mov eax, eax` won't change anything at all except perhaps invalidating speculation/etc).
IMO the clang behavior is completely making sense: we diagnose when this COULD be problematic (such as causing copy constructor from a not-yet-life-constructed self). I'm a bit concerned about: `The self-assignment initialization Type var = var; is an idiom in C code.` from the commit message. Is this true? Is this REALLY that common? To what end? IF we are convinced that is the case, I think it makes sense to at least add a configuration option of 'skip this pattern when it is meaningless instead of harmful' to the static analyzer.. https://github.com/llvm/llvm-project/pull/187530 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
