[PATCH] D155058: [Remark] Overload `<<` for Remark, RemarkType and RemarkLocation.

Alex Langford via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 12 18:15:18 PDT 2023


bulbazord added inline comments.


================
Comment at: llvm/include/llvm/Remarks/Remark.h:75-92
+inline std::string typeToStr(Type Ty) {
+  switch (Ty) {
+  case Type::Unknown:
+    return "Unknown";
+  case Type::Missed:
+    return "Missed";
+  case Type::Passed:
----------------
JDevlieghere wrote:
> Given that there are all string literals, this function should return a `StringRef` and avoid the `std::string` allocation. 
+1


================
Comment at: llvm/lib/Remarks/Remark.cpp:30-31
+  OS << "{ "
+     << "File: " << SourceFilePath.str() << ", Ln: " << SourceLine
+     << " Col:" << SourceColumn << " }\n";
+}
----------------
No need for the additional allocation, you can send StringRefs to raw_ostreams.


================
Comment at: llvm/lib/Remarks/Remark.cpp:35
+void Argument::print(raw_ostream &OS) const {
+  OS << Key.str() << ": " << Val.str();
+}
----------------



================
Comment at: llvm/lib/Remarks/Remark.cpp:42-43
+  OS << "RemarkType: " << typeToStr(RemarkType) << "\n";
+  OS << "FunctionName: " << FunctionName.str() << "\n";
+  OS << "PassName: " << PassName.str() << "\n";
+  if (Loc)
----------------



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155058/new/

https://reviews.llvm.org/D155058



More information about the llvm-commits mailing list