New issue 1140 by mous16: Assertion failed: Val && "isa<> used on a null pointer" on dependant template alias
https://github.com/include-what-you-use/include-what-you-use/issues/1140
include-what-you-use crashes when analyzing the following minum example.
```C++
template<int value, typename Type>
struct ClassValueType
{ };
template<int value>
struct ClassValue
{
template<typename Type>
using ClassType= ClassValueType<value, Type>;
};
template<template<typename> typename TemplateClassType>
struct FinalType
{
static void run() { TemplateClassType<int> instance{}; }
};
template<int value>
void test()
{
using Type= FinalType<ClassValue<value>::template ClassType>;
Type::run();
}
int main()
{
test<0>();
}
```
I've tried it on Windows, with a custom build of LLVM 15.0.5 and IWYU 0.19.
The analysis terminates with the following error:
```
test.cpp:22:55: (8, fwd decl) [ TemplateName ] ClassValue<value>::template ClassType
Assertion failed: Val && "isa<> used on a null pointer", file C:\Users\a00550533\AppData\Local\llvm\include\llvm/Support/Casting.h, line 109
```
[Here](
https://github.com/include-what-you-use/include-what-you-use/files/10041558/iwyu_out.txt) you can find full IWYU output in verbose mode.
I cannot build IWYU nor LLVM in debug mode right now, but after some investigation I realized the assertion is emitted when reaching `iwyu.cc:1532`:
```C++
if (const auto* shadow_decl = dyn_cast<UsingShadowDecl>(used_decl)) {
```
I unfortunately have a really low understanding of LLVM APIs, but I found out that substituting `dyn_cast` with `dyn_cast_or_null` let IWYU avoid the assertion, and continue to the end of the analysis.
I'm really not able to say if this is a valid fix.