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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Mariya Podchishchaeva (Fznamznon)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/127790.diff


2 Files Affected:

- (modified) clang/lib/AST/APValue.cpp (-1) 
- (modified) clang/lib/Sema/SemaInit.cpp (-1) 


``````````diff
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()) {

``````````

</details>


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


More information about the cfe-commits mailing list