[PATCH] D102750: [clang] Fix a crash on CheckArgAlignment.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 19 01:31:39 PDT 2021
hokein created this revision.
hokein added a reviewer: kadircet.
hokein requested review of this revision.
Herald added a project: clang.
We might encounter an undeduced type before calling getTypeAlignInChars.
NOTE: this retrieve the fix from
8f80c66bd2982788a8eede4419684ca72f48b9a2 <https://reviews.llvm.org/rG8f80c66bd2982788a8eede4419684ca72f48b9a2>, which was removed in a Adam's
followup fix fbfcfdbf6828b8d36f4ec0ff5f4eac11fb1411a5 <https://reviews.llvm.org/rGfbfcfdbf6828b8d36f4ec0ff5f4eac11fb1411a5>. We originally
thought the crash was caused by recovery-ast, but it turns out it can
occur for other cases, e.g. typo-correction.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D102750
Files:
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaCXX/typo-correction-crash.cpp
Index: clang/test/SemaCXX/typo-correction-crash.cpp
===================================================================
--- clang/test/SemaCXX/typo-correction-crash.cpp
+++ clang/test/SemaCXX/typo-correction-crash.cpp
@@ -42,3 +42,12 @@
}
};
}
+
+namespace NoCrashOnCheckArgAlignment {
+template <typename a> void b(a &);
+void test() {
+ for (auto file_data :b(files_db_data)); // expected-error {{use of undeclared identifier 'files_db_data'; did you mean 'file_data'?}} \
+ // expected-note {{'file_data' declared here}} \
+ // expected-error {{cannot use type 'void' as a range}}
+}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4571,7 +4571,8 @@
// Find expected alignment, and the actual alignment of the passed object.
// getTypeAlignInChars requires complete types
- if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType())
+ if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
+ ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
return;
CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102750.346359.patch
Type: text/x-patch
Size: 1283 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210519/81278a88/attachment.bin>
More information about the cfe-commits
mailing list