[clang-tools-extra] [clang-tidy] Temp fix for assert in performance-string-view-conversions (PR #179027)

Zinovy Nis via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 31 07:44:31 PST 2026


irishrover wrote:

> It seems that the `ParamExpr` may include the outer parentheses `(..)` while `RedundantExpr` doesn't... (IIUC `hasDescendant` traverses down into the expression tree)
> 
> So we are essentially comparing the range of: `(std::string(s))` and `std::string(s)`.
> 
> ```diff
> @@ -73,9 +73,10 @@ void StringViewConversionsCheck::registerMatchers(MatchFinder *Finder) {
>                 // Ignore cases where the argument is a function call
>                 unless(ignoringParenImpCasts(IsImplicitStringViewFromCall)),
>                 // Match either syntax for std::string construction
> -               hasDescendant(expr(anyOf(RedundantFunctionalCast,
> -                                        RedundantStringConstruction))
> -                                 .bind("redundantExpr")),
> +               hasDescendant(
> +                   expr(ignoringParens(expr(anyOf(RedundantFunctionalCast,
> +                                                  RedundantStringConstruction))))
> +                       .bind("redundantExpr")),
> ```
> 
> If this is the root cause, maybe we can implement the fix in this PR? WDYT?

Unfortunately did not help.

https://github.com/llvm/llvm-project/pull/179027


More information about the cfe-commits mailing list