[clang] [Sema] Fix crash in TypeLoc::initializeFullCopy with mismatched types (PR #174583)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 17 10:20:47 PST 2026
https://github.com/AaronBallman commented:
Thank you for these changes, it took me a while to get to the PR for review (sorry about that)!
I think this fix may be too narrow; I think the issue is that we should not be asking for `TypeSourceInfo` for something the user didn't write in source in the first place. What seems to be happening here is that `GetFullTypeForDeclarator()` eventually determines that the declarator has an invalid type but it pretends the user wrote `int` for recovery purposes: https://github.com/llvm/llvm-project/blob/46ed6201cc3a39b66404bb04fb84f6cec658a9a7/clang/lib/Sema/SemaType.cpp#L1352 (as do many of the other invalid combinations). Then we later try to make a `TypeSourceInfo *` by calling `GetTypeSourceInfoForDeclarator()`: https://github.com/llvm/llvm-project/blob/46ed6201cc3a39b66404bb04fb84f6cec658a9a7/clang/lib/Sema/SemaType.cpp#L5723 I wonder if the correct fix is a few lines up from there -- look to see if the declarator has an invalid type and create a trivial type source info object.
CC @zygoloid @Sirraide @erichkeane for additional opinions here because that's also a potentially invasive change.
https://github.com/llvm/llvm-project/pull/174583
More information about the cfe-commits
mailing list