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

Assertion failure when compiling openssh-portable source code #1204

Closed
arunkumarbhattar opened this issue May 14, 2023 · 0 comments
Closed

Comments

@arunkumarbhattar
Copy link
Member

Description:
I encountered an assertion failure while compiling openssh-portable. The crash is happening when the LLVM IR is being generated, specifically in StoreInst::AssertOK()
This indicates that a StoreInst (an instruction to store a value to memory) is being created with an invalid type. Specifically, the value being stored does not match the type of the value pointed to by the pointer operand.

The crash seems to happen when processing the int16_negative_mask declaration in sntrup761.c.

Backtrace
make (base)
Makefile:690: warning: ignoring prerequisites on suffix rule definition
(cd openbsd-compat && make)
make[1]: Entering directory '/home/arun/ptrsplitEval/typeflex-openssh-portable/openbsd-compat'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/arun/ptrsplitEval/typeflex-openssh-portable/openbsd-compat'
/home/arun/Desktop/macro/checkedc-llvm-project/llvm/cmake-build-debug/bin/clang -g -O2 -pipe -Wunknown-warning-option -Qunused-arguments -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-result -Wmisleading-indentation -fno-strict-aliasing -mretpoline -D_FORTIFY_SOURCE=2 -ftrapv -fno-builtin-memset -fstack-protector-strong -fPIE -I. -I. -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_GNU_SOURCE -DOPENSSL_API_COMPAT=0x10100000L -DSSHDIR="/usr/local/etc" -D_PATH_SSH_PROGRAM="/usr/local/bin/ssh" -D_PATH_SSH_ASKPASS_DEFAULT="/usr/local/libexec/ssh-askpass" -D_PATH_SFTP_SERVER="/usr/local/libexec/sftp-server" -D_PATH_SSH_KEY_SIGN="/usr/local/libexec/ssh-keysign" -D_PATH_SSH_PKCS11_HELPER="/usr/local/libexec/ssh-pkcs11-helper" -D_PATH_SSH_SK_HELPER="/usr/local/libexec/ssh-sk-helper" -D_PATH_SSH_PIDDIR="/var/run" -D_PATH_PRIVSEP_CHROOT_DIR="/var/empty" -DHAVE_CONFIG_H -c sntrup761.c -o sntrup761.o
clang: /home/arun/Desktop/macro/checkedc-llvm-project/llvm/lib/IR/Instructions.cpp:1437: void llvm::StoreInst::AssertOK(): Assertion `getOperand(0)->getType() == cast(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"' failed.
PLEASE submit a bug report to https://github.com/Microsoft/checkedc-clang/issues and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /home/arun/Desktop/macro/checkedc-llvm-project/llvm/cmake-build-debug/bin/clang -g -O2 -pipe -Wunknown-warning-option -Qunused-arguments -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-result -Wmisleading-indentation -fno-strict-aliasing -mretpoline -D_FORTIFY_SOURCE=2 -ftrapv -fno-builtin-memset -fstack-protector-strong -fPIE -I. -I. -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_GNU_SOURCE -DOPENSSL_API_COMPAT=0x10100000L -DSSHDIR="/usr/local/etc" -D_PATH_SSH_PROGRAM="/usr/local/bin/ssh" -D_PATH_SSH_ASKPASS_DEFAULT="/usr/local/libexec/ssh-askpass" -D_PATH_SFTP_SERVER="/usr/local/libexec/sftp-server" -D_PATH_SSH_KEY_SIGN="/usr/local/libexec/ssh-keysign" -D_PATH_SSH_PKCS11_HELPER="/usr/local/libexec/ssh-pkcs11-helper" -D_PATH_SSH_SK_HELPER="/usr/local/libexec/ssh-sk-helper" -D_PATH_SSH_PIDDIR="/var/run" -D_PATH_PRIVSEP_CHROOT_DIR="/var/empty" -DHAVE_CONFIG_H -c sntrup761.c -o sntrup761.o

  1. parser at end of file
  2. Per-file LLVM IR generation
  3. sntrup761.c:412:12: Generating code for declaration 'int16_negative_mask'
    #0 0x000055b38c15a768 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/arun/Desktop/macro/checkedc-llvm-project/llvm/lib/Support/Unix/Signals.inc:565:22
    Merge-back to respective upstreams? #1 0x000055b38c15a82f PrintStackTraceSignalHandler(void*) /home/arun/Desktop/macro/checkedc-llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
    Update setup and build instructions. #2 0x000055b38c1583f1 llvm::sys::RunSignalHandlers() /home/arun/Desktop/macro/checkedc-llvm-project/llvm/lib/Support/Signals.cpp:71:20
    test serialization/deserialization of clang IR with new checked types and new bounds expressions #3 0x000055b38c159f61 llvm::sys::CleanupOnSignal(unsigned long) /home/arun/Desktop/macro/checkedc-llvm-project/llvm/lib/Support/Unix/Signals.inc:361:31
    test AST printing of clang IR with new checked C types and bounds expressions #4 0x000055b38c08871f (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /home/arun/Desktop/macro/checkedc-llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:75:5
    test traversal of ASTs with new checked types and bounds expressions #5 0x000055b38c088c6e CrashRecoverySignalHandler(int) /home/arun/Desktop/macro/checkedc-llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:389:1
    test tree transformations of ASTs with new checked types and bounds expressions #6 0x00007fa08cc42520 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x42520)
    process bounds expressions for parameters with all the parameters available #7 0x00007fa08cc96a7c __pthread_kill_implementation ./nptl/./nptl/pthread_kill.c:44:76
    Extend clang IR with bounds expressions and parse bounds expressions for parameters. #8 0x00007fa08cc96a7c __pthread_kill_internal ./nptl/./nptl/pthread_kill.c:78:10
    Only allow Checked C extension flag for C in clang #9 0x00007fa08cc96a7c pthread_kill ./nptl/./nptl/pthread_kill.c:89:10
    Plan out testing clang internal features with new Checked C features #10 0x00007fa08cc42476 raise ./signal/../sysdeps/posix/raise.c:27:6
    Extend IR with bounds expressions #11 0x00007fa08cc287f3 abort ./stdlib/./stdlib/abort.c:81:7
    Parse bounds declarations for function parameters #12 0x00007fa08cc2871b _nl_load_domain ./intl/./intl/loadmsgcat.c:1177:9
    Parse bounds declarations for variable declarations #13 0x00007fa08cc39e96 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
    Type check non-count bounds expressions #14 0x000055b38b580d80 llvm::StoreInst::AssertOK() /home/arun/Desktop/macro/checkedc-llvm-project/llvm/lib/IR/Instructions.cpp:1440:3
    Parse bounds declarations for function return values #15 0x000055b38b5810d0 llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*, bool, llvm::Align, llvm::AtomicOrdering, unsigned char, llvm::Instruction*) /home/arun/Desktop/macro/checkedc-llvm-project/llvm/lib/IR/Instructions.cpp:1484:1
    Only allow the Checked C extension flag for C. #16 0x000055b38b580f6d llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*, bool, llvm::Align, llvm::Instruction*) /home/arun/Desktop/macro/checkedc-llvm-project/llvm/lib/IR/Instructions.cpp:1465:48
    Parse bounds expressions in function parameter list scopes. #17 0x000055b3897484bc llvm::IRBuilderBase::CreateAlignedStore(llvm::Value*, llvm::Value*, llvm::MaybeAlign, bool) /home/arun/Desktop/macro/checkedc-llvm-project/llvm/include/llvm/IR/IRBuilder.h:1834:18
    Parse bounds declarations for variable declarations. #18 0x000055b38c5e9935 clang::CodeGen::CGBuilderTy::CreateStore(llvm::Value*, clang::CodeGen::Address, bool) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CGBuilder.h:106:3
    Parse bounds declarations for struct members #19 0x000055b38ca8a61d clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*, clang::CodeGen::Address, bool, clang::QualType, clang::CodeGen::LValueBaseInfo, clang::CodeGen::TBAAAccessInfo, bool, bool) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CGExpr.cpp:1865:47
    Represent bounds information in function types #20 0x000055b38ca8a884 clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*, clang::CodeGen::LValue, bool) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CGExpr.cpp:1883:20
    Parse bounds declarations for function return values. #21 0x000055b38ca8c2b3 clang::CodeGen::CodeGenFunction::EmitStoreThroughLValue(clang::CodeGen::RValue, clang::CodeGen::LValue, bool) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CGExpr.cpp:2170:20
    Fix crash during typo correction in C mode. #22 0x000055b38ca549b3 clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CGDecl.cpp:763:27
    Parsing of member bounds declarations. #23 0x000055b38ca5a8b8 clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CGDecl.cpp:1927:19
    Allow member bounds to use enumeration constants #24 0x000055b38ca5a544 clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission const&) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CGDecl.cpp:1888:26
    Update status and add code of conduct. #25 0x000055b38ca574cf clang::CodeGen::CodeGenFunction::EmitAutoVarDecl(clang::VarDecl const&) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CGDecl.cpp:1310:22
    Type check count bounds expressions #26 0x000055b38ca51e69 clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CGDecl.cpp:208:27
    Remove declaring unchecked arrays using the 'unchecked' keyword #27 0x000055b38ca51b1d clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (.localalias) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CGDecl.cpp:154:47
    Check bounds declarations for pointers to constant-sized data for a subset of expressions #28 0x000055b38c6008a2 clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CGStmt.cpp:1249:3
    Parse and represent 'ptr' interop annotation for unchecked pointer types #29 0x000055b38c5fc48c clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CGStmt.cpp:387:5
    Handle redeclarations of functions and variables with bounds #30 0x000055b38c5fb6a0 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CGStmt.cpp:55:3
    Implement implicit conversions for ptr interop annotations #31 0x000055b38c5fc9d1 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CGStmt.cpp:441:3
    Dimensions of multi-dimensional arrays must have consistent checked properties #32 0x000055b38c6ad6e8 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1189:33
    Initial version of the checked-c conversion tool. Current features: #33 0x000055b38c6ae397 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1359:21
    Rewrite tool #34 0x000055b38c6dc379 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:4769:3
    Create documentation for the rewriter tool #35 0x000055b38c6d4d31 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3118:47
    Typecheck count bounds expressions. #36 0x000055b38c6d0f37 clang::CodeGen::CodeGenModule::EmitDeferred() (.localalias) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2351:31
    Add support for relative bounds expressions #37 0x000055b38c6d0f8e clang::CodeGen::CodeGenModule::EmitDeferred() (.localalias) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2353:7
    Check that subexpressions of bounds expressions are non-modifying expressions. #38 0x000055b38c6d0f8e clang::CodeGen::CodeGenModule::EmitDeferred() (.localalias) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2353:7
    Implement storage class restrictions on bounds declarations #39 0x000055b38c6d0f8e clang::CodeGen::CodeGenModule::EmitDeferred() (.localalias) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2353:7
    Implement restrictions on variables at external scope #40 0x000055b38c6d0f8e clang::CodeGen::CodeGenModule::EmitDeferred() (.localalias) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2353:7
    Checked additonal type requirements on expressions with count bounds expressions #41 0x000055b38c6c6fdb clang::CodeGen::CodeGenModule::Release() /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:450:31
    Check type requirements for bounds declarations. #42 0x000055b38d88e651 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:271:11
    Initial support for linking constraints #43 0x000055b38d886d1d clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:294:13
    Bug fixes and modest extensions #44 0x000055b38f3c2975 clang::ParseAST(clang::Sema&, bool, bool) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/Parse/ParseAST.cpp:178:14
    Type check bounds expression arguments #45 0x000055b38ce88c63 clang::ASTFrontendAction::ExecuteAction() /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/Frontend/FrontendAction.cpp:1056:11
    No more test baselines #46 0x000055b38d883b22 clang::CodeGenAction::ExecuteAction() /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1083:5
    Statistics printing and typedef changes #47 0x000055b38ce88512 clang::FrontendAction::Execute() /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/Frontend/FrontendAction.cpp:953:38
    Replace logic in NewTyp::mkTypForConstrainedType with a recursive AST visitor #48 0x000055b38cddcc9c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/Frontend/CompilerInstance.cpp:949:42
    Re-visit re-writing variable declarations with a typedefed type #49 0x000055b38d0291de clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:38
    Revamp kinds for bounds expressions #50 0x000055b388f82b1a cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/arun/Desktop/macro/checkedc-llvm-project/clang/tools/driver/cc1_main.cpp:240:40
    Update setup and build instructions. #51 0x000055b388f76997 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /home/arun/Desktop/macro/checkedc-llvm-project/clang/tools/driver/driver.cpp:330:20
    Revamp kinds for bounds expressions. #52 0x000055b38ccc3901 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optionalllvm::StringRef >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const::'lambda'()::operator()() const /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/Driver/Job.cpp:404:32
    prefix new keywords with underscore #53 0x000055b38ccc41a7 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optionalllvm::StringRef >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const::'lambda'()>(long) /home/arun/Desktop/macro/checkedc-llvm-project/llvm/include/llvm/ADT/STLExtras.h:186:40
    Change Checked C keywords to avoid conflicts with existing identifiers. #54 0x000055b38c07b988 llvm::function_ref<void ()>::operator()() const /home/arun/Desktop/macro/checkedc-llvm-project/llvm/include/llvm/ADT/STLExtras.h:209:62
    Parse and represent bounds-safe interface type annotations #55 0x000055b38c088e8b llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /home/arun/Desktop/macro/checkedc-llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:425:10
    Constraint system is higher order now #56 0x000055b38ccc3b0e clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optionalllvm::StringRef >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/Driver/Job.cpp:404:7
    Constraint generation is higher order now. #57 0x000055b38cc74391 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/Driver/Compilation.cpp:195:22
    Finishing the migration to the new Variable data type. #58 0x000055b38cc7470c clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/Driver/Compilation.cpp:248:53
    Take the LUB of constraints when multiple constraints exist and they might differ #59 0x000055b38cc84745 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) /home/arun/Desktop/macro/checkedc-llvm-project/clang/lib/Driver/Driver.cpp:1517:28
    Small changes for evaluation #60 0x000055b388f779f7 main /home/arun/Desktop/macro/checkedc-llvm-project/clang/tools/driver/driver.cpp:502:39
    Handle types related to variable arguments better in the Checked C rewriter #61 0x00007fa08cc29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    Implement implicit type conversions for bounds-safe interfaces #62 0x00007fa08cc29e40 call_init ./csu/../csu/libc-start.c:128:20
    Rename keyword in bounds-safe interface type annotation. #63 0x00007fa08cc29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
    Validate type in bounds-safe interface type annotation #64 0x000055b388f74fb5 _start (/home/arun/Desktop/macro/checkedc-llvm-project/llvm/cmake-build-debug/bin/clang+0x148dfb5)
    clang-12: error: clang frontend command failed with exit code 134 (use -v to see invocation)
    clang version 12.0.0 (https://github.com/checkedc-purdue/checkedc-llvm-project.git aa9b74b2169eb250ccccb8d1f65a6082377b795a)
    Target: x86_64-unknown-linux-gnu
    Thread model: posix
    InstalledDir: /home/arun/Desktop/macro/checkedc-llvm-project/llvm/cmake-build-debug/bin
    clang-12: note: diagnostic msg:

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-12: note: diagnostic msg: /tmp/sntrup761-7ed827.c
clang-12: note: diagnostic msg: /tmp/sntrup761-7ed827.sh
clang-12: note: diagnostic msg:


make: *** [Makefile:195: sntrup761.o] Error 134
crash.tar.gz

dtarditi added a commit that referenced this issue Dec 20, 2023
…1228)

This fixes issue #1204, when an assertion in generating LLVM IR occurred when compiling open-ssh-portable source code. The assertion occurred because of an unintended modification to an ImplicitCastExpr by the TreeTransform class. This occurs when we use TreeTransform to do an expression substitution, where we substitute some expression E1 for E2. This is done as part of tracking equivalent expressions during check of bounds declarations. If E1 was an ImplicitCastExpr, it was accidentally modified.

The root cause was that TreeTransform calls semantic actions, which eventually call Sema::ImpCastExprToType. This function creates an implicit cast using some expression E as the child of the cast. However, if E is already an implicit cast, it merges the two implicit casts expressions, side-effecting E. The fix is to generate a new combined implicit cast instruction, instead of side-effecting E. That way TreeTransform is non-side-effecting when existing expressions are introduced as part of the AST tree transform. This can cause the existing ImplicitCastExpr E to be unused, but that is not a problem, because we drop pointers to expressions all over the place.

For other uses of TreeTransform in clang, the existing behavior has been fine because TreeTransform disregards implicit cast expressions. It assumed that the semantic actions generated new implicit casts where necessary, so side-effecting one was OK
@dtarditi dtarditi closed this as completed Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants