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

Aleksandr Platonov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 15 00:13:00 PDT 2022


ArcsinX added inline comments.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:5779
         QualType ParamTy = Proto->getParamType(ArgIdx);
+        if (ParamTy->containsErrors())
+          continue;
----------------
hokein wrote:
> 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).
When I found this problem I fixed it like you are suggesting. But after that I replaced it with this check, because it seems there is no reason to try to check something on code with errors.

I mean that even if we are not crashing, results from `CheckArgAlignment()` can't be trusted if we are passing  something with errors to it.


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