[clang] [NFC][clang] Cleanup in APValue and SemaInit (PR #127790)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 19 04:08:02 PST 2025


https://github.com/Fznamznon created https://github.com/llvm/llvm-project/pull/127790

APValue:
Additional assignment of AllowConstexprUnknown is not required since it will be handled by copy constructor called above.
SemaInit:
Remove unnecessary null check. DestRecordDecl can't be null due to being obtained using `cast` and assertion that DestRecordType is present.

Spotted by a static analysis tool.

>From 13a65cf8e93b6b7cfa9ab699137e2cd97af81cf5 Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" <mariya.podchishchaeva at intel.com>
Date: Wed, 19 Feb 2025 04:03:51 -0800
Subject: [PATCH] [NFC][clang] Cleanup in APValue and SemaInit

APValue:
Additional assignment of AllowConstexprUnknown is not required since it
will be handled by copy constructor called above.
SemaInit:
Remove unnecessary null check. DestRecordDecl can't be null due to being
obtained using `cast` and assertion that DestRecordType is present.

Spotted by a static analysis tool.
---
 clang/lib/AST/APValue.cpp   | 1 -
 clang/lib/Sema/SemaInit.cpp | 1 -
 2 files changed, 2 deletions(-)

diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp
index 3b814be266330..7c33d3a165a08 100644
--- a/clang/lib/AST/APValue.cpp
+++ b/clang/lib/AST/APValue.cpp
@@ -390,7 +390,6 @@ APValue &APValue::operator=(const APValue &RHS) {
   if (this != &RHS)
     *this = APValue(RHS);
 
-  AllowConstexprUnknown = RHS.AllowConstexprUnknown;
   return *this;
 }
 
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 6a76e6d74a4b0..aa16ceb737a41 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4577,7 +4577,6 @@ static void TryConstructorInitialization(Sema &S,
     if (!IsListInit &&
         (Kind.getKind() == InitializationKind::IK_Default ||
          Kind.getKind() == InitializationKind::IK_Direct) &&
-        DestRecordDecl != nullptr &&
         !(CtorDecl->isCopyOrMoveConstructor() && CtorDecl->isImplicit()) &&
         DestRecordDecl->isAggregate() &&
         DestRecordDecl->hasUninitializedExplicitInitFields()) {



More information about the cfe-commits mailing list