[all-commits] [llvm/llvm-project] 282cae: [Sema] Fix crash on __fp16 parameters in template ...

Ilya Biryukov via All-commits all-commits at lists.llvm.org
Tue Mar 21 06:09:39 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 282cae0b9a602267ad7ef622f770066491332a11
      https://github.com/llvm/llvm-project/commit/282cae0b9a602267ad7ef622f770066491332a11
  Author: Ilya Biryukov <ibiryukov at google.com>
  Date:   2023-03-21 (Tue, 21 Mar 2023)

  Changed paths:
    M clang/lib/Sema/SemaChecking.cpp
    M clang/lib/Sema/SemaDeclCXX.cpp
    M clang/lib/Sema/SemaLambda.cpp
    M clang/lib/Sema/SemaTemplateInstantiate.cpp
    A clang/test/SemaCXX/GH61441.cpp

  Log Message:
  -----------
  [Sema] Fix crash on __fp16 parameters in template instantiations

Fixes #61441.

Currently, Clang stores `nullptr` in the parameter lists inside
`FunctionProtoTypeLoc` if `__fp16` is used without pointer qualifiers.

Any code path that calls `Declarator::setInvalidType()` before
`GetFullTypeForDeclarator` will lead to the same problem downstream.

The relevant code is:
```cpp
if (D.isInvalidType())
  return Context.getTrivialTypeSourceInfo(T);

return GetTypeSourceInfoForDeclarator(state, T, TInfo);
```

`GetTypeSourceInfoForDeclarator` sets the parameter `Decl`, but we can't
call it when `isInvalidType() == true` as this causes other assertion
failures that seem harder to fix.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D146426




More information about the All-commits mailing list