[clang] [clang][Sema]fix crash of invalid friend declaration with storage-cla… (PR #190597)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 7 05:59:47 PDT 2026


https://github.com/cor3ntin commented:

I think It's going to be easier to review / maintain if you put all the  code inside the ` if (TypeSpecType != TST_error) ` in a (global static) function instead.

Maybe 

```cpp

void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) {
  // Before possibly changing their values, save specs as written.
  SaveWrittenBuiltinSpecs();

  // Check the type specifier components first. No checking for an invalid
  // type.
 CheckTypeSpecType(TypeSpecType, S, Policy);
 

in `CheckTypeSpecType` you can keep the early return.

My hope is that by doing so, the code should flow the same and have much fewert line changes. And limiting function size is never a bad thing anyway.


Thanks!


 



Try to keep the formatting changes to a minimum, this is a lot of code to review

https://github.com/llvm/llvm-project/pull/190597


More information about the cfe-commits mailing list