1351290Sdim//===-- ClangExpressionSourceCode.cpp ---------------------------*- C++ -*-===// 2351290Sdim// 3351290Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4351290Sdim// See https://llvm.org/LICENSE.txt for license information. 5351290Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6351290Sdim// 7351290Sdim//===----------------------------------------------------------------------===// 8351290Sdim 9351290Sdim#include "ClangExpressionSourceCode.h" 10351290Sdim 11351290Sdim#include "clang/Basic/CharInfo.h" 12351290Sdim#include "clang/Basic/SourceManager.h" 13351290Sdim#include "clang/Lex/Lexer.h" 14351290Sdim#include "llvm/ADT/StringRef.h" 15351290Sdim 16351290Sdim#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h" 17351290Sdim#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" 18351290Sdim#include "lldb/Symbol/Block.h" 19351290Sdim#include "lldb/Symbol/CompileUnit.h" 20351290Sdim#include "lldb/Symbol/DebugMacros.h" 21351290Sdim#include "lldb/Symbol/TypeSystem.h" 22351290Sdim#include "lldb/Symbol/VariableList.h" 23351290Sdim#include "lldb/Target/ExecutionContext.h" 24351290Sdim#include "lldb/Target/Language.h" 25351290Sdim#include "lldb/Target/Platform.h" 26351290Sdim#include "lldb/Target/StackFrame.h" 27351290Sdim#include "lldb/Target/Target.h" 28351290Sdim#include "lldb/Utility/StreamString.h" 29351290Sdim 30351290Sdimusing namespace lldb_private; 31351290Sdim 32360784Sdim#define PREFIX_NAME "<lldb wrapper prefix>" 33360784Sdim 34360784Sdimconst llvm::StringRef ClangExpressionSourceCode::g_prefix_file_name = PREFIX_NAME; 35360784Sdim 36360784Sdimconst char *ClangExpressionSourceCode::g_expression_prefix = 37360784Sdim"#line 1 \"" PREFIX_NAME R"(" 38360784Sdim#ifndef offsetof 39360784Sdim#define offsetof(t, d) __builtin_offsetof(t, d) 40360784Sdim#endif 41351290Sdim#ifndef NULL 42351290Sdim#define NULL (__null) 43351290Sdim#endif 44351290Sdim#ifndef Nil 45351290Sdim#define Nil (__null) 46351290Sdim#endif 47351290Sdim#ifndef nil 48351290Sdim#define nil (__null) 49351290Sdim#endif 50351290Sdim#ifndef YES 51351290Sdim#define YES ((BOOL)1) 52351290Sdim#endif 53351290Sdim#ifndef NO 54351290Sdim#define NO ((BOOL)0) 55351290Sdim#endif 56351290Sdimtypedef __INT8_TYPE__ int8_t; 57351290Sdimtypedef __UINT8_TYPE__ uint8_t; 58351290Sdimtypedef __INT16_TYPE__ int16_t; 59351290Sdimtypedef __UINT16_TYPE__ uint16_t; 60351290Sdimtypedef __INT32_TYPE__ int32_t; 61351290Sdimtypedef __UINT32_TYPE__ uint32_t; 62351290Sdimtypedef __INT64_TYPE__ int64_t; 63351290Sdimtypedef __UINT64_TYPE__ uint64_t; 64351290Sdimtypedef __INTPTR_TYPE__ intptr_t; 65351290Sdimtypedef __UINTPTR_TYPE__ uintptr_t; 66351290Sdimtypedef __SIZE_TYPE__ size_t; 67351290Sdimtypedef __PTRDIFF_TYPE__ ptrdiff_t; 68351290Sdimtypedef unsigned short unichar; 69351290Sdimextern "C" 70351290Sdim{ 71351290Sdim int printf(const char * __restrict, ...); 72351290Sdim} 73351290Sdim)"; 74351290Sdim 75351290Sdimnamespace { 76351290Sdim 77351290Sdimclass AddMacroState { 78351290Sdim enum State { 79351290Sdim CURRENT_FILE_NOT_YET_PUSHED, 80351290Sdim CURRENT_FILE_PUSHED, 81351290Sdim CURRENT_FILE_POPPED 82351290Sdim }; 83351290Sdim 84351290Sdimpublic: 85351290Sdim AddMacroState(const FileSpec ¤t_file, const uint32_t current_file_line) 86351290Sdim : m_state(CURRENT_FILE_NOT_YET_PUSHED), m_current_file(current_file), 87351290Sdim m_current_file_line(current_file_line) {} 88351290Sdim 89351290Sdim void StartFile(const FileSpec &file) { 90351290Sdim m_file_stack.push_back(file); 91351290Sdim if (file == m_current_file) 92351290Sdim m_state = CURRENT_FILE_PUSHED; 93351290Sdim } 94351290Sdim 95351290Sdim void EndFile() { 96351290Sdim if (m_file_stack.size() == 0) 97351290Sdim return; 98351290Sdim 99351290Sdim FileSpec old_top = m_file_stack.back(); 100351290Sdim m_file_stack.pop_back(); 101351290Sdim if (old_top == m_current_file) 102351290Sdim m_state = CURRENT_FILE_POPPED; 103351290Sdim } 104351290Sdim 105351290Sdim // An entry is valid if it occurs before the current line in the current 106351290Sdim // file. 107351290Sdim bool IsValidEntry(uint32_t line) { 108351290Sdim switch (m_state) { 109351290Sdim case CURRENT_FILE_NOT_YET_PUSHED: 110351290Sdim return true; 111351290Sdim case CURRENT_FILE_PUSHED: 112351290Sdim // If we are in file included in the current file, the entry should be 113351290Sdim // added. 114351290Sdim if (m_file_stack.back() != m_current_file) 115351290Sdim return true; 116351290Sdim 117351290Sdim return line < m_current_file_line; 118351290Sdim default: 119351290Sdim return false; 120351290Sdim } 121351290Sdim } 122351290Sdim 123351290Sdimprivate: 124351290Sdim std::vector<FileSpec> m_file_stack; 125351290Sdim State m_state; 126351290Sdim FileSpec m_current_file; 127351290Sdim uint32_t m_current_file_line; 128351290Sdim}; 129351290Sdim 130351290Sdim} // anonymous namespace 131351290Sdim 132351290Sdimstatic void AddMacros(const DebugMacros *dm, CompileUnit *comp_unit, 133351290Sdim AddMacroState &state, StreamString &stream) { 134351290Sdim if (dm == nullptr) 135351290Sdim return; 136351290Sdim 137351290Sdim for (size_t i = 0; i < dm->GetNumMacroEntries(); i++) { 138351290Sdim const DebugMacroEntry &entry = dm->GetMacroEntryAtIndex(i); 139351290Sdim uint32_t line; 140351290Sdim 141351290Sdim switch (entry.GetType()) { 142351290Sdim case DebugMacroEntry::DEFINE: 143351290Sdim if (state.IsValidEntry(entry.GetLineNumber())) 144351290Sdim stream.Printf("#define %s\n", entry.GetMacroString().AsCString()); 145351290Sdim else 146351290Sdim return; 147351290Sdim break; 148351290Sdim case DebugMacroEntry::UNDEF: 149351290Sdim if (state.IsValidEntry(entry.GetLineNumber())) 150351290Sdim stream.Printf("#undef %s\n", entry.GetMacroString().AsCString()); 151351290Sdim else 152351290Sdim return; 153351290Sdim break; 154351290Sdim case DebugMacroEntry::START_FILE: 155351290Sdim line = entry.GetLineNumber(); 156351290Sdim if (state.IsValidEntry(line)) 157351290Sdim state.StartFile(entry.GetFileSpec(comp_unit)); 158351290Sdim else 159351290Sdim return; 160351290Sdim break; 161351290Sdim case DebugMacroEntry::END_FILE: 162351290Sdim state.EndFile(); 163351290Sdim break; 164351290Sdim case DebugMacroEntry::INDIRECT: 165351290Sdim AddMacros(entry.GetIndirectDebugMacros(), comp_unit, state, stream); 166351290Sdim break; 167351290Sdim default: 168351290Sdim // This is an unknown/invalid entry. Ignore. 169351290Sdim break; 170351290Sdim } 171351290Sdim } 172351290Sdim} 173351290Sdim 174360784Sdimlldb_private::ClangExpressionSourceCode::ClangExpressionSourceCode( 175360784Sdim llvm::StringRef filename, llvm::StringRef name, llvm::StringRef prefix, 176360784Sdim llvm::StringRef body, Wrapping wrap) 177360784Sdim : ExpressionSourceCode(name, prefix, body, wrap) { 178360784Sdim // Use #line markers to pretend that we have a single-line source file 179360784Sdim // containing only the user expression. This will hide our wrapper code 180360784Sdim // from the user when we render diagnostics with Clang. 181360784Sdim m_start_marker = "#line 1 \"" + filename.str() + "\"\n"; 182360784Sdim m_end_marker = "\n;\n#line 1 \"<lldb wrapper suffix>\"\n"; 183360784Sdim} 184360784Sdim 185351290Sdimnamespace { 186351290Sdim/// Allows checking if a token is contained in a given expression. 187351290Sdimclass TokenVerifier { 188351290Sdim /// The tokens we found in the expression. 189351290Sdim llvm::StringSet<> m_tokens; 190351290Sdim 191351290Sdimpublic: 192351290Sdim TokenVerifier(std::string body); 193351290Sdim /// Returns true iff the given expression body contained a token with the 194351290Sdim /// given content. 195351290Sdim bool hasToken(llvm::StringRef token) const { 196351290Sdim return m_tokens.find(token) != m_tokens.end(); 197351290Sdim } 198351290Sdim}; 199351290Sdim} // namespace 200351290Sdim 201351290SdimTokenVerifier::TokenVerifier(std::string body) { 202351290Sdim using namespace clang; 203351290Sdim 204351290Sdim // We only care about tokens and not their original source locations. If we 205351290Sdim // move the whole expression to only be in one line we can simplify the 206351290Sdim // following code that extracts the token contents. 207351290Sdim std::replace(body.begin(), body.end(), '\n', ' '); 208351290Sdim std::replace(body.begin(), body.end(), '\r', ' '); 209351290Sdim 210351290Sdim FileSystemOptions file_opts; 211351290Sdim FileManager file_mgr(file_opts, 212351290Sdim FileSystem::Instance().GetVirtualFileSystem()); 213351290Sdim 214351290Sdim // Let's build the actual source code Clang needs and setup some utility 215351290Sdim // objects. 216351290Sdim llvm::IntrusiveRefCntPtr<DiagnosticIDs> diag_ids(new DiagnosticIDs()); 217351290Sdim llvm::IntrusiveRefCntPtr<DiagnosticOptions> diags_opts( 218351290Sdim new DiagnosticOptions()); 219351290Sdim DiagnosticsEngine diags(diag_ids, diags_opts); 220351290Sdim clang::SourceManager SM(diags, file_mgr); 221351290Sdim auto buf = llvm::MemoryBuffer::getMemBuffer(body); 222351290Sdim 223351290Sdim FileID FID = SM.createFileID(clang::SourceManager::Unowned, buf.get()); 224351290Sdim 225351290Sdim // Let's just enable the latest ObjC and C++ which should get most tokens 226351290Sdim // right. 227351290Sdim LangOptions Opts; 228351290Sdim Opts.ObjC = true; 229351290Sdim Opts.DollarIdents = true; 230351290Sdim Opts.CPlusPlus17 = true; 231351290Sdim Opts.LineComment = true; 232351290Sdim 233351290Sdim Lexer lex(FID, buf.get(), SM, Opts); 234351290Sdim 235351290Sdim Token token; 236351290Sdim bool exit = false; 237351290Sdim while (!exit) { 238351290Sdim // Returns true if this is the last token we get from the lexer. 239351290Sdim exit = lex.LexFromRawLexer(token); 240351290Sdim 241351290Sdim // Extract the column number which we need to extract the token content. 242351290Sdim // Our expression is just one line, so we don't need to handle any line 243351290Sdim // numbers here. 244351290Sdim bool invalid = false; 245351290Sdim unsigned start = SM.getSpellingColumnNumber(token.getLocation(), &invalid); 246351290Sdim if (invalid) 247351290Sdim continue; 248351290Sdim // Column numbers start at 1, but indexes in our string start at 0. 249351290Sdim --start; 250351290Sdim 251351290Sdim // Annotations don't have a length, so let's skip them. 252351290Sdim if (token.isAnnotation()) 253351290Sdim continue; 254351290Sdim 255351290Sdim // Extract the token string from our source code and store it. 256351290Sdim std::string token_str = body.substr(start, token.getLength()); 257351290Sdim if (token_str.empty()) 258351290Sdim continue; 259351290Sdim m_tokens.insert(token_str); 260351290Sdim } 261351290Sdim} 262351290Sdim 263351290Sdimstatic void AddLocalVariableDecls(const lldb::VariableListSP &var_list_sp, 264351290Sdim StreamString &stream, 265351290Sdim const std::string &expr, 266351290Sdim lldb::LanguageType wrapping_language) { 267351290Sdim TokenVerifier tokens(expr); 268351290Sdim 269351290Sdim for (size_t i = 0; i < var_list_sp->GetSize(); i++) { 270351290Sdim lldb::VariableSP var_sp = var_list_sp->GetVariableAtIndex(i); 271351290Sdim 272351290Sdim ConstString var_name = var_sp->GetName(); 273351290Sdim 274351290Sdim 275351290Sdim // We can check for .block_descriptor w/o checking for langauge since this 276351290Sdim // is not a valid identifier in either C or C++. 277351290Sdim if (!var_name || var_name == ".block_descriptor") 278351290Sdim continue; 279351290Sdim 280351290Sdim if (!expr.empty() && !tokens.hasToken(var_name.GetStringRef())) 281351290Sdim continue; 282351290Sdim 283351290Sdim if ((var_name == "self" || var_name == "_cmd") && 284351290Sdim (wrapping_language == lldb::eLanguageTypeObjC || 285351290Sdim wrapping_language == lldb::eLanguageTypeObjC_plus_plus)) 286351290Sdim continue; 287351290Sdim 288351290Sdim if (var_name == "this" && 289351290Sdim wrapping_language == lldb::eLanguageTypeC_plus_plus) 290351290Sdim continue; 291351290Sdim 292351290Sdim stream.Printf("using $__lldb_local_vars::%s;\n", var_name.AsCString()); 293351290Sdim } 294351290Sdim} 295351290Sdim 296351290Sdimbool ClangExpressionSourceCode::GetText( 297351290Sdim std::string &text, lldb::LanguageType wrapping_language, bool static_method, 298351290Sdim ExecutionContext &exe_ctx, bool add_locals, bool force_add_all_locals, 299351290Sdim llvm::ArrayRef<std::string> modules) const { 300351290Sdim const char *target_specific_defines = "typedef signed char BOOL;\n"; 301351290Sdim std::string module_macros; 302351290Sdim 303351290Sdim Target *target = exe_ctx.GetTargetPtr(); 304351290Sdim if (target) { 305360784Sdim if (target->GetArchitecture().GetMachine() == llvm::Triple::aarch64 || 306360784Sdim target->GetArchitecture().GetMachine() == llvm::Triple::aarch64_32) { 307351290Sdim target_specific_defines = "typedef bool BOOL;\n"; 308351290Sdim } 309351290Sdim if (target->GetArchitecture().GetMachine() == llvm::Triple::x86_64) { 310351290Sdim if (lldb::PlatformSP platform_sp = target->GetPlatform()) { 311351290Sdim static ConstString g_platform_ios_simulator("ios-simulator"); 312351290Sdim if (platform_sp->GetPluginName() == g_platform_ios_simulator) { 313351290Sdim target_specific_defines = "typedef bool BOOL;\n"; 314351290Sdim } 315351290Sdim } 316351290Sdim } 317351290Sdim 318360784Sdim ClangModulesDeclVendor *decl_vendor = target->GetClangModulesDeclVendor(); 319360784Sdim auto *persistent_vars = llvm::cast<ClangPersistentVariables>( 320360784Sdim target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC)); 321360784Sdim if (decl_vendor && persistent_vars) { 322351290Sdim const ClangModulesDeclVendor::ModuleVector &hand_imported_modules = 323351290Sdim persistent_vars->GetHandLoadedClangModules(); 324351290Sdim ClangModulesDeclVendor::ModuleVector modules_for_macros; 325351290Sdim 326351290Sdim for (ClangModulesDeclVendor::ModuleID module : hand_imported_modules) { 327351290Sdim modules_for_macros.push_back(module); 328351290Sdim } 329351290Sdim 330351290Sdim if (target->GetEnableAutoImportClangModules()) { 331351290Sdim if (StackFrame *frame = exe_ctx.GetFramePtr()) { 332351290Sdim if (Block *block = frame->GetFrameBlock()) { 333351290Sdim SymbolContext sc; 334351290Sdim 335351290Sdim block->CalculateSymbolContext(&sc); 336351290Sdim 337351290Sdim if (sc.comp_unit) { 338351290Sdim StreamString error_stream; 339351290Sdim 340351290Sdim decl_vendor->AddModulesForCompileUnit( 341351290Sdim *sc.comp_unit, modules_for_macros, error_stream); 342351290Sdim } 343351290Sdim } 344351290Sdim } 345351290Sdim } 346351290Sdim 347351290Sdim decl_vendor->ForEachMacro( 348351290Sdim modules_for_macros, 349351290Sdim [&module_macros](const std::string &expansion) -> bool { 350351290Sdim module_macros.append(expansion); 351351290Sdim module_macros.append("\n"); 352351290Sdim return false; 353351290Sdim }); 354351290Sdim } 355351290Sdim } 356351290Sdim 357351290Sdim StreamString debug_macros_stream; 358351290Sdim StreamString lldb_local_var_decls; 359351290Sdim if (StackFrame *frame = exe_ctx.GetFramePtr()) { 360351290Sdim const SymbolContext &sc = frame->GetSymbolContext( 361351290Sdim lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry); 362351290Sdim 363351290Sdim if (sc.comp_unit && sc.line_entry.IsValid()) { 364351290Sdim DebugMacros *dm = sc.comp_unit->GetDebugMacros(); 365351290Sdim if (dm) { 366351290Sdim AddMacroState state(sc.line_entry.file, sc.line_entry.line); 367351290Sdim AddMacros(dm, sc.comp_unit, state, debug_macros_stream); 368351290Sdim } 369351290Sdim } 370351290Sdim 371351290Sdim if (add_locals) 372351290Sdim if (target->GetInjectLocalVariables(&exe_ctx)) { 373351290Sdim lldb::VariableListSP var_list_sp = 374351290Sdim frame->GetInScopeVariableList(false, true); 375351290Sdim AddLocalVariableDecls(var_list_sp, lldb_local_var_decls, 376351290Sdim force_add_all_locals ? "" : m_body, 377351290Sdim wrapping_language); 378351290Sdim } 379351290Sdim } 380351290Sdim 381351290Sdim if (m_wrap) { 382351290Sdim switch (wrapping_language) { 383351290Sdim default: 384351290Sdim return false; 385351290Sdim case lldb::eLanguageTypeC: 386351290Sdim case lldb::eLanguageTypeC_plus_plus: 387351290Sdim case lldb::eLanguageTypeObjC: 388351290Sdim break; 389351290Sdim } 390351290Sdim 391351290Sdim // Generate a list of @import statements that will import the specified 392351290Sdim // module into our expression. 393351290Sdim std::string module_imports; 394351290Sdim for (const std::string &module : modules) { 395351290Sdim module_imports.append("@import "); 396351290Sdim module_imports.append(module); 397351290Sdim module_imports.append(";\n"); 398351290Sdim } 399351290Sdim 400351290Sdim StreamString wrap_stream; 401351290Sdim 402351290Sdim wrap_stream.Printf("%s\n%s\n%s\n%s\n%s\n", module_macros.c_str(), 403351290Sdim debug_macros_stream.GetData(), g_expression_prefix, 404351290Sdim target_specific_defines, m_prefix.c_str()); 405351290Sdim 406351290Sdim // First construct a tagged form of the user expression so we can find it 407351290Sdim // later: 408351290Sdim std::string tagged_body; 409351290Sdim switch (wrapping_language) { 410351290Sdim default: 411351290Sdim tagged_body = m_body; 412351290Sdim break; 413351290Sdim case lldb::eLanguageTypeC: 414351290Sdim case lldb::eLanguageTypeC_plus_plus: 415351290Sdim case lldb::eLanguageTypeObjC: 416360784Sdim tagged_body.append(m_start_marker); 417351290Sdim tagged_body.append(m_body); 418360784Sdim tagged_body.append(m_end_marker); 419351290Sdim break; 420351290Sdim } 421351290Sdim switch (wrapping_language) { 422351290Sdim default: 423351290Sdim break; 424351290Sdim case lldb::eLanguageTypeC: 425351290Sdim wrap_stream.Printf("%s" 426351290Sdim "void \n" 427351290Sdim "%s(void *$__lldb_arg) \n" 428351290Sdim "{ \n" 429351290Sdim " %s; \n" 430351290Sdim "%s" 431351290Sdim "} \n", 432351290Sdim module_imports.c_str(), m_name.c_str(), 433351290Sdim lldb_local_var_decls.GetData(), tagged_body.c_str()); 434351290Sdim break; 435351290Sdim case lldb::eLanguageTypeC_plus_plus: 436351290Sdim wrap_stream.Printf("%s" 437351290Sdim "void \n" 438351290Sdim "$__lldb_class::%s(void *$__lldb_arg) \n" 439351290Sdim "{ \n" 440351290Sdim " %s; \n" 441351290Sdim "%s" 442351290Sdim "} \n", 443351290Sdim module_imports.c_str(), m_name.c_str(), 444351290Sdim lldb_local_var_decls.GetData(), tagged_body.c_str()); 445351290Sdim break; 446351290Sdim case lldb::eLanguageTypeObjC: 447351290Sdim if (static_method) { 448351290Sdim wrap_stream.Printf( 449351290Sdim "%s" 450351290Sdim "@interface $__lldb_objc_class ($__lldb_category) \n" 451351290Sdim "+(void)%s:(void *)$__lldb_arg; \n" 452351290Sdim "@end \n" 453351290Sdim "@implementation $__lldb_objc_class ($__lldb_category) \n" 454351290Sdim "+(void)%s:(void *)$__lldb_arg \n" 455351290Sdim "{ \n" 456351290Sdim " %s; \n" 457351290Sdim "%s" 458351290Sdim "} \n" 459351290Sdim "@end \n", 460351290Sdim module_imports.c_str(), m_name.c_str(), m_name.c_str(), 461351290Sdim lldb_local_var_decls.GetData(), tagged_body.c_str()); 462351290Sdim } else { 463351290Sdim wrap_stream.Printf( 464351290Sdim "%s" 465351290Sdim "@interface $__lldb_objc_class ($__lldb_category) \n" 466351290Sdim "-(void)%s:(void *)$__lldb_arg; \n" 467351290Sdim "@end \n" 468351290Sdim "@implementation $__lldb_objc_class ($__lldb_category) \n" 469351290Sdim "-(void)%s:(void *)$__lldb_arg \n" 470351290Sdim "{ \n" 471351290Sdim " %s; \n" 472351290Sdim "%s" 473351290Sdim "} \n" 474351290Sdim "@end \n", 475351290Sdim module_imports.c_str(), m_name.c_str(), m_name.c_str(), 476351290Sdim lldb_local_var_decls.GetData(), tagged_body.c_str()); 477351290Sdim } 478351290Sdim break; 479351290Sdim } 480351290Sdim 481351290Sdim text = wrap_stream.GetString(); 482351290Sdim } else { 483351290Sdim text.append(m_body); 484351290Sdim } 485351290Sdim 486351290Sdim return true; 487351290Sdim} 488351290Sdim 489351290Sdimbool ClangExpressionSourceCode::GetOriginalBodyBounds( 490351290Sdim std::string transformed_text, lldb::LanguageType wrapping_language, 491351290Sdim size_t &start_loc, size_t &end_loc) { 492351290Sdim switch (wrapping_language) { 493351290Sdim default: 494351290Sdim return false; 495351290Sdim case lldb::eLanguageTypeC: 496351290Sdim case lldb::eLanguageTypeC_plus_plus: 497351290Sdim case lldb::eLanguageTypeObjC: 498351290Sdim break; 499351290Sdim } 500351290Sdim 501360784Sdim start_loc = transformed_text.find(m_start_marker); 502351290Sdim if (start_loc == std::string::npos) 503351290Sdim return false; 504360784Sdim start_loc += m_start_marker.size(); 505360784Sdim end_loc = transformed_text.find(m_end_marker); 506351290Sdim return end_loc != std::string::npos; 507351290Sdim} 508