OSDN Git Service

[IR/Analysis] Defend against getting slightly wrong template arguments
authorChandler Carruth <chandlerc@gmail.com>
Tue, 7 Feb 2017 03:17:30 +0000 (03:17 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 7 Feb 2017 03:17:30 +0000 (03:17 +0000)
commite4145c2707e05419885195355d00a56f1013a0cb
tree4f48a5d1662efde708dceb6a2027ff60cceb9516
parent167cdd001ac7b5c7481fcd40912de7cf9b4fef1e
[IR/Analysis] Defend against getting slightly wrong template arguments
passed into CRTP base classes.

This can sometimes happen and not cause an immediate failure when the
derived class is, itself, a template. You can end up essentially calling
methods on the wrong derived type but a type where many things will
appear to "work".

To fail fast and with a clear error message we can use a static_assert,
but we have to stash that static_assert inside a method body or nested
type that won't need to be completed while building the base class. I've
tried to pick a reasonably small number of places that seemed like
reliably places for this to be instantiated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294272 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/PtrUseVisitor.h
include/llvm/IR/InstVisitor.h