[all-commits] [llvm/llvm-project] d9d1ae: [Clang][Sema] fix crash of attribute transform (#7...

Qizhi Hu via All-commits all-commits at lists.llvm.org
Thu Jan 25 22:27:05 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d9d1ae6400a7f8a12068bdd37ecda62f07e52bce
      https://github.com/llvm/llvm-project/commit/d9d1ae6400a7f8a12068bdd37ecda62f07e52bce
  Author: Qizhi Hu <836744285 at qq.com>
  Date:   2024-01-26 (Fri, 26 Jan 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/AST/TypeLoc.h
    M clang/lib/Sema/TreeTransform.h
    A clang/test/Sema/attr-lifetimebound-no-crash.cpp

  Log Message:
  -----------
  [Clang][Sema] fix crash of attribute transform (#78088)

Try to fix [issue](https://github.com/llvm/llvm-project/issues/73619)

1. During transforming `FunctionProtoType`, if `ThisContext` is
`nullptr` and `CurrentContext` is `ClassTemplateSpecializationDecl`,
Constructor of `CXXThisScopeRAII` and `Sema::getCurrentThisType` won't
set `CXXThisTypeOverride` of Sema. This will lead to building `this` in
`RebuildCXXThisExpr` with a invalid type(NULL type) and cause crash.
2. During transforming attribute type, if `modifiedType` of attribute
type is changed, `EquivalentType` need to be transformed. If
`EquivalentType` is `FunctionProtoType`, its `ParamVarDecl` will not be
copyed(but parameter num does) and will not be instanced in
`TransformFunctionTypeParams` since `ParamVarDecl` is `nullptr`. This
will lead to crash in `findInstantiationOf`(can't find the instance of
`ParamVarDecl`).

This patch tries to fix these issues above.

1. If `CurrentContext` is `ClassTemplateSpecializationDecl`, Use it.
2. Use `EquivalentTypeLoc` instead of `EquivalentType` since it has
parameter info. But, if use current `TypeLocBuilder`, it will crash in
`TypeLocBuilder::push` since `LastType` is mismatch. Use an auxiliary
`TypeLocBuilder` instead and get transformed `EquivalentType`.

Co-authored-by: huqizhi <836744285 at qq.com>




More information about the All-commits mailing list