================
@@ -172,13 +172,52 @@ void UseStdMinMaxCheck::check(const
MatchFinder::MatchResult &Result) {
auto ReplaceAndDiagnose = [&](const llvm::StringRef FunctionName) {
const SourceManager &Source = *Result.SourceManager;
+ llvm::SmallString<64> Comment;
+
+ const auto AppendNormalized = [&](llvm::StringRef Text) {
+ Text = Text.ltrim();
+ if (!Text.empty()) {
+ if (!Comment.empty())
+ Comment += " ";
+ Comment += Text;
+ }
+ };
+
+ AppendNormalized(Lexer::getSourceText(
+ CharSourceRange::getCharRange(
+ Lexer::getLocForEndOfToken(If->getRParenLoc(), 0, Source, LO),
+ If->getThen()->getBeginLoc()),
+ Source, LO));
+
+ if (const auto *CS = dyn_cast<CompoundStmt>(If->getThen())) {
----------------
zeyi2 wrote:
Captures:
- `if (cond) { // Comment B`
- `if (cond) { /* Comment B */ x = y; }`
https://github.com/llvm/llvm-project/pull/169908
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits