[clang] [-Wunsafe-buffer-usage] Introduce std::array fixits (PR #80084)

Ziqing Luo via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 7 14:19:03 PST 2024


================
@@ -2495,10 +2471,100 @@ static FixItList fixVariableWithSpan(const VarDecl *VD,
   return fixLocalVarDeclWithSpan(VD, Ctx, getUserFillPlaceHolder(), Handler);
 }
 
+static FixItList fixVarDeclWithArray(const VarDecl *D, const ASTContext &Ctx,
+                                     UnsafeBufferUsageHandler &Handler) {
+  FixItList FixIts{};
+
+  if (auto CAT = dyn_cast<clang::ConstantArrayType>(D->getType())) {
+    const QualType &ArrayEltT = CAT->getElementType();
+    assert(!ArrayEltT.isNull() && "Trying to fix a non-array type variable!");
+    // FIXME: support multi-dimensional arrays
+    if (isa<clang::ConstantArrayType>(ArrayEltT))
----------------
ziqingluo-90 wrote:

is it possible that the element type is an array type but not a constant array type?

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


More information about the cfe-commits mailing list