[clang-tools-extra] [clangd] Extract to function: Fix parameter declarator printing (PR #230046)

Aleksandr Platonov via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 14 04:20:55 PDT 2026


================
@@ -1163,6 +1181,19 @@ bool createParameters(NewFunction &ExtractedFunc,
     // Parameter qualifiers are same as the Decl's qualifiers.
     QualType FullTypeInfo = VD->getType();
     QualType TypeInfo = FullTypeInfo.getNonReferenceType();
+
+    // A variably-modified type that isn't itself a plain array (e.g. a
+    // pointer to a VLA, `int (*)[N]`) has no path below that handles it
+    // safely: its bound is baked into the type at every level, so it
+    // keeps mentioning `N` whether passed by value, by reference, or
+    // (in C) by pointer -- const-qualifying or wrapping it in another
+    // pointer/reference doesn't remove the bound from the type the way
+    // decaying an array's own outer dimension does. A plain array gets
+    // a narrower, more precise check further down instead, since its
+    // outer dimension specifically isn't a problem once decayed.
+    if (TypeInfo->isVariablyModifiedType() && !TypeInfo->isArrayType())
----------------
ArcsinX wrote:

Here we reject variable modified type if it's not array, but lower (where my previous comment was) we reject for array types too in case of C++. So, maybe we can combine these checks here:
```cpp
    if (TypeInfo->isVariablyModifiedType() &&
        (LangOpts.CPlusPlus || !TypeInfo->isArrayType()))
      return false;
```

And remove the check there (where my prev comment was)

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


More information about the cfe-commits mailing list