[PATCH] D102750: [clang] Fix a crash on CheckArgAlignment.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 19 04:30:00 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGf5b5426433c9: [clang] Fix a crash on CheckArgAlignment. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

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.346405.patch
Type: text/x-patch
Size: 1283 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210519/1784b407/attachment.bin>


More information about the cfe-commits mailing list