[PATCH] D133886: [clang][RecoveryExpr] Don't perform alignment check if parameter type contains errors

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 14 13:55:40 PDT 2022


hokein added inline comments.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:5779
         QualType ParamTy = Proto->getParamType(ArgIdx);
+        if (ParamTy->containsErrors())
+          continue;
----------------
It looks like for the failure case the `ParamTy` for the parameter is a dependent array type, and it violates the "non-dependent" assumption of `clang::ASTContext::getTypeInfoImpl` which is called by  `getTypeAlignInChars` in `CheckArgAlignment`.

so I'd suggest moving the fix to `CheckArgAlignment` line 5685 (adding a `ParamTy->isDependentType()` to the `if` condition).


================
Comment at: clang/test/SemaCXX/recovery-expr-type.cpp:171
+  struct {
+    void m(UC (&)[SZ]) {}
+  } S;
----------------
we can simplify it further:

```
void m(int (&)[undefined()]) {}
...


S.m(1);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133886/new/

https://reviews.llvm.org/D133886



More information about the cfe-commits mailing list