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);
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);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits