Skip to content
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

Fix segfault due to failing Expr classification #1145

Merged
merged 1 commit into from
Oct 22, 2024
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
8 changes: 6 additions & 2 deletions c2rust-ast-exporter/src/AstExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,12 @@ class TranslateASTVisitor final
#if CLANG_VERSION_MAJOR < 13
bool isRValue = ast->isRValue();
#else
assert(Context && "Expected Context to be non-NULL");
bool isRValue = ast->Classify(*Context).isRValue();
// prvalues are equivalent to rvalues in C++03.
//
// NOTE: We used to call ast->Classify(*Context).isRValue() but that may
// result in a segfault on LLVM 18 and 19 for certain string literals.
// See https://github.com/immunant/c2rust/issues/1124
bool isRValue = ast->getValueKind() == VK_PRValue;
#endif
encode_entry_raw(ast, tag, ast->getSourceRange(), ty, isRValue, isVaList,
encodeMacroExpansions, childIds, extra);
Expand Down
Loading