aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Remarks
diff options
context:
space:
mode:
authorZain Jaffal <z_jaffal@apple.com>2023-07-24 14:46:48 +0100
committerZain Jaffal <z_jaffal@apple.com>2023-07-24 14:49:01 +0100
commit3161db8ca07eaf76106cb73128f8c4e08571bde1 (patch)
tree032c3af2625f34a4d2c878376b0bc9b90504fded /llvm/lib/Remarks
parente71bae94b04391cb47680622666d448418c0d972 (diff)
downloadllvm-3161db8ca07eaf76106cb73128f8c4e08571bde1.zip
llvm-3161db8ca07eaf76106cb73128f8c4e08571bde1.tar.gz
llvm-3161db8ca07eaf76106cb73128f8c4e08571bde1.tar.bz2
[Remark] Overload `<<` for Remark, RemarkType and RemarkLocation.
Represent different remark concepts as strings by overloading the `<<` operator. Reviewed By: thegameg Differential Revision: https://reviews.llvm.org/D155058
Diffstat (limited to 'llvm/lib/Remarks')
-rw-r--r--llvm/lib/Remarks/Remark.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/llvm/lib/Remarks/Remark.cpp b/llvm/lib/Remarks/Remark.cpp
index a038f81..1b248db 100644
--- a/llvm/lib/Remarks/Remark.cpp
+++ b/llvm/lib/Remarks/Remark.cpp
@@ -12,7 +12,6 @@
#include "llvm/Remarks/Remark.h"
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/Support/raw_ostream.h"
#include <optional>
using namespace llvm;
@@ -26,6 +25,33 @@ std::string Remark::getArgsAsMsg() const {
return OS.str();
}
+void RemarkLocation::print(raw_ostream &OS) const {
+ OS << "{ "
+ << "File: " << SourceFilePath << ", Line: " << SourceLine
+ << " Column:" << SourceColumn << " }\n";
+}
+
+void Argument::print(raw_ostream &OS) const {
+ OS << Key << ": " << Val << "\n";
+}
+
+void Remark::print(raw_ostream &OS) const {
+ OS << "Name: ";
+ OS << RemarkName << "\n";
+ OS << "Type: " << typeToStr(RemarkType) << "\n";
+ OS << "FunctionName: " << FunctionName << "\n";
+ OS << "PassName: " << PassName << "\n";
+ if (Loc)
+ OS << "Loc: " << Loc.value();
+ if (Hotness)
+ OS << "Hotness: " << Hotness;
+ if (!Args.empty()) {
+ OS << "Args:\n";
+ for (auto Arg : Args)
+ OS << "\t" << Arg;
+ }
+}
+
// Create wrappers for C Binding types (see CBindingWrapping.h).
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(StringRef, LLVMRemarkStringRef)