This is an archive of the discontinued LLVM Phabricator instance.

Disable -Wtautological-compare in template instantiations.
Needs ReviewPublic

Authored by rtrieu on Nov 19 2012, 9:42 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None

Diff Detail

Event Timeline

It would be nicer if we could build into the constant evaluator some
kind of result that indicated that the expression is dependent (if we
skipped over a SubstNonTypeTemplateParameter while evaluating the
expression (not sure if there's a way to detect the other, perhaps
more common cases of foo<T>::constant, though)) - this would give us
better fidelity (we could still warn on non-dependent cases) & that
machinery will be useful for other cases (like CFG construction)

Earlier this year I implemented part of this sort of thing, except for
'sizeof' rather than for templates, in an effort to improve
-Wunreachable-code - this change has not yet been committed (it came
with some CFG changes that Ted had feedback on & I haven't had a
chance to follow up on), but could be used as a rough guide.

Alternatively: could we possibly just not run this warning/analysis on
template specializations and only run it on template patterns? Then it
would be trivial: any expression that could be constant evaluated
wasn't dependent anyway. (this is what I proposed (& still propose)
doing for -Wunreachable-code in templates: simply always do it on the
template pattern & never on the template specialization)

It would be nicer if we could build into the constant evaluator some
kind of result that indicated that the expression is dependent (if we
skipped over a SubstNonTypeTemplateParameter while evaluating the
expression (not sure if there's a way to detect the other, perhaps
more common cases of foo<T>::constant, though)) - this would give us
better fidelity (we could still warn on non-dependent cases) & that
machinery will be useful for other cases (like CFG construction)

Earlier this year I implemented part of this sort of thing, except for
'sizeof' rather than for templates, in an effort to improve
-Wunreachable-code - this change has not yet been committed (it came
with some CFG changes that Ted had feedback on & I haven't had a
chance to follow up on), but could be used as a rough guide.

Alternatively: could we possibly just not run this warning/analysis on
template specializations and only run it on template patterns? Then it
would be trivial: any expression that could be constant evaluated
wasn't dependent anyway. (this is what I proposed (& still propose)
doing for -Wunreachable-code in templates: simply always do it on the
template pattern & never on the template specialization)