=?utf-8?q?José?= L. Junior <josejun...@10xengineers.ai>,taalhaataahir0102 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>, =?utf-8?q?José?= L. Junior <josejun...@10xengineers.ai> Message-ID: In-Reply-To: <llvm.org/llvm/llvm-project/pull/69...@github.com>
================ @@ -246,8 +246,8 @@ class Address { /// \see Address::DumpStyle bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style = DumpStyleInvalid, - uint32_t addr_byte_size = UINT32_MAX, - bool all_ranges = false) const; + uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false, + const char *pattern = nullptr) const; ---------------- taalhaataahir0102 wrote: Hi @DavidSpickett . Tried this incremental approach: ``` static void test_func1(Stream &strm, llvm::Regex *regex_param = nullptr) { strm.Printf("Inside test_func1\n"); } static void test_func2(Stream &strm, llvm::Regex ®ex_param) { strm.Printf("Inside test_func2\n"); } static void test_func3(Stream &strm, const std::optional<llvm::Regex> regex_param = std::nullopt) { strm.Printf("Inside test_func3\n"); } static void test_func4(Stream &strm, const std::optional<llvm::Regex> ®ex_param = std::nullopt) { strm.Printf("Inside test_func4\n"); } static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter, Stream &strm, Module *module, const char *name, bool name_is_regex, bool verbose, bool all_ranges) { llvm::Regex regex1(name); std::optional<llvm::Regex> regex2 = std::make_optional<llvm::Regex>(name); test_func1(strm, ®ex1); test_func2(strm, regex1); // test_func3(strm, regex2); test_func4(strm, regex2); ... ... } ``` In test1, used the same logic like used previously i.e., function accepting pointer to `llvm::Regex` and default value is null pointer. In test2 passed `llvm::regex` by reference but could not give a default value. In test 3 used the `std::optional<llvm::Regex>` but was getting the error mentioned above i.e., use of deleted functions. The exact error is: ``` error: use of deleted function ‘std::optional<llvm::Regex>::optional(const std::optional<llvm::Regex>&)’ 1611 | test_func3(strm, regex2) ``` I believe it's due to the deletion of copy constructor which you mentioned. In test 4 passing the reference of `std::optional<llvm::Regex>` to the function which is working fine as expected. Will use this one to pass the pattern now. I'm a little confused. Right now, we're passing the pattern as `llvm::StringRef`, and finally when we reach `PutCStringColorHighlighted` we convert it to llvm::Regex: `llvm::Regex reg_pattern(pattern);` What will be the benefit of converting `const char* name` to `std::optional<llvm::Regex>` from the very beginning and than passing it till we reach `PutCStringColorHighlighted`? 🤔 https://github.com/llvm/llvm-project/pull/69422 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits