Timm =?utf-8?q?Bäder?= <tbae...@redhat.com> Message-ID: In-Reply-To: <llvm.org/llvm/llvm-project/pull/117...@github.com>
================ @@ -454,62 +454,43 @@ void DiagnosticRenderer::emitSingleMacroExpansion( SpellingRanges, {}); } -/// Check that the macro argument location of Loc starts with ArgumentLoc. -/// The starting location of the macro expansions is used to differeniate -/// different macro expansions. -static bool checkLocForMacroArgExpansion(SourceLocation Loc, - const SourceManager &SM, - SourceLocation ArgumentLoc) { - SourceLocation MacroLoc; - if (SM.isMacroArgExpansion(Loc, &MacroLoc)) { - if (ArgumentLoc == MacroLoc) return true; - } - - return false; -} - -/// Check if all the locations in the range have the same macro argument -/// expansion, and that the expansion starts with ArgumentLoc. -static bool checkRangeForMacroArgExpansion(CharSourceRange Range, - const SourceManager &SM, - SourceLocation ArgumentLoc) { - SourceLocation BegLoc = Range.getBegin(), EndLoc = Range.getEnd(); - while (BegLoc != EndLoc) { - if (!checkLocForMacroArgExpansion(BegLoc, SM, ArgumentLoc)) - return false; - BegLoc.getLocWithOffset(1); - } - - return checkLocForMacroArgExpansion(BegLoc, SM, ArgumentLoc); -} - /// A helper function to check if the current ranges are all inside the same /// macro argument expansion as Loc. -static bool checkRangesForMacroArgExpansion(FullSourceLoc Loc, - ArrayRef<CharSourceRange> Ranges) { +static bool +rangesInsideSameMacroArgExpansion(FullSourceLoc Loc, + ArrayRef<CharSourceRange> Ranges) { assert(Loc.isMacroID() && "Must be a macro expansion!"); - SmallVector<CharSourceRange, 4> SpellingRanges; - mapDiagnosticRanges(Loc, Ranges, SpellingRanges); - - // Count all valid ranges. - unsigned ValidCount = - llvm::count_if(Ranges, [](const auto &R) { return R.isValid(); }); + { ---------------- AaronBallman wrote: Is the extra compound statement helpful? https://github.com/llvm/llvm-project/pull/117671 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits