[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
Wed Sep 14 12:16:28 PDT 2022
ArcsinX created this revision.
ArcsinX added reviewers: hokein, kadircet.
Herald added a project: All.
ArcsinX requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
This patch fixes a crash which appears because of CheckArgAlignment() call with error type.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133886
Files:
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaCXX/recovery-expr-type.cpp
Index: clang/test/SemaCXX/recovery-expr-type.cpp
===================================================================
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -162,3 +162,15 @@
b = __builtin_object_size(c, 0); // crash2
}
}
+
+namespace test15 {
+const UnknownType SZ = 8; // expected-error {{unknown type}}
+typedef unsigned char UC;
+void f() {
+ struct {
+ void m(UC (&)[SZ]) {}
+ } S;
+ unsigned char A[8];
+ S.m(A); // no crash
+}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -5776,6 +5776,8 @@
checkAIXMemberAlignment((Arg->getExprLoc()), Arg);
QualType ParamTy = Proto->getParamType(ArgIdx);
+ if (ParamTy->containsErrors())
+ continue;
QualType ArgTy = Arg->getType();
CheckArgAlignment(Arg->getExprLoc(), FDecl, std::to_string(ArgIdx + 1),
ArgTy, ParamTy);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133886.460180.patch
Type: text/x-patch
Size: 1054 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220914/bfd0a9a6/attachment-0001.bin>
More information about the cfe-commits
mailing list