Skip to content

[Clang][AST][NFC] Add assertion on Init to CompoundLiteralExpr #152593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions clang/include/clang/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -3548,6 +3548,7 @@ class CompoundLiteralExpr : public Expr {
QualType T, ExprValueKind VK, Expr *init, bool fileScope)
: Expr(CompoundLiteralExprClass, T, VK, OK_Ordinary),
LParenLoc(lparenloc), TInfoAndScope(tinfo, fileScope), Init(init) {
assert(Init && "Init is a nullptr");
setDependence(computeDependence(this));
}

Expand Down Expand Up @@ -3577,19 +3578,11 @@ class CompoundLiteralExpr : public Expr {
APValue &getStaticValue() const;

SourceLocation getBeginLoc() const LLVM_READONLY {
// FIXME: Init should never be null.
if (!Init)
return SourceLocation();
if (LParenLoc.isInvalid())
return Init->getBeginLoc();
return LParenLoc;
}
SourceLocation getEndLoc() const LLVM_READONLY {
// FIXME: Init should never be null.
if (!Init)
return SourceLocation();
return Init->getEndLoc();
}
SourceLocation getEndLoc() const LLVM_READONLY { return Init->getEndLoc(); }

static bool classof(const Stmt *T) {
return T->getStmtClass() == CompoundLiteralExprClass;
Expand Down