[clang] Avoid invalidating specialization lookup (#196533)
Fixes a use-after-free in `ASTReader::LoadExternalSpecializationsImpl`
when loading external specializations with `-ftime-trace` enabled.
This resolves the https://github.com/llvm/llvm-project/issues/196482 and
builds upon the https://github.com/llvm/llvm-project/pull/172658
The function kept a pointer into `SpecLookups`:
```cpp
LookupTable = &It->getSecond();
```
Then it constructed a `TimeTraceScope` whose name callback calls
`getNameForDiagnostic`. That call may deserialize additional AST state
and mutate `SpecLookups`, invalidating the saved pointer before it is
later used for:
```cpp
LookupTable->Table.find(HashValue);
```
This is observed as an ASAN `heap-use-after-free` in:
```text
MultiOnDiskHashTable<LazySpecializationInfoLookupTrait>::find
ASTReader::LoadExternalSpecializationsImpl
```
The fix computes the template-argument hash and copies the lazy
specialization lookup result before constructing the time-trace scope.
This avoids retaining a `DenseMap` iterator or pointer into
`SpecLookups` across code that may trigger deserialization.
Validation from a local reproducer:
- Unpatched Clang + PCH + `-ftime-trace`: ASAN heap-use-after-free.
- Unpatched Clang + same PCH without `-ftime-trace`: passes.
- Patched Clang + PCH + `-ftime-trace`: full downstream wasm build
passes.
I cannot attach the original PCH-based reproducer publicly because the
PCH contains private project paths and serialized private headers, but
the reduced failing source no longer contains project logic and the ASAN
trace points directly at invalidation inside
`LoadExternalSpecializationsImpl`.