@@ -723,6 +723,21 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
723723 return builder->CreateCall (fn, {str, idx1});
724724 }
725725
726+ llvm::Value* lfortran_str_contains (llvm::Value* str, llvm::Value* substr)
727+ {
728+ std::string runtime_func_name = " _lfortran_str_contains" ;
729+ llvm::Function *fn = module ->getFunction (runtime_func_name);
730+ if (!fn) {
731+ llvm::FunctionType *function_type = llvm::FunctionType::get (
732+ llvm::Type::getInt1Ty (context), {
733+ character_type, character_type
734+ }, false );
735+ fn = llvm::Function::Create (function_type,
736+ llvm::Function::ExternalLinkage, runtime_func_name, *module );
737+ }
738+ return builder->CreateCall (fn, {str, substr});
739+ }
740+
726741 llvm::Value* lfortran_str_copy (llvm::Value* str, llvm::Value* idx1, llvm::Value* idx2)
727742 {
728743 std::string runtime_func_name = " _lfortran_str_copy" ;
@@ -6416,6 +6431,22 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
64166431 }
64176432 }
64186433
6434+ void visit_StringContains (const ASR::StringContains_t& x) {
6435+ if (x.m_value ) {
6436+ this ->visit_expr_wrapper (x.m_value , true );
6437+ return ;
6438+ }
6439+
6440+ this ->visit_expr_wrapper (x.m_left , true );
6441+ llvm::Value *substr = tmp;
6442+
6443+ this ->visit_expr_wrapper (x.m_right , true );
6444+ llvm::Value *right = tmp;
6445+
6446+ tmp = lfortran_str_contains (right, substr);
6447+ strings_to_be_deallocated.push_back (al, tmp);
6448+ }
6449+
64196450 void visit_StringSection (const ASR::StringSection_t& x) {
64206451 if (x.m_value ) {
64216452 this ->visit_expr_wrapper (x.m_value , true );
0 commit comments