[clang] Fix bug (PR #104811)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 19 09:22:46 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (smanna12)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/104811.diff
1 Files Affected:
- (modified) clang/lib/Sema/SemaDecl.cpp (+5)
``````````diff
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 503e93f925713..a3cc211a67c72 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -13518,6 +13518,11 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
}
Init = Result.getAs<Expr>();
+
+ // Assert that Init is non-null only if no errors have occurred.
+ assert((!Result.isInvalid() && Init) &&
+ "Should have a valid initializer at this point");
+
IsParenListInit = !InitSeq.steps().empty() &&
InitSeq.step_begin()->Kind ==
InitializationSequence::SK_ParenthesizedListInit;
``````````
</details>
https://github.com/llvm/llvm-project/pull/104811
More information about the cfe-commits
mailing list