[PATCH] D127923: [Diagnostics] Accept newline and format diag opts on first line

Scott Linder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 17 11:25:17 PDT 2022


scott.linder added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp:99-103
+      size_t NewlinePos = PD->getShortDescription().find_first_of('\n');
+      if (NewlinePos != std::string::npos)
+        OutStr = PD->getShortDescription().str().insert(NewlinePos, WarningMsg);
+      else
+        OutStr = (PD->getShortDescription() + WarningMsg).str();
----------------
scott.linder wrote:
> It's frustrating that `std::string::insert` doesn't follow the pattern of `npos==end-of-string`, but I'd still suggest only doing the actual insert/append once
Or to be more precise, I would try to only have one piece of code doing the insert/append


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127923



More information about the cfe-commits mailing list