[clang] 95862d0 - [clang] Fix manual memory management with SmallVector in ConceptRef (#147231)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 7 05:09:07 PDT 2025
Author: Bogdan Vetrenko
Date: 2025-07-07T14:09:04+02:00
New Revision: 95862d0897352de4bc7f4815def819639533bfc7
URL: https://github.com/llvm/llvm-project/commit/95862d0897352de4bc7f4815def819639533bfc7
DIFF: https://github.com/llvm/llvm-project/commit/95862d0897352de4bc7f4815def819639533bfc7.diff
LOG: [clang] Fix manual memory management with SmallVector in ConceptRef (#147231)
This change replaces manual `new[]`/`delete[]` with `llvm::SmallVector`
for `TemplateArgumentLocInfo` in `createTrivialConceptReference`.
Added:
Modified:
clang/lib/AST/TypeLoc.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/TypeLoc.cpp b/clang/lib/AST/TypeLoc.cpp
index 1bdb86ad445a4..5c45c596538f8 100644
--- a/clang/lib/AST/TypeLoc.cpp
+++ b/clang/lib/AST/TypeLoc.cpp
@@ -22,6 +22,7 @@
#include "clang/AST/TypeLocVisitor.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
@@ -652,9 +653,9 @@ static ConceptReference *createTrivialConceptReference(ASTContext &Context,
DeclarationNameInfo(AT->getTypeConstraintConcept()->getDeclName(), Loc,
AT->getTypeConstraintConcept()->getDeclName());
unsigned size = AT->getTypeConstraintArguments().size();
- TemplateArgumentLocInfo *TALI = new TemplateArgumentLocInfo[size];
+ llvm::SmallVector<TemplateArgumentLocInfo, 8> TALI(size);
TemplateSpecializationTypeLoc::initializeArgLocs(
- Context, AT->getTypeConstraintArguments(), TALI, Loc);
+ Context, AT->getTypeConstraintArguments(), TALI.data(), Loc);
TemplateArgumentListInfo TAListI;
for (unsigned i = 0; i < size; ++i) {
TAListI.addArgument(
@@ -666,7 +667,6 @@ static ConceptReference *createTrivialConceptReference(ASTContext &Context,
Context, NestedNameSpecifierLoc{}, Loc, DNI, nullptr,
AT->getTypeConstraintConcept(),
ASTTemplateArgumentListInfo::Create(Context, TAListI));
- delete[] TALI;
return ConceptRef;
}
More information about the cfe-commits
mailing list