Skip to content

Conversation

@Fznamznon
Copy link
Contributor

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.

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.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Feb 19, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 19, 2025

@llvm/pr-subscribers-clang

Author: Mariya Podchishchaeva (Fznamznon)

Changes

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

@Fznamznon
Copy link
Contributor Author

Thanks @Sirraide

@Fznamznon Fznamznon merged commit 0cd5a1f into llvm:main Feb 20, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants