Skip to content

Commit f1e455e

Browse files
authored
[NFC][Sema][OpenMP] Fix free-nonheap-object warning (#112942)
This is one of the many PRs to fix errors with LLVM_ENABLE_WERROR=on. Built by GCC 11. Fix warning In destructor ‘llvm::APInt::~APInt()’, inlined from ‘llvm::APInt::~APInt()’ at llvm-project/llvm/include/llvm/ADT/APInt.h:190:3, inlined from ‘llvm::APSInt::~APSInt()’ at llvm-project/llvm/include/llvm/ADT/APSInt.h:23:21, inlined from ‘bool checkOMPArraySectionConstantForReduction(clang::ASTContext&, const clang::ArraySectionExpr*, bool&, llvm::SmallVectorImpl<llvm::APSInt>&)’ at llvm-project/clang/lib/Sema/SemaOpenMP.cpp:18357:45, inlined from ‘bool actOnOMPReductionKindClause(clang::Sema&, {anonymous}::DSAStackTy*, clang::OpenMPClauseKind, llvm::ArrayRef<clang::Expr*>, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation, clang::CXXScopeSpec&, const clang::DeclarationNameInfo&, llvm::ArrayRef<clang::Expr*>, {anonymous}::ReductionData&)’ at llvm-project/clang/lib/Sema/SemaOpenMP.cpp:18715:68: llvm-project/llvm/include/llvm/ADT/APInt.h:192:18: error: ‘void operator delete [](void*)’ called on a pointer to an unallocated object ‘1’ [-Werror=free-nonheap-object] 192 | delete[] U.pVal; | ^~~~
1 parent fc59f2c commit f1e455e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18335,7 +18335,8 @@ static bool checkOMPArraySectionConstantForReduction(
1833518335
return false;
1833618336

1833718337
// This is an array subscript which has implicit length 1!
18338-
ArraySizes.push_back(llvm::APSInt::get(1));
18338+
llvm::APSInt ConstantOne = llvm::APSInt::get(1);
18339+
ArraySizes.push_back(ConstantOne);
1833918340
} else {
1834018341
Expr::EvalResult Result;
1834118342
if (!Length->EvaluateAsInt(Result, Context))
@@ -18354,7 +18355,8 @@ static bool checkOMPArraySectionConstantForReduction(
1835418355
if (!SingleElement) {
1835518356
while (const auto *TempASE = dyn_cast<ArraySubscriptExpr>(Base)) {
1835618357
// Has implicit length 1!
18357-
ArraySizes.push_back(llvm::APSInt::get(1));
18358+
llvm::APSInt ConstantOne = llvm::APSInt::get(1);
18359+
ArraySizes.push_back(ConstantOne);
1835818360
Base = TempASE->getBase()->IgnoreParenImpCasts();
1835918361
}
1836018362
}

0 commit comments

Comments
 (0)