[all-commits] [llvm/llvm-project] 473795: [AST] Use APIntStorage to fix memory leak in EnumC...

Craig Topper via All-commits all-commits at lists.llvm.org
Tue Jan 16 12:10:49 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4737959d91fab7673b1bb642f88658bb2a24d723
      https://github.com/llvm/llvm-project/commit/4737959d91fab7673b1bb642f88658bb2a24d723
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2024-01-16 (Tue, 16 Jan 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    A clang/include/clang/AST/APNumericStorage.h
    M clang/include/clang/AST/Decl.h
    M clang/include/clang/AST/Expr.h
    M clang/lib/AST/Decl.cpp
    M clang/lib/CodeGen/CGBuiltin.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Serialization/ASTReaderDecl.cpp

  Log Message:
  -----------
  [AST] Use APIntStorage to fix memory leak in EnumConstantDecl. (#78311)

EnumConstantDecl is allocated by the ASTContext allocator so the
destructor is never called.

This patch takes a similar approach to IntegerLiteral by using
APIntStorage to allocate large APSInts using the ASTContext allocator as
well.

The downside is that an additional heap allocation and copy of the data
needs to be made when calling getInitValue if the APSInt is large.

Fixes #78160.




More information about the All-commits mailing list