[llvm] 9aea667 - [symbolizer] Change the ErrorHandler from llvm::function_ref to std::function. (#115477)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 8 07:01:23 PST 2024
Author: Haojian Wu
Date: 2024-11-08T16:01:19+01:00
New Revision: 9aea6671085f02e6127750103ca48ae6a09ceeb8
URL: https://github.com/llvm/llvm-project/commit/9aea6671085f02e6127750103ca48ae6a09ceeb8
DIFF: https://github.com/llvm/llvm-project/commit/9aea6671085f02e6127750103ca48ae6a09ceeb8.diff
LOG: [symbolizer] Change the ErrorHandler from llvm::function_ref to std::function. (#115477)
This fixes dangling `ErrorHandler` references
([here](https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp#L48-L53)
is an example).
`llvm::function_ref` doesn't own the callable, and it is not safe to
store a function_ref (the `PlainPrinterBase` stores a
`llvm::function_ref` which can easily lead to dangling references).
Added:
Modified:
llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h b/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
index 72ffdd29f1b72d..828875f1bb0ede 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/DIPrinter.h
@@ -65,7 +65,7 @@ struct PrinterConfig {
int SourceContextLines;
};
-using ErrorHandler = function_ref<void(const ErrorInfoBase &, StringRef)>;
+using ErrorHandler = std::function<void(const ErrorInfoBase &, StringRef)>;
class PlainPrinterBase : public DIPrinter {
protected:
More information about the llvm-commits
mailing list