[PATCH] D81384: [AST] Fix a clang crash on an invalid for-range statement.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 8 06:31:03 PDT 2020


hokein marked an inline comment as done.
hokein added inline comments.


================
Comment at: clang/lib/Sema/SemaStmt.cpp:2437
     if (RequireCompleteType(RangeLoc, RangeType,
-                            diag::err_for_range_incomplete_type))
+                            diag::err_for_range_incomplete_type)) {
+      if (LoopVar->getType()->isUndeducedType())
----------------
some details:
for the crash case, the RangeType is a `Bar<int>` class specialization, `RequireCompleteType` generates a definition decl of `Bar<int>`, which is invalid, and `RequireCompleteType` returns true, and doesn't emit a diagnostic (seems to suppress the "incomplete-type" diagnostic for invalid decls), so the trick `InvalidateOnErrorScope` (on Line 2396) doesn't invalidate the LoopVar Decl, we have to manually invalidate it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81384





More information about the cfe-commits mailing list